Use Martin Ankerl's robin hood unordered map.

ska::flat_hash_map has bugs and its development is dead.
This commit is contained in:
Bartosz Taudul 2020-01-28 21:49:36 +01:00
parent ac9479aa3f
commit 022528bb47
20 changed files with 2290 additions and 1579 deletions

View File

@ -165,7 +165,6 @@
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
<ClInclude Include="..\..\..\server\TracyVector.hpp" />
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp" />
<ClInclude Include="..\..\src\getopt.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -71,9 +71,6 @@
<ClInclude Include="..\..\..\common\TracySystem.hpp">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp">
<Filter>server</Filter>
</ClInclude>

View File

@ -162,9 +162,8 @@
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
<ClInclude Include="..\..\..\server\TracyVector.hpp" />
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -65,9 +65,6 @@
<ClInclude Include="..\..\..\common\TracySystem.hpp">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp">
<Filter>server</Filter>
</ClInclude>
@ -111,4 +108,4 @@
<Filter>server</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

View File

@ -186,8 +186,8 @@
<ClInclude Include="..\..\..\server\TracyViewData.hpp" />
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\TracyYield.hpp" />
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp" />
<ClInclude Include="..\..\..\server\tracy_pdqsort.h" />
<ClInclude Include="..\..\..\server\tracy_robin_hood.h" />
<ClInclude Include="..\..\..\server\tracy_xxh3.h" />
<ClInclude Include="..\..\libs\gl3w\GL\gl3w.h" />
<ClInclude Include="..\..\libs\gl3w\GL\glcorearb.h" />

View File

@ -173,9 +173,6 @@
<ClInclude Include="..\..\..\server\TracyPopcnt.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\common\TracyForceInline.hpp">
<Filter>common</Filter>
</ClInclude>
@ -308,6 +305,9 @@
<ClInclude Include="..\..\..\server\TracySort.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_robin_hood.h">
<Filter>server</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="DebugVis.natvis" />

View File

@ -28,8 +28,8 @@
#include "stb_image.h"
#include "../../common/TracyProtocol.hpp"
#include "../../server/tracy_flat_hash_map.hpp"
#include "../../server/tracy_pdqsort.h"
#include "../../server/tracy_robin_hood.h"
#include "../../server/TracyBadVersion.hpp"
#include "../../server/TracyFileRead.hpp"
#include "../../server/TracyImGui.hpp"
@ -105,7 +105,7 @@ struct ClientData
enum class ViewShutdown { False, True, Join };
static tracy::flat_hash_map<uint32_t, ClientData> clients;
static tracy::unordered_flat_map<uint32_t, ClientData> clients;
static std::unique_ptr<tracy::View> view;
static tracy::BadVersionState badVer;
static int port = 8086;
@ -114,7 +114,7 @@ static char title[128];
static std::thread loadThread;
static std::unique_ptr<tracy::UdpListen> broadcastListen;
static std::mutex resolvLock;
static tracy::flat_hash_map<std::string, std::string> resolvMap;
static tracy::unordered_flat_map<std::string, std::string> resolvMap;
static ResolvService resolv( port );
static ImFont* bigFont;
static ImFont* smallFont;

View File

@ -7,7 +7,6 @@
#define XXH_STATIC_LINKING_ONLY
#include "tracy_xxh3.h"
#include "tracy_flat_hash_map.hpp"
namespace tracy
{
@ -33,11 +32,6 @@ struct Hasher
}
};
struct HasherPOT : public Hasher
{
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct Comparator
{
bool operator()( const char* lhs, const char* rhs ) const
@ -67,11 +61,6 @@ struct StringKey
}
};
struct HasherPOT : public Hasher
{
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct Comparator
{
bool operator()( const StringKey& lhs, const StringKey& rhs ) const

View File

@ -10,7 +10,7 @@
#include "TracyCharUtil.hpp"
#include "TracyShortPtr.hpp"
#include "TracyVector.hpp"
#include "tracy_flat_hash_map.hpp"
#include "tracy_robin_hood.h"
#include "../common/TracyForceInline.hpp"
namespace tracy
@ -323,11 +323,13 @@ enum { CallstackFrameIdSize = sizeof( CallstackFrameId ) };
struct CallstackFrameTree
{
CallstackFrameTree( CallstackFrameId id ) : frame( id ) {}
CallstackFrameId frame;
uint64_t alloc;
uint32_t count;
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> children;
flat_hash_set<uint32_t, nohash<uint32_t>> callstacks;
unordered_flat_map<uint64_t, CallstackFrameTree> children;
unordered_flat_set<uint32_t> callstacks;
};
enum { CallstackFrameTreeSize = sizeof( CallstackFrameTree ) };
@ -464,7 +466,7 @@ struct GpuCtxData
uint64_t count;
uint8_t accuracyBits;
float period;
flat_hash_map<uint64_t, GpuCtxThreadData, nohash<uint64_t>> threadData;
unordered_flat_map<uint64_t, GpuCtxThreadData> threadData;
short_ptr<GpuEvent> query[64*1024];
};
@ -480,7 +482,7 @@ struct LockMap
int16_t srcloc;
Vector<LockEventPtr> timeline;
flat_hash_map<uint64_t, uint8_t, nohash<uint64_t>> threadMap;
unordered_flat_map<uint64_t, uint8_t> threadMap;
std::vector<uint64_t> threadList;
LockType type;
int64_t timeAnnounce;
@ -530,7 +532,7 @@ struct MemData
{
Vector<MemEvent> data;
Vector<uint32_t> frees;
flat_hash_map<uint64_t, size_t, nohash<uint64_t>> active;
unordered_flat_map<uint64_t, size_t> active;
uint64_t high = std::numeric_limits<uint64_t>::min();
uint64_t low = std::numeric_limits<uint64_t>::max();
uint64_t usage = 0;
@ -561,7 +563,6 @@ struct SourceLocationHasher
{
return charutil::hash( (const char*)ptr, sizeof( SourceLocationBase ) );
}
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct SourceLocationComparator

View File

@ -2,7 +2,7 @@
#define __TRACYSTRINGDISCOVERY_HPP__
#include "../common/TracyForceInline.hpp"
#include "tracy_flat_hash_map.hpp"
#include "tracy_robin_hood.h"
#include "TracyCharUtil.hpp"
#include "TracyVector.hpp"
@ -69,9 +69,9 @@ public:
private:
Vector<T> m_data;
flat_hash_map<uint64_t, T, nohash<uint64_t>> m_pending;
flat_hash_map<uint64_t, T, nohash<uint64_t>> m_map;
flat_hash_map<const char*, T, charutil::HasherPOT, charutil::Comparator> m_rev;
unordered_flat_map<uint64_t, T> m_pending;
unordered_flat_map<uint64_t, T> m_map;
unordered_flat_map<const char*, T, charutil::Hasher, charutil::Comparator> m_rev;
};
}

View File

@ -5,7 +5,7 @@
#include <stdint.h>
#include "../common/TracyForceInline.hpp"
#include "tracy_flat_hash_map.hpp"
#include "tracy_robin_hood.h"
#include "TracyVector.hpp"
namespace tracy
@ -51,7 +51,7 @@ private:
uint16_t CompressThreadReal( uint64_t thread );
uint16_t CompressThreadNew( uint64_t thread );
flat_hash_map<uint64_t, uint16_t, nohash<uint64_t>> m_threadMap;
unordered_flat_map<uint64_t, uint16_t> m_threadMap;
Vector<uint64_t> m_threadExpand;
std::pair<uint64_t, uint16_t> m_threadLast;
};

View File

@ -5,7 +5,6 @@
#include <string.h>
#include "../common/TracyForceInline.hpp"
#include "tracy_flat_hash_map.hpp"
#include "TracyCharUtil.hpp"
#include "TracyEvent.hpp"
#include "TracyMemory.hpp"
@ -97,12 +96,6 @@ struct VarArrayHasher
}
};
template<typename T>
struct VarArrayHasherPOT : public VarArrayHasher<T>
{
typedef tracy::power_of_two_hash_policy hash_policy;
};
template<typename T>
struct VarArrayComparator
{

View File

@ -5607,7 +5607,7 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, B
ImGui::TreePop();
}
void View::CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
void View::CalcZoneTimeData( unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone )
{
assert( zone.HasChildren() );
const auto& children = m_worker.GetZoneChildren( zone.Child() );
@ -5622,7 +5622,7 @@ void View::CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_
}
template<typename Adapter, typename V>
void View::CalcZoneTimeDataImpl( const V& children, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
void View::CalcZoneTimeDataImpl( const V& children, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone )
{
Adapter a;
if( m_timeDist.exclusiveTime )
@ -5651,7 +5651,7 @@ void View::CalcZoneTimeDataImpl( const V& children, flat_hash_map<int16_t, ZoneT
}
}
void View::CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
void View::CalcZoneTimeData( const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone )
{
assert( zone.HasChildren() );
const auto& children = m_worker.GetZoneChildren( zone.Child() );
@ -5666,7 +5666,7 @@ void View::CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map<int16_t, Zo
}
template<typename Adapter, typename V>
void View::CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
void View::CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone )
{
Adapter a;
if( m_timeDist.exclusiveTime )
@ -6388,7 +6388,7 @@ void View::DrawZoneInfoWindow()
}
if( !m_timeDist.data.empty() )
{
std::vector<flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::const_iterator> vec;
std::vector<unordered_flat_map<int16_t, ZoneTimeData>::const_iterator> vec;
vec.reserve( m_timeDist.data.size() );
for( auto it = m_timeDist.data.cbegin(); it != m_timeDist.data.cend(); ++it ) vec.emplace_back( it );
static bool widthSet = false;
@ -6478,7 +6478,7 @@ void View::DrawZoneInfoChildren( const V& children, int64_t ztime )
Vector<uint32_t> v;
};
uint64_t ctime = 0;
flat_hash_map<int16_t, ChildGroup, nohash<int16_t>> cmap;
unordered_flat_map<int16_t, ChildGroup> cmap;
cmap.reserve( 128 );
for( size_t i=0; i<children.size(); i++ )
{
@ -6921,7 +6921,7 @@ void View::DrawGpuInfoChildren( const V& children, int64_t ztime )
Vector<uint32_t> v;
};
uint64_t ctime = 0;
flat_hash_map<int16_t, ChildGroup, nohash<int16_t>> cmap;
unordered_flat_map<int16_t, ChildGroup> cmap;
cmap.reserve( 128 );
for( size_t i=0; i<children.size(); i++ )
{
@ -12235,7 +12235,7 @@ void View::DrawCpuDataWindow()
};
const auto& ctd = m_worker.GetCpuThreadData();
flat_hash_map<uint64_t, PidData, nohash<uint64_t>> pids;
unordered_flat_map<uint64_t, PidData> pids;
for( auto& v : ctd )
{
uint64_t pid = m_worker.GetPidFromTid( v.first );
@ -12270,7 +12270,7 @@ void View::DrawCpuDataWindow()
ImGui::NextColumn();
ImGui::Separator();
std::vector<flat_hash_map<uint64_t, PidData, nohash<uint64_t>>::iterator> psort;
std::vector<unordered_flat_map<uint64_t, PidData>::iterator> psort;
psort.reserve( pids.size() );
for( auto it = pids.begin(); it != pids.end(); ++it ) psort.emplace_back( it );
switch( m_cpuDataSort )
@ -12763,17 +12763,17 @@ void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const
ImGui::EndChild();
}
static tracy_force_inline CallstackFrameTree* GetFrameTreeItemNoGroup( flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>>& tree, CallstackFrameId idx, const Worker& worker )
static tracy_force_inline CallstackFrameTree* GetFrameTreeItemNoGroup( unordered_flat_map<uint64_t, CallstackFrameTree>& tree, CallstackFrameId idx, const Worker& worker )
{
auto it = tree.find( idx.data );
if( it == tree.end() )
{
it = tree.emplace( idx.data, CallstackFrameTree { idx } ).first;
it = tree.emplace( idx.data, CallstackFrameTree( idx ) ).first;
}
return &it->second;
}
static tracy_force_inline CallstackFrameTree* GetFrameTreeItemGroup( flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>>& tree, CallstackFrameId idx, const Worker& worker )
static tracy_force_inline CallstackFrameTree* GetFrameTreeItemGroup( unordered_flat_map<uint64_t, CallstackFrameTree>& tree, CallstackFrameId idx, const Worker& worker )
{
auto frameDataPtr = worker.GetCallstackFrame( idx );
if( !frameDataPtr ) return nullptr;
@ -12785,14 +12785,14 @@ static tracy_force_inline CallstackFrameTree* GetFrameTreeItemGroup( flat_hash_m
auto it = tree.find( fidx );
if( it == tree.end() )
{
it = tree.emplace( fidx, CallstackFrameTree { idx } ).first;
it = tree.emplace( fidx, CallstackFrameTree( idx ) ).first;
}
return &it->second;
}
flat_hash_map<uint32_t, View::PathData, nohash<uint32_t>> View::GetCallstackPaths( const MemData& mem, bool onlyActive ) const
unordered_flat_map<uint32_t, View::PathData> View::GetCallstackPaths( const MemData& mem, bool onlyActive ) const
{
flat_hash_map<uint32_t, PathData, nohash<uint32_t>> pathSum;
unordered_flat_map<uint32_t, PathData> pathSum;
pathSum.reserve( m_worker.GetCallstackPayloadCount() );
const auto zvMid = m_vd.zvStart + ( m_vd.zvEnd - m_vd.zvStart ) / 2;
@ -12839,9 +12839,9 @@ flat_hash_map<uint32_t, View::PathData, nohash<uint32_t>> View::GetCallstackPath
return pathSum;
}
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> View::GetCallstackFrameTreeBottomUp( const MemData& mem ) const
unordered_flat_map<uint64_t, CallstackFrameTree> View::GetCallstackFrameTreeBottomUp( const MemData& mem ) const
{
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> root;
unordered_flat_map<uint64_t, CallstackFrameTree> root;
auto pathSum = GetCallstackPaths( mem, m_activeOnlyBottomUp );
if( m_groupCallstackTreeByNameBottomUp )
{
@ -12892,9 +12892,9 @@ flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> View::GetCallstack
return root;
}
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> View::GetCallstackFrameTreeTopDown( const MemData& mem ) const
unordered_flat_map<uint64_t, CallstackFrameTree> View::GetCallstackFrameTreeTopDown( const MemData& mem ) const
{
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> root;
unordered_flat_map<uint64_t, CallstackFrameTree> root;
auto pathSum = GetCallstackPaths( mem, m_activeOnlyTopDown );
if( m_groupCallstackTreeByNameTopDown )
{
@ -12993,7 +12993,7 @@ struct MemoryPage
int8_t data[PageSize];
};
static tracy_force_inline MemoryPage& GetPage( flat_hash_map<uint64_t, MemoryPage, nohash<uint64_t>>& memmap, uint64_t page )
static tracy_force_inline MemoryPage& GetPage( unordered_flat_map<uint64_t, MemoryPage>& memmap, uint64_t page )
{
auto it = memmap.find( page );
if( it == memmap.end() )
@ -13003,7 +13003,7 @@ static tracy_force_inline MemoryPage& GetPage( flat_hash_map<uint64_t, MemoryPag
return it->second;
}
static tracy_force_inline void FillPages( flat_hash_map<uint64_t, MemoryPage, nohash<uint64_t>>& memmap, uint64_t c0, uint64_t c1, int8_t val )
static tracy_force_inline void FillPages( unordered_flat_map<uint64_t, MemoryPage>& memmap, uint64_t c0, uint64_t c1, int8_t val )
{
auto p0 = c0 >> PageBits;
const auto p1 = c1 >> PageBits;
@ -13047,7 +13047,7 @@ std::vector<MemoryPage> View::GetMemoryPages() const
{
std::vector<MemoryPage> ret;
static flat_hash_map<uint64_t, MemoryPage, nohash<uint64_t>> memmap;
static unordered_flat_map<uint64_t, MemoryPage> memmap;
const auto& mem = m_worker.GetMemData();
const auto memlow = mem.low;
@ -13092,7 +13092,7 @@ std::vector<MemoryPage> View::GetMemoryPages() const
}
}
std::vector<flat_hash_map<uint64_t, MemoryPage, nohash<uint64_t>>::const_iterator> itmap;
std::vector<unordered_flat_map<uint64_t, MemoryPage>::const_iterator> itmap;
itmap.reserve( memmap.size() );
ret.reserve( memmap.size() );
for( auto it = memmap.begin(); it != memmap.end(); ++it ) itmap.emplace_back( it );
@ -13407,11 +13407,11 @@ void View::DrawMemory()
ImGui::End();
}
void View::DrawFrameTreeLevel( const flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>>& tree, int& idx )
void View::DrawFrameTreeLevel( const unordered_flat_map<uint64_t, CallstackFrameTree>& tree, int& idx )
{
auto& io = ImGui::GetIO();
std::vector<flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>>::const_iterator> sorted;
std::vector<unordered_flat_map<uint64_t, CallstackFrameTree>::const_iterator> sorted;
sorted.reserve( tree.size() );
for( auto it = tree.begin(); it != tree.end(); ++it )
{

View File

@ -17,7 +17,7 @@
#include "TracyVector.hpp"
#include "TracyViewData.hpp"
#include "TracyWorker.hpp"
#include "tracy_flat_hash_map.hpp"
#include "tracy_robin_hood.h"
struct ImVec2;
struct ImFont;
@ -156,10 +156,10 @@ private:
template<class T>
void ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id = nullptr, int64_t startTime = -1 );
flat_hash_map<uint32_t, PathData, nohash<uint32_t>> GetCallstackPaths( const MemData& mem, bool onlyActive ) const;
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>> GetCallstackFrameTreeTopDown( const MemData& mem ) const;
void DrawFrameTreeLevel( const flat_hash_map<uint64_t, CallstackFrameTree, nohash<uint64_t>>& tree, int& idx );
unordered_flat_map<uint32_t, PathData> GetCallstackPaths( const MemData& mem, bool onlyActive ) const;
unordered_flat_map<uint64_t, CallstackFrameTree> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
unordered_flat_map<uint64_t, CallstackFrameTree> GetCallstackFrameTreeTopDown( const MemData& mem ) const;
void DrawFrameTreeLevel( const unordered_flat_map<uint64_t, CallstackFrameTree>& tree, int& idx );
void DrawZoneList( const Vector<short_ptr<ZoneEvent>>& zones );
void DrawInfoWindow();
@ -231,19 +231,19 @@ private:
int64_t GetZoneSelfTime( const GpuEvent& zone );
bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt );
tracy_force_inline void CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone );
tracy_force_inline void CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone );
tracy_force_inline void CalcZoneTimeData( unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone );
tracy_force_inline void CalcZoneTimeData( const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone );
template<typename Adapter, typename V>
void CalcZoneTimeDataImpl( const V& children, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone );
void CalcZoneTimeDataImpl( const V& children, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone );
template<typename Adapter, typename V>
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone );
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, unordered_flat_map<int16_t, ZoneTimeData>::iterator zit, const ZoneEvent& zone );
void SetPlaybackFrame( uint32_t idx );
flat_hash_map<const void*, VisData, nohash<const void*>> m_visData;
flat_hash_map<uint64_t, bool, nohash<uint64_t>> m_visibleMsgThread;
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;
flat_hash_map<const PlotData*, PlotView, nohash<const PlotData*>> m_plotView;
unordered_flat_map<const void*, VisData> m_visData;
unordered_flat_map<uint64_t, bool> m_visibleMsgThread;
unordered_flat_map<const void*, int> m_gpuDrift;
unordered_flat_map<const PlotData*, PlotView> m_plotView;
Vector<const ThreadData*> m_threadOrder;
Vector<float> m_threadDnd;
@ -415,7 +415,7 @@ private:
bool show = false;
bool ignoreCase = false;
std::vector<int16_t> match;
flat_hash_map<uint64_t, Group, nohash<uint64_t>> groups;
unordered_flat_map<uint64_t, Group> groups;
size_t processed;
uint16_t groupId;
int selMatch = 0;
@ -626,7 +626,7 @@ private:
SortBy sortBy = SortBy::Time;
bool runningTime = false;
bool exclusiveTime = true;
flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>> data;
unordered_flat_map<int16_t, ZoneTimeData> data;
const ZoneEvent* dataValidFor = nullptr;
float fztime;
} m_timeDist;

View File

@ -23,8 +23,6 @@
#include "TracyWorker.hpp"
#include "TracyYield.hpp"
#include "tracy_flat_hash_map.hpp"
namespace tracy
{
@ -465,7 +463,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
uint32_t packageId;
uint64_t psz;
f.Read2( packageId, psz );
auto& package = *m_data.cpuTopology.emplace( packageId, flat_hash_map<uint32_t, std::vector<uint32_t>> {} ).first;
auto& package = *m_data.cpuTopology.emplace( packageId, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
package.second.reserve( psz );
for( uint64_t j=0; j<psz; j++ )
{
@ -556,7 +554,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
}
}
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> pointerMap;
unordered_flat_map<uint64_t, const char*> pointerMap;
f.Read( sz );
m_data.stringData.reserve_exact( sz, m_slab );
@ -850,7 +848,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
s_loadProgress.subTotal.store( 0, std::memory_order_relaxed );
s_loadProgress.progress.store( LoadProgress::Messages, std::memory_order_relaxed );
flat_hash_map<uint64_t, MessageData*, nohash<uint64_t>> msgMap;
unordered_flat_map<uint64_t, MessageData*> msgMap;
f.Read( sz );
if( eventMask & EventType::Messages )
{
@ -4769,7 +4767,7 @@ void Worker::ProcessParamSetup( const QueueParamSetup& ev )
void Worker::ProcessCpuTopology( const QueueCpuTopology& ev )
{
auto package = m_data.cpuTopology.find( ev.package );
if( package == m_data.cpuTopology.end() ) package = m_data.cpuTopology.emplace( ev.package, flat_hash_map<uint32_t, std::vector<uint32_t>> {} ).first;
if( package == m_data.cpuTopology.end() ) package = m_data.cpuTopology.emplace( ev.package, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
auto core = package->second.find( ev.core );
if( core == package->second.end() ) core = package->second.emplace( ev.core, std::vector<uint32_t> {} ).first;
core->second.emplace_back( ev.thread );
@ -5699,7 +5697,7 @@ void Worker::Write( FileWrite& f )
}
// Only save context switches relevant to active threads.
std::vector<flat_hash_map<uint64_t, ContextSwitch*, nohash<uint64_t>>::const_iterator> ctxValid;
std::vector<unordered_flat_map<uint64_t, ContextSwitch*>::const_iterator> ctxValid;
ctxValid.reserve( m_data.ctxSwitch.size() );
for( auto it = m_data.ctxSwitch.begin(); it != m_data.ctxSwitch.end(); ++it )
{

View File

@ -16,7 +16,7 @@
#include "../common/TracyQueue.hpp"
#include "../common/TracyProtocol.hpp"
#include "../common/TracySocket.hpp"
#include "tracy_flat_hash_map.hpp"
#include "tracy_robin_hood.h"
#include "TracyEvent.hpp"
#include "TracyShortPtr.hpp"
#include "TracySlab.hpp"
@ -137,7 +137,6 @@ private:
struct CallstackFrameIdHash
{
size_t operator()( const CallstackFrameId& id ) const { return id.data; }
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct CallstackFrameIdCompare
@ -159,7 +158,6 @@ private:
}
return hash;
}
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct RevFrameComp
@ -192,29 +190,29 @@ private:
int64_t lastTime = 0;
uint64_t frameOffset = 0;
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> strings;
unordered_flat_map<uint64_t, const char*> strings;
Vector<const char*> stringData;
flat_hash_map<charutil::StringKey, uint32_t, charutil::StringKey::HasherPOT, charutil::StringKey::Comparator> stringMap;
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> threadNames;
flat_hash_map<uint64_t, std::pair<const char*, const char*>, nohash<uint64_t>> externalNames;
unordered_flat_map<charutil::StringKey, uint32_t, charutil::StringKey::Hasher, charutil::StringKey::Comparator> stringMap;
unordered_flat_map<uint64_t, const char*> threadNames;
unordered_flat_map<uint64_t, std::pair<const char*, const char*>> externalNames;
flat_hash_map<uint64_t, SourceLocation, nohash<uint64_t>> sourceLocation;
unordered_flat_map<uint64_t, SourceLocation> sourceLocation;
Vector<short_ptr<SourceLocation>> sourceLocationPayload;
flat_hash_map<const SourceLocation*, int16_t, SourceLocationHasher, SourceLocationComparator> sourceLocationPayloadMap;
unordered_flat_map<const SourceLocation*, int16_t, SourceLocationHasher, SourceLocationComparator> sourceLocationPayloadMap;
Vector<uint64_t> sourceLocationExpand;
#ifndef TRACY_NO_STATISTICS
flat_hash_map<int16_t, SourceLocationZones, nohash<int16_t>> sourceLocationZones;
unordered_flat_map<int16_t, SourceLocationZones> sourceLocationZones;
bool sourceLocationZonesReady;
#else
flat_hash_map<int16_t, uint64_t> sourceLocationZonesCnt;
unordered_flat_map<int16_t, uint64_t> sourceLocationZonesCnt;
#endif
flat_hash_map<VarArray<CallstackFrameId>*, uint32_t, VarArrayHasherPOT<CallstackFrameId>, VarArrayComparator<CallstackFrameId>> callstackMap;
unordered_flat_map<VarArray<CallstackFrameId>*, uint32_t, VarArrayHasher<CallstackFrameId>, VarArrayComparator<CallstackFrameId>> callstackMap;
Vector<short_ptr<VarArray<CallstackFrameId>>> callstackPayload;
flat_hash_map<CallstackFrameId, CallstackFrameData*, CallstackFrameIdHash, CallstackFrameIdCompare> callstackFrameMap;
flat_hash_map<CallstackFrameData*, CallstackFrameId, RevFrameHash, RevFrameComp> revFrameMap;
unordered_flat_map<CallstackFrameId, CallstackFrameData*, CallstackFrameIdHash, CallstackFrameIdCompare> callstackFrameMap;
unordered_flat_map<CallstackFrameData*, CallstackFrameId, RevFrameHash, RevFrameComp> revFrameMap;
flat_hash_map<uint32_t, LockMap*, nohash<uint32_t>> lockMap;
unordered_flat_map<uint32_t, LockMap*> lockMap;
ThreadCompress localThreadCompress;
ThreadCompress externalThreadCompress;
@ -229,12 +227,12 @@ private:
CrashEvent crashEvent;
flat_hash_map<uint64_t, ContextSwitch*, nohash<uint64_t>> ctxSwitch;
unordered_flat_map<uint64_t, ContextSwitch*> ctxSwitch;
CpuData cpuData[256];
int cpuDataCount = 0;
flat_hash_map<uint64_t, uint64_t, nohash<uint64_t>> tidToPid;
flat_hash_map<uint64_t, CpuThreadData, nohash<uint64_t>> cpuThreadData;
unordered_flat_map<uint64_t, uint64_t> tidToPid;
unordered_flat_map<uint64_t, CpuThreadData> cpuThreadData;
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 );
@ -251,8 +249,8 @@ private:
bool ctxUsageReady = false;
#endif
flat_hash_map<uint32_t, flat_hash_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
flat_hash_map<uint32_t, CpuThreadTopology, nohash<uint32_t>> cpuTopologyMap;
unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
unordered_flat_map<uint32_t, CpuThreadTopology> cpuTopologyMap;
};
struct MbpsBlock
@ -353,7 +351,7 @@ public:
const CpuData* GetCpuData() const { return m_data.cpuData; }
int GetCpuDataCpuCount() const { return m_data.cpuDataCount; }
uint64_t GetPidFromTid( uint64_t tid ) const;
const flat_hash_map<uint64_t, CpuThreadData, nohash<uint64_t>>& GetCpuThreadData() const { return m_data.cpuThreadData; }
const unordered_flat_map<uint64_t, CpuThreadData>& GetCpuThreadData() const { return m_data.cpuThreadData; }
void GetCpuUsageAtTime( int64_t time, int& own, int& other ) const;
int64_t GetFrameTime( const FrameData& fd, size_t idx ) const;
@ -362,7 +360,7 @@ public:
const FrameImage* GetFrameImage( const FrameData& fd, size_t idx ) const;
std::pair<int, int> GetFrameRange( const FrameData& fd, int64_t from, int64_t to );
const flat_hash_map<uint32_t, LockMap*, nohash<uint32_t>>& GetLockMap() const { return m_data.lockMap; }
const unordered_flat_map<uint32_t, LockMap*>& GetLockMap() const { return m_data.lockMap; }
const Vector<short_ptr<MessageData>>& GetMessages() const { return m_data.messages; }
const Vector<GpuCtxData*>& GetGpuData() const { return m_data.gpuData; }
const Vector<PlotData*>& GetPlots() const { return m_data.plots.Data(); }
@ -411,7 +409,7 @@ public:
#ifndef TRACY_NO_STATISTICS
const SourceLocationZones& GetZonesForSourceLocation( int16_t srcloc ) const;
const flat_hash_map<int16_t, SourceLocationZones, nohash<int16_t>>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
const unordered_flat_map<int16_t, SourceLocationZones>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
bool AreSourceLocationZonesReady() const { return m_data.sourceLocationZonesReady; }
bool IsCpuUsageReady() const { return m_data.ctxUsageReady; }
#endif
@ -673,15 +671,15 @@ private:
bool m_ignoreMemFreeFaults;
short_ptr<GpuCtxData> m_gpuCtxMap[256];
flat_hash_map<uint64_t, StringLocation, nohash<uint64_t>> m_pendingCustomStrings;
unordered_flat_map<uint64_t, StringLocation> m_pendingCustomStrings;
uint64_t m_pendingCallstackPtr = 0;
uint32_t m_pendingCallstackId;
flat_hash_map<uint64_t, int16_t, nohash<uint64_t>> m_pendingSourceLocationPayload;
unordered_flat_map<uint64_t, int16_t> m_pendingSourceLocationPayload;
Vector<uint64_t> m_sourceLocationQueue;
flat_hash_map<uint64_t, int16_t, nohash<uint64_t>> m_sourceLocationShrink;
flat_hash_map<uint64_t, ThreadData*, nohash<uint64_t>> m_threadMap;
flat_hash_map<uint64_t, NextCallstack, nohash<uint64_t>> m_nextCallstack;
flat_hash_map<uint64_t, FrameImagePending, nohash<uint64_t>> m_pendingFrameImageData;
unordered_flat_map<uint64_t, int16_t> m_sourceLocationShrink;
unordered_flat_map<uint64_t, ThreadData*> m_threadMap;
unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack;
unordered_flat_map<uint64_t, FrameImagePending> m_pendingFrameImageData;
uint32_t m_pendingStrings;
uint32_t m_pendingThreads;
@ -716,7 +714,7 @@ private:
Vector<ServerQueryPacket> m_serverQueryQueue;
size_t m_serverQuerySpaceLeft;
flat_hash_map<uint64_t, int32_t> m_frameImageStaging;
unordered_flat_map<uint64_t, int32_t> m_frameImageStaging;
char* m_frameImageBuffer = nullptr;
size_t m_frameImageBufferSize = 0;
char* m_frameImageCompressedBuffer = nullptr;

File diff suppressed because it is too large Load Diff

2194
server/tracy_robin_hood.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -162,7 +162,6 @@
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
<ClInclude Include="..\..\..\server\TracyVector.hpp" />
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -65,9 +65,6 @@
<ClInclude Include="..\..\..\common\TracySystem.hpp">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp">
<Filter>server</Filter>
</ClInclude>