-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracing's overhead may be too high for profiling CPU-bound operations #4892
Comments
I've been wanting to put certain sets of spans under different features for this reason. At the very least separate it into the system/overhead spans and everything else. We'd probably want to have them enabled under the |
I should mention that a big portion of the difference between the two histograms above is due to the applying system commands. This is mostly just a constant offset since most systems don't apply commands every frame. The issue is that it shows up in the trace as a bunch of spans. This check is very light quick in actual code since it's a tight loop just checking that the buffers are empty. Without tracing enable applying these commands is probably less than a microsecond, but shows up in the above image as 90us. I'm not sure how much of an issue this is as it shows up a constant offset for most frames, but we should probably supply a way of disabling these spans if people want to see something closer to the real framerate. |
For However, the other side in One potential cause of this might be that the tracing macros allocate memory, or the subscriber/visitor model of tracing may not be a trivial operation, which have a non-trivial runtime cost. See nagisa/rust_tracy_client#26, which includes a tracy_client level non-allocating |
We'd have to get the name of the originating system down into the SystemParam somehow. Might be doable. People have wanted the name there for other reasons like error reporting. See #2949
Would we have to bypass the tracing crate to use this? |
Notes from Discord: the For a profiling use-case, it might be worthwhile to implement your own subscriber (replacing the @hawkw has some ideas to improve |
# Objective A separate `tracing` span for running a system's commands is created, even if the system doesn't have commands. This is adding extra measuring overhead (see #4892) where it's not needed. ## Solution Move the span into `ParallelCommandState` and `CommandQueue`'s `SystemParamState::apply`. To get the right metadata for the span, a additional `&SystemMeta` parameter was added to `SystemParamState::apply`. --- ## Changelog Added: `SystemMeta::name` Changed: Systems without `Commands` and `ParallelCommands` will no longer show a "system_commands" span when profiling. Changed: `SystemParamState::apply` now takes a `&SystemMeta` parameter in addition to the provided `&mut World`.
# Objective A separate `tracing` span for running a system's commands is created, even if the system doesn't have commands. This is adding extra measuring overhead (see bevyengine#4892) where it's not needed. ## Solution Move the span into `ParallelCommandState` and `CommandQueue`'s `SystemParamState::apply`. To get the right metadata for the span, a additional `&SystemMeta` parameter was added to `SystemParamState::apply`. --- ## Changelog Added: `SystemMeta::name` Changed: Systems without `Commands` and `ParallelCommands` will no longer show a "system_commands" span when profiling. Changed: `SystemParamState::apply` now takes a `&SystemMeta` parameter in addition to the provided `&mut World`.
# Objective A separate `tracing` span for running a system's commands is created, even if the system doesn't have commands. This is adding extra measuring overhead (see bevyengine#4892) where it's not needed. ## Solution Move the span into `ParallelCommandState` and `CommandQueue`'s `SystemParamState::apply`. To get the right metadata for the span, a additional `&SystemMeta` parameter was added to `SystemParamState::apply`. --- ## Changelog Added: `SystemMeta::name` Changed: Systems without `Commands` and `ParallelCommands` will no longer show a "system_commands" span when profiling. Changed: `SystemParamState::apply` now takes a `&SystemMeta` parameter in addition to the provided `&mut World`.
I'm calling this fixed by #9390. If there's still ongoing problems, please reopen this issue :) |
Bevy version
0.7 and current head (cc4062e)
What you did
Attempted to profile
many_foxes
withtrace_tracy
enabled. Commented out spans forsystem_overhead
andsystem_commands
.What went wrong
Profiled measurements for each stage show significant changes. Here's a comparison of the
Update
stage measurements:There's only 10-20 systems in that stage, and the overhead scales with the number of systems. This overhead should be much lower, and it makes it difficult to make perf decisions on a macro level.
The text was updated successfully, but these errors were encountered: