mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Store m_strings in common string storage.
This commit is contained in:
parent
b28fdc94ce
commit
5ec3ccd595
@ -207,18 +207,6 @@ View::View( FileRead& f )
|
|||||||
m_frames.push_back( v );
|
m_frames.push_back( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Read( &sz, sizeof( sz ) );
|
|
||||||
for( uint64_t i=0; i<sz; i++ )
|
|
||||||
{
|
|
||||||
uint64_t ptr;
|
|
||||||
f.Read( &ptr, sizeof( ptr ) );
|
|
||||||
uint64_t ssz;
|
|
||||||
f.Read( &ssz, sizeof( ssz ) );
|
|
||||||
char tmp[16*1024];
|
|
||||||
f.Read( tmp, ssz );
|
|
||||||
m_strings.emplace( ptr, std::string( tmp, tmp+ssz ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<uint64_t, const char*> pointerMap;
|
std::unordered_map<uint64_t, const char*> pointerMap;
|
||||||
|
|
||||||
f.Read( &sz, sizeof( sz ) );
|
f.Read( &sz, sizeof( sz ) );
|
||||||
@ -236,6 +224,15 @@ View::View( FileRead& f )
|
|||||||
pointerMap.emplace( ptr, dst );
|
pointerMap.emplace( ptr, dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.Read( &sz, sizeof( sz ) );
|
||||||
|
for( uint64_t i=0; i<sz; i++ )
|
||||||
|
{
|
||||||
|
uint64_t id, ptr;
|
||||||
|
f.Read( &id, sizeof( id ) );
|
||||||
|
f.Read( &ptr, sizeof( ptr ) );
|
||||||
|
m_strings.emplace( id, pointerMap.find( ptr )->second );
|
||||||
|
}
|
||||||
|
|
||||||
f.Read( &sz, sizeof( sz ) );
|
f.Read( &sz, sizeof( sz ) );
|
||||||
for( uint64_t i=0; i<sz; i++ )
|
for( uint64_t i=0; i<sz; i++ )
|
||||||
{
|
{
|
||||||
@ -538,7 +535,7 @@ void View::DispatchProcess( const QueueItem& ev, char*& ptr )
|
|||||||
AddCustomString( ev.stringTransfer.ptr, ptr, sz );
|
AddCustomString( ev.stringTransfer.ptr, ptr, sz );
|
||||||
break;
|
break;
|
||||||
case QueueType::StringData:
|
case QueueType::StringData:
|
||||||
AddString( ev.stringTransfer.ptr, std::string( ptr, ptr+sz ) );
|
AddString( ev.stringTransfer.ptr, ptr, sz );
|
||||||
break;
|
break;
|
||||||
case QueueType::ThreadName:
|
case QueueType::ThreadName:
|
||||||
AddThreadString( ev.stringTransfer.ptr, ptr, sz );
|
AddThreadString( ev.stringTransfer.ptr, ptr, sz );
|
||||||
@ -893,14 +890,15 @@ void View::CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst )
|
|||||||
ServerQuery( ServerQuerySourceLocationPayload, ptr );
|
ServerQuery( ServerQuerySourceLocationPayload, ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::AddString( uint64_t ptr, std::string&& str )
|
void View::AddString( uint64_t ptr, char* str, size_t sz )
|
||||||
{
|
{
|
||||||
assert( m_strings.find( ptr ) == m_strings.end() );
|
assert( m_strings.find( ptr ) == m_strings.end() );
|
||||||
auto it = m_pendingStrings.find( ptr );
|
auto it = m_pendingStrings.find( ptr );
|
||||||
assert( it != m_pendingStrings.end() );
|
assert( it != m_pendingStrings.end() );
|
||||||
m_pendingStrings.erase( it );
|
m_pendingStrings.erase( it );
|
||||||
|
const auto sl = StoreString( str, sz );
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
m_strings.emplace( ptr, std::move( str ) );
|
m_strings.emplace( ptr, sl.ptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::AddThreadString( uint64_t id, char* str, size_t sz )
|
void View::AddThreadString( uint64_t id, char* str, size_t sz )
|
||||||
@ -1224,7 +1222,7 @@ void View::HandlePlotName( uint64_t name, std::string&& str )
|
|||||||
m_plotRev.emplace( str, idx );
|
m_plotRev.emplace( str, idx );
|
||||||
std::lock_guard<std::mutex> lock( m_lock );
|
std::lock_guard<std::mutex> lock( m_lock );
|
||||||
m_plots.push_back( pit->second );
|
m_plots.push_back( pit->second );
|
||||||
m_strings.emplace( name, std::move( str ) );
|
//m_strings.emplace( name, std::move( str ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1335,7 +1333,7 @@ const char* View::GetString( uint64_t ptr ) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return it->second.c_str();
|
return it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3235,16 +3233,6 @@ void View::Write( FileWrite& f )
|
|||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
f.Write( m_frames.data(), sizeof( uint64_t ) * sz );
|
f.Write( m_frames.data(), sizeof( uint64_t ) * sz );
|
||||||
|
|
||||||
sz = m_strings.size();
|
|
||||||
f.Write( &sz, sizeof( sz ) );
|
|
||||||
for( auto& v : m_strings )
|
|
||||||
{
|
|
||||||
f.Write( &v.first, sizeof( v.first ) );
|
|
||||||
sz = v.second.size();
|
|
||||||
f.Write( &sz, sizeof( sz ) );
|
|
||||||
f.Write( v.second.c_str(), v.second.size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
sz = m_stringData.size();
|
sz = m_stringData.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
for( auto& v : m_stringData )
|
for( auto& v : m_stringData )
|
||||||
@ -3256,6 +3244,15 @@ void View::Write( FileWrite& f )
|
|||||||
f.Write( v, sz );
|
f.Write( v, sz );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sz = m_strings.size();
|
||||||
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
for( auto& v : m_strings )
|
||||||
|
{
|
||||||
|
f.Write( &v.first, sizeof( v.first ) );
|
||||||
|
uint64_t ptr = (uint64_t)v.second;
|
||||||
|
f.Write( &ptr, sizeof( ptr ) );
|
||||||
|
}
|
||||||
|
|
||||||
sz = m_threadNames.size();
|
sz = m_threadNames.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
for( auto& v : m_threadNames )
|
for( auto& v : m_threadNames )
|
||||||
|
|||||||
@ -148,7 +148,7 @@ private:
|
|||||||
void CheckSourceLocation( uint64_t ptr );
|
void CheckSourceLocation( uint64_t ptr );
|
||||||
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst );
|
||||||
|
|
||||||
void AddString( uint64_t ptr, std::string&& str );
|
void AddString( uint64_t ptr, char* str, size_t sz );
|
||||||
void AddThreadString( uint64_t id, char* str, size_t sz );
|
void AddThreadString( uint64_t id, char* str, size_t sz );
|
||||||
void AddCustomString( uint64_t ptr, char* str, size_t sz );
|
void AddCustomString( uint64_t ptr, char* str, size_t sz );
|
||||||
void AddSourceLocation( const QueueSourceLocation& srcloc );
|
void AddSourceLocation( const QueueSourceLocation& srcloc );
|
||||||
@ -238,7 +238,7 @@ private:
|
|||||||
Vector<MessageData*> m_messages;
|
Vector<MessageData*> m_messages;
|
||||||
Vector<TextData*> m_textData;
|
Vector<TextData*> m_textData;
|
||||||
Vector<SourceLocation*> m_sourceLocationPayload;
|
Vector<SourceLocation*> m_sourceLocationPayload;
|
||||||
std::unordered_map<uint64_t, std::string> m_strings;
|
std::unordered_map<uint64_t, const char*> m_strings;
|
||||||
std::unordered_map<uint64_t, const char*> m_threadNames;
|
std::unordered_map<uint64_t, const char*> m_threadNames;
|
||||||
std::unordered_map<uint64_t, SourceLocation> m_sourceLocation;
|
std::unordered_map<uint64_t, SourceLocation> m_sourceLocation;
|
||||||
std::vector<uint64_t> m_sourceLocationExpand;
|
std::vector<uint64_t> m_sourceLocationExpand;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user