tracy icon indicating copy to clipboard operation
tracy copied to clipboard

What is the overhead of Tracy functions when Tracy is disabled?

Open Zaephus opened this issue 10 months ago • 5 comments

I am unable to find in the documentation if there is any overhead to having Tracy functions in your code when running it with TRACY_ENABLED set to false. I am trying to find out if it is necessary to use macros to exclude Tracy function calls when Tracy is disabled, like below:

#ifdef ENABLE_PROFILING
	ZoneScoped
#endif

I think it would be nice to mention this overhead in the Performance Impact section (1.7) of the documentation.

Zaephus avatar Apr 25 '25 10:04 Zaephus

https://github.com/wolfpld/tracy/blob/a03c7580b9101df3225937524e09a9a885d5464a/public/tracy/Tracy.hpp#L31

ZoneScoped and many other macros are defined to be nothing if TRACY_ENABLE is undefined. Which, means, if TRACY_ENABLE is not defined, there is zero runtime overhead.

SandSnip3r avatar May 04 '25 15:05 SandSnip3r

There is at least one exception (perhaps others?) tracy::SetThreadName(...) does set the thread name even when compiled without TRACY_ENABLE. Some of what it does is disabled without TRACY_ENABLE but not everything.

DominiquePelle-TomTom avatar May 16 '25 14:05 DominiquePelle-TomTom

True! However, I actually find this feature useful when not using Tracy. When using a debugger, the threads actually have useful names.

On Fri, May 16, 2025 at 7:24 AM Dominique Pelle @.***> wrote:

DominiquePelle-TomTom left a comment (wolfpld/tracy#1036) https://github.com/wolfpld/tracy/issues/1036#issuecomment-2886871808

There is at least one exception (perhaps others?) tracy::SetThreadName(...) does set the thread name even when compiled without TRACY_ENABLE. Some of what it does is disabled without TRACY_ENABLE but not everything.

— Reply to this email directly, view it on GitHub https://github.com/wolfpld/tracy/issues/1036#issuecomment-2886871808, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJZQCWVZQ4L3A6VNWPCZCT26XYJDAVCNFSM6AAAAAB33H6PNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBWHA3TCOBQHA . You are receiving this because you commented.Message ID: @.***>

SandSnip3r avatar May 16 '25 14:05 SandSnip3r

Thread naming is something you want to have universally, and otherwise you would need to have two systems doing the same thing.

wolfpld avatar May 16 '25 14:05 wolfpld

@SandSnip3r wrote:

True! However, I actually find this feature useful when not using Tracy.

For the record, I completely agree, but I just wanted to say that building without TRACY_ENABLE does not imply that all Tracy macros are no-op.

DominiquePelle-TomTom avatar May 20 '25 06:05 DominiquePelle-TomTom