-
-
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
Improve codegen for world validation #9464
Improve codegen for world validation #9464
Conversation
Example |
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 think I remember this being better, and it's a pattern already used in Bevy, but don't remember if it has any actual impact
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 style nits. The motivation and logic behind the change makes sense to me. Could you rebase this PR to the latest main? I want to test this against bevy_asm_tests to see the output difference.
Co-authored-by: James Liu <contact@jamessliu.com>
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.
It does seem to work. There was a rough 300 fewer lines of assembly generated across several test cases for QueryState, a 14% decrease in codegen. Though the bulk of that seems to be in the symbols for panicking, this is still a decent win.
I'll kick off a merge once CI is fixed.
# Objective Improve code-gen for `QueryState::validate_world` and `SystemState::validate_world`. ## Solution * Move panics into separate, non-inlined functions, to reduce the code size of the outer methods. * Mark the panicking functions with `#[cold]` to help the compiler optimize for the happy path. * Mark the functions with `#[track_caller]` to make debugging easier. --------- Co-authored-by: James Liu <contact@jamessliu.com>
Objective
Improve code-gen for
QueryState::validate_world
andSystemState::validate_world
.Solution
#[cold]
to help the compiler optimize for the happy path.#[track_caller]
to make debugging easier.