Cache last shrinked source location.

This commit is contained in:
Bartosz Taudul 2019-10-25 21:07:28 +02:00
parent 294793367f
commit 779063a18b
2 changed files with 12 additions and 2 deletions

View File

@ -2584,11 +2584,13 @@ void Worker::NewSourceLocation( uint64_t ptr )
Query( ServerQuerySourceLocation, ptr );
}
int16_t Worker::ShrinkSourceLocation( uint64_t srcloc )
int16_t Worker::ShrinkSourceLocationReal( uint64_t srcloc )
{
auto it = m_sourceLocationShrink.find( srcloc );
if( it != m_sourceLocationShrink.end() )
{
m_data.shrinkSrclocLast.first = srcloc;
m_data.shrinkSrclocLast.second = it->second;
return it->second;
}
else
@ -2608,6 +2610,8 @@ int16_t Worker::NewShrinkedSourceLocation( uint64_t srcloc )
m_data.sourceLocationZonesCnt.emplace( sz, 0 );
#endif
m_sourceLocationShrink.emplace( srcloc, sz );
m_data.shrinkSrclocLast.first = srcloc;
m_data.shrinkSrclocLast.second = sz;
return sz;
}

View File

@ -215,6 +215,7 @@ private:
std::pair<uint64_t, ThreadData*> threadDataLast = std::make_pair( std::numeric_limits<uint64_t>::max(), nullptr );
std::pair<uint64_t, ContextSwitch*> ctxSwitchLast = std::make_pair( std::numeric_limits<uint64_t>::max(), nullptr );
uint64_t checkSrclocLast = 0;
std::pair<uint64_t, uint16_t> shrinkSrclocLast = std::make_pair( std::numeric_limits<uint64_t>::max(), 0 );
};
struct MbpsBlock
@ -469,7 +470,12 @@ private:
tracy_force_inline void CheckSourceLocation( uint64_t ptr );
void NewSourceLocation( uint64_t ptr );
tracy_force_inline int16_t ShrinkSourceLocation( uint64_t srcloc );
tracy_force_inline int16_t ShrinkSourceLocation( uint64_t srcloc )
{
if( m_data.shrinkSrclocLast.first == srcloc ) return m_data.shrinkSrclocLast.second;
return ShrinkSourceLocationReal( srcloc );
}
int16_t ShrinkSourceLocationReal( uint64_t srcloc );
int16_t NewShrinkedSourceLocation( uint64_t srcloc );
tracy_force_inline void MemAllocChanged( int64_t time );