-
-
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
Inline more ECS functions #8083
Conversation
Holding off on taking this out of draft until #8053 is merged since some of the optimizations using inlined |
I just kicked off a merge of #8053 |
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.
LGTM. I'd be interested in seeing if there's any visible difference in benchmarks, but it's not necessary.
Is there an impact on build time with those new inlines? |
Good question.Definitely worth measuring. I would assume it would increase the amount of generated code whenever larger functions like Entities::get and SparseSets::get are used, but it probably doesn't have that strong of an impact without LTO enabled. |
@mockersf I checked the compiler output changes for this PR: james7132/bevy_asm_tests@214de16 Seems like there's a slight increase in codegen (~100-170 instructions) for component insertion/removal, and a signifcant decrease for any fetch or iteration (i.e. Query iteration, Query::get, and World::get). |
As a final sanity check, I reran microbenchmarks for this PR. Gains are generally pretty small or within error margin, with the exception of
|
Did two builds just to check for major build time regressions. This PR: 1m 14s No significant changes. Maybe slightly faster but probably just within the noise. |
Objective
Upon closer inspection, there are a few functions in the ECS that are not being inlined, even with the highest optimizations and LTO enabled:
Query::get
calls in hot loops. In particular, theWorldQuery
implementation for()
is used everywhere as the default filter and is effectively a no-op.Query::get
,World::get
, and any component insertion or removal.Almost all of these have trivial or even empty implementations or have significant opportunity to be optimized into surrounding code when inlined with LTO enabled.
Solution
Inline them