@ -282,7 +282,7 @@ namespace Profiler
m_stackLevel = 0 ;
m_stackLevel = 0 ;
m_cachedTimeRegionMap . clear ( ) ;
m_cachedTimeRegionMap . clear ( ) ;
m_timeRegionStack . clear ( ) ;
m_timeRegionStack . clear ( ) ;
m_cachedTimeRegions. clear ( ) ;
ResetCachedData ( ) ;
}
}
timeRegion . m_stackDepth = aznumeric_cast < uint16_t > ( m_stackLevel ) ;
timeRegion . m_stackDepth = aznumeric_cast < uint16_t > ( m_stackLevel ) ;
@ -329,8 +329,21 @@ namespace Profiler
{
{
return ;
return ;
}
}
// Add an entry to the cached region
// Add an entry to the cached region. Discard excess data in case there is too much to handle.
m_cachedTimeRegions . push_back ( timeRegionCached ) ;
if ( m_cachedTimeRegions . size ( ) < TimeRegionStackSize )
{
m_cachedTimeRegions . push_back ( timeRegionCached ) ;
}
// Warn only once per thread if the cached data limit has been reached.
else if ( ! m_cachedDataLimitReached )
{
AZ_Warning (
" Profiler " , false ,
" Limit for profiling data has been reached by thread %i. Excess data will be discarded. Considering moving or reducing "
" profiler markers to prevent data loss. " ,
m_executingThreadId ) ;
m_cachedDataLimitReached = true ;
}
// If the stack is empty, add it to the local cache map. Only gets called when the stack is empty
// If the stack is empty, add it to the local cache map. Only gets called when the stack is empty
// NOTE: this is where the largest overhead will be, but due to it only being called when the stack is empty
// NOTE: this is where the largest overhead will be, but due to it only being called when the stack is empty
@ -354,7 +367,7 @@ namespace Profiler
}
}
// Clear the cached regions
// Clear the cached regions
m_cachedTimeRegions. clear ( ) ;
ResetCachedData ( ) ;
}
}
}
}
@ -371,10 +384,17 @@ namespace Profiler
m_cachedTimeRegionMap . clear ( ) ;
m_cachedTimeRegionMap . clear ( ) ;
m_hitSizeLimitMap . clear ( ) ;
m_hitSizeLimitMap . clear ( ) ;
}
}
m_cachedTimeRegionMutex . unlock ( ) ;
m_cachedTimeRegionMutex . unlock ( ) ;
}
}
}
}
void CpuTimingLocalStorage : : ResetCachedData ( )
{
m_cachedTimeRegions . clear ( ) ;
m_cachedDataLimitReached = false ;
}
// --- CpuProfilingStatisticsSerializer ---
// --- CpuProfilingStatisticsSerializer ---
CpuProfilingStatisticsSerializer : : CpuProfilingStatisticsSerializer ( const AZStd : : ring_buffer < CpuProfiler : : TimeRegionMap > & continuousData )
CpuProfilingStatisticsSerializer : : CpuProfilingStatisticsSerializer ( const AZStd : : ring_buffer < CpuProfiler : : TimeRegionMap > & continuousData )