From fd689592237190020f44e69a9f32f5f0a972eae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Sun, 24 May 2026 15:04:31 +0200 Subject: [PATCH] Rename InitRpmalloc to InitAllocator. The function is about to dispatch between rpmalloc and a pluggable allocator hook, so the rpmalloc-specific name no longer fits. Pure rename plus a small consequence: the SymbolWorker call site no longer needs the TRACY_USE_RPMALLOC guard, since the no-op static-inline fallback in TracyAlloc.hpp makes InitAllocator() safe to call unconditionally. --- public/client/TracyAlloc.cpp | 6 +++--- public/client/TracyCallstack.cpp | 8 ++++---- public/client/TracyProfiler.cpp | 10 ++++------ public/client/TracySysTrace.cpp | 2 +- public/client/apple/TracyMach.cpp | 2 +- public/common/TracyAlloc.hpp | 10 +++++----- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/public/client/TracyAlloc.cpp b/public/client/TracyAlloc.cpp index c675b6d3..d85cf02b 100644 --- a/public/client/TracyAlloc.cpp +++ b/public/client/TracyAlloc.cpp @@ -14,7 +14,7 @@ extern thread_local bool RpThreadInitDone; extern std::atomic RpInitDone; extern std::atomic RpInitLock; -tracy_no_inline static void InitRpmallocPlumbing() +tracy_no_inline static void InitAllocatorPlumbing() { const auto done = RpInitDone.load( std::memory_order_acquire ); if( !done ) @@ -33,9 +33,9 @@ tracy_no_inline static void InitRpmallocPlumbing() RpThreadInitDone = true; } -TRACY_API void InitRpmalloc() +TRACY_API void InitAllocator() { - if( !RpThreadInitDone ) InitRpmallocPlumbing(); + if( !RpThreadInitDone ) InitAllocatorPlumbing(); } } diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index e9f35490..9095d847 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -918,7 +918,7 @@ ModuleNameAndBaseAddress GetModuleNameAndPrepareSymbols( uint64_t addr ) constexpr DWORD flag = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; HMODULE mod = NULL; - InitRpmalloc(); + InitAllocator(); if( GetModuleHandleExA( flag, (char*)addr, &mod ) != 0 ) { MODULEINFO info; @@ -997,7 +997,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) DBGHELP_LOCK; #endif - InitRpmalloc(); + InitAllocator(); const ModuleNameAndBaseAddress moduleNameAndAddress = GetModuleNameAndPrepareSymbols( ptr ); @@ -1314,7 +1314,7 @@ void InitCallstackCritical() void InitCallstack() { - InitRpmalloc(); + InitAllocator(); #ifdef TRACY_HAS_DL_ITERATE_PHDR_TO_REFRESH_IMAGE_CACHE CreateImageCaches(); @@ -1780,7 +1780,7 @@ CallstackEntryData DecodeCallstackPtrExternal( uint64_t ptr ) CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) { - InitRpmalloc(); + InitAllocator(); if( !IsKernelAddress( ptr ) ) { #ifdef __linux__ diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 0d25f3e8..9eed5970 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -2371,7 +2371,7 @@ static void FreeAssociatedMemory( const QueueItem& item ) #ifdef TRACY_HAS_CALLSTACK case QueueType::CallstackFrameSize: { - InitRpmalloc(); + InitAllocator(); auto size = MemRead( &item.callstackFrameSizeFat.size ); auto data = (const CallstackEntry*)MemRead( &item.callstackFrameSizeFat.data ); for( uint8_t i=0; i 0 ); int64_t refThread = m_refTimeThread; int64_t refCtx = m_refTimeCtx; @@ -2944,7 +2944,7 @@ Profiler::DequeueStatus Profiler::DequeueSerial() { dequeueStatus = DequeueStatus::DataDequeued; - InitRpmalloc(); + InitAllocator(); int64_t refSerial = m_refTimeSerial; int64_t refGpu = m_refTimeGpu; #ifdef TRACY_FIBERS @@ -3758,9 +3758,7 @@ void Profiler::SymbolWorker() ThreadExitHandler threadExitHandler; SetThreadName( "Tracy Symbol Worker" ); -#ifdef TRACY_USE_RPMALLOC - InitRpmalloc(); -#endif + InitAllocator(); InitCallstack(); while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index e106e3b1..fef4830b 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -1109,7 +1109,7 @@ void SysTraceWorker( void* ptr ) { ThreadExitHandler threadExitHandler; SetThreadName( "Tracy Sampling" ); - InitRpmalloc(); + InitAllocator(); sched_param sp = { 99 }; if( pthread_setschedparam( pthread_self(), SCHED_FIFO, &sp ) != 0 ) TracyDebug( "Failed to increase SysTraceWorker thread priority!" ); auto ctxBufferIdx = s_ctxBufferIdx; diff --git a/public/client/apple/TracyMach.cpp b/public/client/apple/TracyMach.cpp index 018c3ee5..e1024610 100644 --- a/public/client/apple/TracyMach.cpp +++ b/public/client/apple/TracyMach.cpp @@ -197,7 +197,7 @@ void SysTraceWorker( void* ) { ThreadExitHandler threadExitHandler; SetThreadName( "Tracy Mach Watchdog" ); - InitRpmalloc(); + InitAllocator(); SysTraceWatch(); } diff --git a/public/common/TracyAlloc.hpp b/public/common/TracyAlloc.hpp index ddb0e5df..6e6498f2 100644 --- a/public/common/TracyAlloc.hpp +++ b/public/common/TracyAlloc.hpp @@ -14,15 +14,15 @@ namespace tracy { #ifdef TRACY_USE_RPMALLOC -TRACY_API void InitRpmalloc(); +TRACY_API void InitAllocator(); #else -static inline void InitRpmalloc() {} +static inline void InitAllocator() {} #endif static inline void* tracy_malloc( size_t size ) { #ifdef TRACY_USE_RPMALLOC - InitRpmalloc(); + InitAllocator(); return rpmalloc( size ); #else return malloc( size ); @@ -41,7 +41,7 @@ static inline void* tracy_malloc_fast( size_t size ) static inline void tracy_free( void* ptr ) { #ifdef TRACY_USE_RPMALLOC - InitRpmalloc(); + InitAllocator(); rpfree( ptr ); #else free( ptr ); @@ -60,7 +60,7 @@ static inline void tracy_free_fast( void* ptr ) static inline void* tracy_realloc( void* ptr, size_t size ) { #ifdef TRACY_USE_RPMALLOC - InitRpmalloc(); + InitAllocator(); return rprealloc( ptr, size ); #else return realloc( ptr, size );