From 7f7bd691952e6d7fb2867ffcda5960207297b1de Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 18 Aug 2026 00:00:32 +0200 Subject: [PATCH] Remove TRACY_DELAYED_INIT option. Delayed init was introduced 2019-02-19 in ef5e30056 and was lazy init at that time, matching the name. This changed 2020-05-19 in 4eb78f5c8, when auto-init was added, making delayed init not delayed anymore. While the option is still needed to make manual lifetime work, and it has to be enabled on apple, there's no reason anymore to expose it to users. --- .github/actions/test-tracy/action.yml | 4 ++-- CMakeLists.txt | 4 ---- manual/tracy.md | 11 ++++------- manual/tracy.tex | 9 +++------ meson.build | 4 ---- meson.options | 1 - monitor/CMakeLists.txt | 1 - public/client/TracyMangle.hpp | 11 +++++++++++ public/client/TracyProfiler.cpp | 10 +--------- 9 files changed, 21 insertions(+), 34 deletions(-) diff --git a/.github/actions/test-tracy/action.yml b/.github/actions/test-tracy/action.yml index 7f73f142..a2c662ee 100644 --- a/.github/actions/test-tracy/action.yml +++ b/.github/actions/test-tracy/action.yml @@ -24,8 +24,8 @@ runs: cmake --build tests/tracy/build --parallel cmake -E rm -rf tests/tracy/build - # same with TRACY_DELAYED_INIT and TRACY_MANUAL_LIFETIME - cmake -B tests/tracy/build -S tests/tracy -DCMAKE_BUILD_TYPE=Release -DTRACY_DELAYED_INIT=ON -DTRACY_MANUAL_LIFETIME=ON ${{ inputs.extra_cmake_flags }} + # same with TRACY_MANUAL_LIFETIME + cmake -B tests/tracy/build -S tests/tracy -DCMAKE_BUILD_TYPE=Release -DTRACY_MANUAL_LIFETIME=ON ${{ inputs.extra_cmake_flags }} cmake --build tests/tracy/build --parallel cmake -E rm -rf tests/tracy/build diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ae4550f..76b3cb09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,6 @@ set_option(TRACY_NO_VSYNC_CAPTURE "Disable capture of hardware Vsync events" OFF set_option(TRACY_NO_FRAME_IMAGE "Disable the frame image support and its thread" OFF TracyClient) set_option(TRACY_NO_SYSTEM_TRACING "Disable systrace sampling" OFF TracyClient) set_option(TRACY_PATCHABLE_NOPSLEDS "Enable nopsleds for efficient patching by system-level tools (e.g. rr)" OFF TracyClient) -set_option(TRACY_DELAYED_INIT "Enable delayed initialization of the library (init on first call)" OFF TracyClient) set_option(TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the profile" OFF TracyClient) set_option(TRACY_FIBERS "Enable fibers support" OFF TracyClient) set_option(TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF TracyClient) @@ -153,9 +152,6 @@ if(rocprofiler-sdk_FOUND) endif() # handle incompatible combinations -if(TRACY_MANUAL_LIFETIME AND NOT TRACY_DELAYED_INIT) - message(FATAL_ERROR "TRACY_MANUAL_LIFETIME can not be activated with disabled TRACY_DELAYED_INIT") -endif() if(TRACY_DISALLOW_HW_TIMER AND NOT TRACY_TIMER_FALLBACK) message(FATAL_ERROR "TRACY_DISALLOW_HW_TIMER can not be activated with disabled TRACY_TIMER_FALLBACK") endif() diff --git a/manual/tracy.md b/manual/tracy.md index 8800bc4a..40aa1b18 100644 --- a/manual/tracy.md +++ b/manual/tracy.md @@ -11,7 +11,7 @@ The user manual **Bartosz Taudul** [\](mailto:wolf@nereid.pl) -2026-08-16 +2026-08-17 # Quick overview {#quick-overview .unnumbered} @@ -426,8 +426,7 @@ Each enabled option is passed down to your program as a preprocessor macro of th | `TRACY_DISALLOW_HW_TIMER` | Never use the hardware timer, even if it *appears* to be available. Requires `TRACY_TIMER_FALLBACK`. | | | | | **Special environments** | | -| `TRACY_DELAYED_INIT` | Gather the profiler data into a single structure, initialized on first use instead of at load time (section [2.1.9](#multidll)). | -| `TRACY_MANUAL_LIFETIME` | Provide the `StartupProfiler` and `ShutdownProfiler` functions for manual profiler lifetime management. Requires `TRACY_DELAYED_INIT` (section [2.1.9](#multidll)). | +| `TRACY_MANUAL_LIFETIME` | Provide the `StartupProfiler` and `ShutdownProfiler` functions for manual profiler lifetime management (section [2.1.9](#multidll)). | | `TRACY_PLATFORM_HEADER` | Path to a header providing the `TRACY_HAS_CUSTOM_*` hooks for an unsupported platform (section [2.1.11](#customplatform)). | | `TRACY_PATCHABLE_NOPSLEDS` | Emit nopsleds in front of the timer reads, so that system-level tools such as *rr* can patch them. | | | | @@ -510,9 +509,9 @@ For that, you need a *profiler DLL* to which your executable and the other DLLs If you are targeting Windows with Microsoft Visual Studio or MinGW, add the `TRACY_IMPORTS` define to your application. -If you are experiencing crashes or freezes when manually loading/unloading a separate DLL with Tracy integration, you might want to try defining both `TRACY_DELAYED_INIT` and `TRACY_MANUAL_LIFETIME` macros. +If you are experiencing crashes or freezes when manually loading/unloading a separate DLL with Tracy integration, you might want to try defining the `TRACY_MANUAL_LIFETIME` macro. -`TRACY_DELAYED_INIT` enables a path where profiler data is gathered into one structure and initialized on the first request rather than statically at the DLL load at the expense of atomic load on each request to the profiler data. `TRACY_MANUAL_LIFETIME` flag augments this behavior to provide manual `StartupProfiler` and `ShutdownProfiler` functions that allow you to create and destroy the profiler data manually. This manual management removes the need to do an atomic load on each call and lets you define an appropriate place to free the resources. +`TRACY_MANUAL_LIFETIME` provides the `StartupProfiler` and `ShutdownProfiler` functions that allow you to create and destroy the profiler data manually, letting you define an appropriate place to free the resources. Under `TRACY_MANUAL_LIFETIME` the profiler does not exist until `StartupProfiler()` is called and ceases to exist after `ShutdownProfiler()`. Using any instrumentation, zones, locks, plots, messages, and so on before startup or after shutdown is an error. Use `TracyIsStarted` to guard instrumentation that may run conditionally. > [!IMPORTANT] > **Keep everything consistent** @@ -2544,7 +2543,6 @@ You can integrate Tracy with CMake by adding the git submodule folder as a subdi option(TRACY_ENABLE "" ON) # must be enabled option(TRACY_Fortran "" ON) - option(TRACY_DELAYED_INIT "" ON) option(TRACY_MANUAL_LIFETIME "" ON) add_subdirectory(3rdparty/tracy) # target: TracyClientF90 or alias Tracy::TracyClientF90 @@ -2567,7 +2565,6 @@ For using Link-Time optimizations, link both `Tracy::TracyClient` and `Tracy::Tr > When using CMake 3.11 or newer, you can use Tracy via CMake FetchContent. In this case, you do not need to add a git submodule for Tracy manually. Add this to your CMakeLists.txt: > > option(TRACY_Fortran "" ON) -> option(TRACY_DELAYED_INIT "" ON) > option(TRACY_MANUAL_LIFETIME "" ON) > > FetchContent_Declare( diff --git a/manual/tracy.tex b/manual/tracy.tex index 04226988..bbb3b1a1 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -556,8 +556,7 @@ Each enabled option is passed down to your program as a preprocessor macro of th \texttt{TRACY\_DISALLOW\_HW\_TIMER} & Never use the hardware timer, even if it \emph{appears} to be available. Requires \texttt{TRACY\_TIMER\_FALLBACK}. \\ & \\ \textbf{Special environments} & \\ -\texttt{TRACY\_DELAYED\_INIT} & Gather the profiler data into a single structure, initialized on first use instead of at load time (section~\ref{multidll}). \\ -\texttt{TRACY\_MANUAL\_LIFETIME} & Provide the \texttt{StartupProfiler} and \texttt{ShutdownProfiler} functions for manual profiler lifetime management. Requires \texttt{TRACY\_DELAYED\_INIT} (section~\ref{multidll}). \\ +\texttt{TRACY\_MANUAL\_LIFETIME} & Provide the \texttt{StartupProfiler} and \texttt{ShutdownProfiler} functions for manual profiler lifetime management (section~\ref{multidll}). \\ \texttt{TRACY\_PLATFORM\_HEADER} & Path to a header providing the \texttt{TRACY\_HAS\_CUSTOM\_*} hooks for an unsupported platform (section~\ref{customplatform}). \\ \texttt{TRACY\_PATCHABLE\_NOPSLEDS} & Emit nopsleds in front of the timer reads, so that system-level tools such as \emph{rr} can patch them. \\ & \\ @@ -649,9 +648,9 @@ For that, you need a \emph{profiler DLL} to which your executable and the other If you are targeting Windows with Microsoft Visual Studio or MinGW, add the \texttt{TRACY\_IMPORTS} define to your application. -If you are experiencing crashes or freezes when manually loading/unloading a separate DLL with Tracy integration, you might want to try defining both \texttt{TRACY\_DELAYED\_INIT} and \texttt{TRACY\_MANUAL\_LIFETIME} macros. +If you are experiencing crashes or freezes when manually loading/unloading a separate DLL with Tracy integration, you might want to try defining the \texttt{TRACY\_MANUAL\_LIFETIME} macro. -\texttt{TRACY\_DELAYED\_INIT} enables a path where profiler data is gathered into one structure and initialized on the first request rather than statically at the DLL load at the expense of atomic load on each request to the profiler data. \texttt{TRACY\_MANUAL\_LIFETIME} flag augments this behavior to provide manual \texttt{StartupProfiler} and \texttt{ShutdownProfiler} functions that allow you to create and destroy the profiler data manually. This manual management removes the need to do an atomic load on each call and lets you define an appropriate place to free the resources. +\texttt{TRACY\_MANUAL\_LIFETIME} provides the \texttt{StartupProfiler} and \texttt{ShutdownProfiler} functions that allow you to create and destroy the profiler data manually, letting you define an appropriate place to free the resources. Under \texttt{TRACY\_MANUAL\_LIFETIME} the profiler does not exist until \texttt{StartupProfiler()} is called and ceases to exist after \texttt{ShutdownProfiler()}. Using any instrumentation, zones, locks, plots, messages, and so on before startup or after shutdown is an error. Use \texttt{TracyIsStarted} to guard instrumentation that may run conditionally. \begin{bclogo}[ noborder=true, @@ -2836,7 +2835,6 @@ You can integrate Tracy with CMake by adding the git submodule folder as a subdi option(TRACY_ENABLE "" ON) # must be enabled option(TRACY_Fortran "" ON) -option(TRACY_DELAYED_INIT "" ON) option(TRACY_MANUAL_LIFETIME "" ON) add_subdirectory(3rdparty/tracy) # target: TracyClientF90 or alias Tracy::TracyClientF90 \end{lstlisting} @@ -2870,7 +2868,6 @@ When using CMake 3.11 or newer, you can use Tracy via CMake FetchContent. In thi \begin{lstlisting} option(TRACY_Fortran "" ON) -option(TRACY_DELAYED_INIT "" ON) option(TRACY_MANUAL_LIFETIME "" ON) FetchContent_Declare( diff --git a/meson.build b/meson.build index 878909ce..753987e8 100644 --- a/meson.build +++ b/meson.build @@ -85,10 +85,6 @@ if get_option('patchable_nopsleds') tracy_common_args += ['-DTRACY_PATCHABLE_NOPSLEDS'] endif -if get_option('delayed_init') - tracy_common_args += ['-DTRACY_DELAYED_INIT'] -endif - if get_option('manual_lifetime') tracy_common_args += ['-DTRACY_MANUAL_LIFETIME'] endif diff --git a/meson.options b/meson.options index 54f788f9..4b0ebccb 100644 --- a/meson.options +++ b/meson.options @@ -22,7 +22,6 @@ option('disallow_hw_timer', type : 'boolean', value : false, description : 'Disa option('libunwind_backtrace', type : 'boolean', value : false, description : 'Use libunwind backtracing where supported') option('symbol_offline_resolve', type : 'boolean', value : false, description : 'Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution') option('libbacktrace_elf_dynload_support', type : 'boolean', value : false, description : 'Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation') -option('delayed_init', type : 'boolean', value : false, description : 'Enable delayed initialization of the library (init on first call)') option('manual_lifetime', type : 'boolean', value : false, description : 'Enable the manual lifetime management of the profile') option('fibers', type : 'boolean', value : false, description : 'Enable fibers support') option('no_crash_handler', type : 'boolean', value : false, description : 'Disable crash handling') diff --git a/monitor/CMakeLists.txt b/monitor/CMakeLists.txt index 988cd667..7b058ec9 100644 --- a/monitor/CMakeLists.txt +++ b/monitor/CMakeLists.txt @@ -28,7 +28,6 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC $) target_compile_definitions(${PROJECT_NAME} PRIVATE TRACY_ENABLE - TRACY_DELAYED_INIT TRACY_MANUAL_LIFETIME TRACY_NO_FRAME_IMAGE ) diff --git a/public/client/TracyMangle.hpp b/public/client/TracyMangle.hpp index 1e7bc8c5..5a047558 100644 --- a/public/client/TracyMangle.hpp +++ b/public/client/TracyMangle.hpp @@ -1,6 +1,17 @@ #ifndef __TRACYMANGLE_HPP__ #define __TRACYMANGLE_HPP__ +// TRACY_DELAYED_INIT is an internal implementation switch, not a user-facing +// option: Apple platforms require it, and TRACY_MANUAL_LIFETIME builds on top +// of it. It is derived here so that every translation unit, and the client +// implementation, see the same effective value before any config-dependent +// symbol name is computed. +#if defined(TRACY_MANUAL_LIFETIME) || defined(__APPLE__) +# ifndef TRACY_DELAYED_INIT +# define TRACY_DELAYED_INIT +# endif +#endif + #ifdef TRACY_ENABLE #define TRACY_ENABLE_MANGLE _E1 #else diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 4a5d9c47..ed5c0455 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -83,10 +83,6 @@ #include "TracySysTrace.hpp" #include "../tracy/TracyC.h" -#if defined TRACY_MANUAL_LIFETIME && !defined(TRACY_DELAYED_INIT) -# error "TRACY_MANUAL_LIFETIME requires enabled TRACY_DELAYED_INIT" -#endif - #ifdef TRACY_PORT # ifndef TRACY_DATA_PORT # define TRACY_DATA_PORT TRACY_PORT @@ -96,11 +92,7 @@ # endif #endif -#ifdef __APPLE__ -# ifndef TRACY_DELAYED_INIT -# define TRACY_DELAYED_INIT -# endif -#else +#ifndef __APPLE__ # ifdef __GNUC__ # define init_order( val ) __attribute__ ((init_priority(val))) # else