-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Use new run_without_applying_deferred
method in SingleThreadedExecutor
#18684
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
Use new run_without_applying_deferred
method in SingleThreadedExecutor
#18684
Conversation
Less unsafe is more good! |
world: &mut World, | ||
) -> Result { | ||
let result = system.run_without_applying_deferred((), world); | ||
black_box(()); |
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.
This is the first time I've seen black_box
used like this, and after some searching I still don't know why this would be beneficial. Can you explain or link me to somewhere this is explained?
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.
I'm not actually sure! I just copied it from the other methods.
... Okay, I think I found the source. It comes from the __rust_begin_short_backtrace
method in std, which has a comment "prevent this frame from being tail-call optimised away".
I'm going to add that as a comment to the black_box
calls here, even though it's not strictly related to this PR.
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.
Scheduler simplifications are nice. And yep, I should have commented the black_box
.
…utor` (bevyengine#18684) # Objective Simplify code in the `SingleThreadedExecutor` by removing a special case for exclusive systems. The `SingleThreadedExecutor` runs systems without immediately applying deferred buffers. That required calling `run_unsafe()` instead of `run()`, but that would `panic` for exclusive systems, so the code also needed a special case for those. Following bevyengine#18076 and bevyengine#18406, we have a `run_without_applying_deferred` method that has the exact behavior we want and works on exclusive systems. ## Solution Replace the code in `SingleThreadedExecutor` that runs systems with a single call to `run_without_applying_deferred()`. Also add this as a wrapper in the `__rust_begin_short_backtrace` module to preserve the special behavior for backtraces.
Objective
Simplify code in the
SingleThreadedExecutor
by removing a special case for exclusive systems.The
SingleThreadedExecutor
runs systems without immediately applying deferred buffers. That required callingrun_unsafe()
instead ofrun()
, but that wouldpanic
for exclusive systems, so the code also needed a special case for those. Following #18076 and #18406, we have arun_without_applying_deferred
method that has the exact behavior we want and works on exclusive systems.Solution
Replace the code in
SingleThreadedExecutor
that runs systems with a single call torun_without_applying_deferred()
. Also add this as a wrapper in the__rust_begin_short_backtrace
module to preserve the special behavior for backtraces.