-
-
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
Only run event systems if they have tangible work to do #7728
Only run event systems if they have tangible work to do #7728
Conversation
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
# Objective Noticed while writing #7728 that we are using `trace!` logs in our event functions. This has shown to have significant overhead, even trace level logs are disabled globally, as seen in #7639. ## Solution Use the `detailed_trace!` macro introduced in #7639. Also removed the `event_trace` function that was only used in one location. --- ## Changelog Changed: Event trace logs are now feature gated behind the `detailed-trace` feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit but other than that LGTM
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
) # Objective Scheduling low cost systems has significant overhead due to task pool contention and the extra machinery to schedule and run them. Event update systems are the prime example of a low cost system, requiring a guaranteed O(1) operation, and there are a *lot* of them. ## Solution Add a run condition to every event system so they only run when there is an event in either of it's two internal Vecs. --- ## Changelog Changed: Event update systems will not run if there are no events to process. ## Migration Guide `Events<T>::update_system` has been split off from the the type and can be found at `bevy_ecs::event::event_update_system`. --------- Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
# Objective Scheduling low cost systems has significant overhead due to task pool contention and the extra machinery to schedule and run them. Following the example of #7728, `asset_events` is good example of this kind of system, where there is no work to be done when there are no queued asset events. ## Solution Put a run condition on it that checks if there are any queued events. ## Performance Tested against `many_foxes`, we can see a slight improvement in the total time spent in `UpdateAssets`. Also noted much less volatility due to not being at the whim of the OS thread scheduler. ![image](https://github.com/bevyengine/bevy/assets/3137680/e0b282bf-27d0-4fe4-81b9-ecd72ab258e5) --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Objective
Scheduling low cost systems has significant overhead due to task pool contention and the extra machinery to schedule and run them. Event update systems are the prime example of a low cost system, requiring a guaranteed O(1) operation, and there are a lot of them.
Solution
Add a run condition to every event system so they only run when there is an event in either of it's two internal Vecs.
Changelog
Changed: Event update systems will not run if there are no events to process.
Migration Guide
Events<T>::update_system
has been split off from the the type and can be found atbevy_ecs::event::event_update_system
.