mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Source file cache plumbing.
This commit is contained in:
parent
f38464cf55
commit
ae1155852a
@ -22,6 +22,7 @@
|
||||
#include "../common/TracyProtocol.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "TracyFileRead.hpp"
|
||||
#include "TracyFilesystem.hpp"
|
||||
#include "TracyFileWrite.hpp"
|
||||
#include "TracySort.hpp"
|
||||
#include "TracyTaskDispatch.hpp"
|
||||
@ -7299,4 +7300,28 @@ ZoneExtra& Worker::RequestZoneExtra( ZoneEvent& ev )
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::CacheSource( const StringRef& str )
|
||||
{
|
||||
assert( str.active );
|
||||
assert( m_checkedFileStrings.find( str ) == m_checkedFileStrings.end() );
|
||||
m_checkedFileStrings.emplace( str );
|
||||
auto file = GetString( str );
|
||||
if( SourceFileValid( file, GetCaptureTime() ) )
|
||||
{
|
||||
// Possible duplication of pointer and index strings
|
||||
if( m_data.sourceFileCache.find( file ) == m_data.sourceFileCache.end() )
|
||||
{
|
||||
FILE* f = fopen( file, "rb" );
|
||||
fseek( f, 0, SEEK_END );
|
||||
const auto sz = ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
auto src = (char*)m_slab.AllocBig( sz+1 );
|
||||
fread( src, 1, sz, f );
|
||||
src[sz] = '\0';
|
||||
fclose( f );
|
||||
m_data.sourceFileCache.emplace( file, MemoryBlock{ src, uint32_t( sz+1 ) } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -304,6 +304,8 @@ private:
|
||||
|
||||
unordered_flat_map<uint64_t, uint64_t> codeAddressToLocation;
|
||||
unordered_flat_map<uint64_t, Vector<uint64_t>> locationCodeAddressList;
|
||||
|
||||
unordered_flat_map<const char*, MemoryBlock, charutil::Hasher, charutil::Comparator> sourceFileCache;
|
||||
};
|
||||
|
||||
struct MbpsBlock
|
||||
@ -714,6 +716,8 @@ private:
|
||||
StringLocation StoreString( const char* str, size_t sz );
|
||||
const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread );
|
||||
|
||||
void CacheSource( const StringRef& str );
|
||||
|
||||
tracy_force_inline Vector<short_ptr<ZoneEvent>>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; }
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
tracy_force_inline Vector<GhostZone>& GetGhostChildrenMutable( int32_t idx ) { return m_data.ghostChildren[idx]; }
|
||||
@ -803,6 +807,8 @@ private:
|
||||
FrameImagePending m_pendingFrameImageData = {};
|
||||
unordered_flat_map<uint64_t, SymbolPending> m_pendingSymbols;
|
||||
unordered_flat_set<uint64_t> m_pendingSymbolCode;
|
||||
unordered_flat_set<StringRef, StringRefHasher, StringRefComparator> m_pendingFileStrings;
|
||||
unordered_flat_set<StringRef, StringRefHasher, StringRefComparator> m_checkedFileStrings;
|
||||
|
||||
uint32_t m_pendingStrings;
|
||||
uint32_t m_pendingThreads;
|
||||
|
Loading…
Reference in New Issue
Block a user