Closed plekakis closed 6 months ago
The issues I see with the current solution:
TracyIsStarted
check is needed? If you manage the profiler lifetime yourself, you already know where you can and can't make the calls. Adding internal checks just makes things slower.QueueSerialFinish
shows me that this is not a complete solution, but a stop gap measure. There are no use cases where you would call this function directly from your code.MANUAL_LIFETIME
case, but the logic changes you are introducing depend on TRACY_ON_DEMAND
.m_active
and related handling to a code path that doesn't currently need it, for no good reason.Yes, I agree, let's close this PR. It needs more thought, for sure, however as discussed previously: "If you manage the profiler lifetime yourself, you already know where you can and can't make the calls" This is not correct when it comes to mutex instrumentation. For now I can simply use ON_DEMAND which suits my use-case well actually.
This is not correct when it comes to mutex instrumentation.
That's true. I have looked at how to solve this myself and it is already non-trivial in the on-demand case. I'm not sure a manual lifetime management solution would be viable here.
Most public API functions are now guarded against TracyIsStarted. This is always true when MANUAL_LIFETIME is not defined and true after StartupProfiler is called. This does mean that no data recording is taking place until after Tracy has been initialised. It doesn't break existing behaviour, this is only a path taken when MANUAL_LIFETIME is defined. In addition to the Scoped classes, the LockCtx is also guarded. This means that the mutexes won't be instrumented if at the time of their context allocation Tracy hasn't been initialised (this is expected in this case).