mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Use 32 bits to store lock id.
This makes queue item size 32 bytes. Queue operations can now be faster, because multiplication by 33 is replaced by shift by 5.
This commit is contained in:
parent
ec789d60e8
commit
1aaab3c5e4
@ -2,6 +2,7 @@
|
||||
#define __TRACYLOCK_HPP__
|
||||
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "TracyProfiler.hpp"
|
||||
@ -9,7 +10,7 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
static std::atomic<uint64_t> s_lockCounter( 0 );
|
||||
static std::atomic<uint32_t> s_lockCounter( 0 );
|
||||
|
||||
template<class T>
|
||||
class Lockable
|
||||
@ -19,6 +20,7 @@ public:
|
||||
: m_id( s_lockCounter.fetch_add( 1, std::memory_order_relaxed ) )
|
||||
, m_lckloc( (uint64_t)srcloc )
|
||||
{
|
||||
assert( m_id != std::numeric_limits<uint32_t>::max() );
|
||||
}
|
||||
|
||||
Lockable( const Lockable& ) = delete;
|
||||
@ -106,7 +108,7 @@ public:
|
||||
|
||||
private:
|
||||
T m_lockable;
|
||||
uint64_t m_id;
|
||||
uint32_t m_id;
|
||||
uint64_t m_lckloc;
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,7 @@ struct QueueZoneName
|
||||
|
||||
struct QueueLockWait
|
||||
{
|
||||
uint64_t id;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
uint64_t lckloc; // ptr
|
||||
@ -86,21 +86,21 @@ struct QueueLockWait
|
||||
|
||||
struct QueueLockObtain
|
||||
{
|
||||
uint64_t id;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockRelease
|
||||
{
|
||||
uint64_t id;
|
||||
uint32_t id;
|
||||
int64_t time;
|
||||
uint64_t thread;
|
||||
};
|
||||
|
||||
struct QueueLockMark
|
||||
{
|
||||
uint64_t id;
|
||||
uint32_t id;
|
||||
uint64_t thread;
|
||||
uint64_t srcloc; // ptr
|
||||
};
|
||||
@ -176,6 +176,7 @@ static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name
|
||||
};
|
||||
|
||||
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );
|
||||
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
|
||||
static_assert( sizeof( void* ) <= sizeof( uint64_t ), "Pointer size > 8 bytes" );
|
||||
|
||||
|
@ -172,7 +172,7 @@ private:
|
||||
std::unordered_map<uint64_t, std::string> m_threadNames;
|
||||
std::unordered_set<const char*, charutil::Hasher, charutil::Comparator> m_customStrings;
|
||||
std::unordered_map<uint64_t, QueueSourceLocation> m_sourceLocation;
|
||||
std::unordered_map<uint64_t, LockMap> m_lockMap;
|
||||
std::unordered_map<uint32_t, LockMap> m_lockMap;
|
||||
uint64_t m_zonesCnt;
|
||||
|
||||
std::mutex m_mbpslock;
|
||||
|
Loading…
Reference in New Issue
Block a user