mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
a634075a39
# Objective In #11330 I found out that `Parent::get` didn't get inlined, **even with LTO on**! This means that just to access a field, we have an instruction cache invalidation, we will move some registers to the stack, will jump to new instructions, move the field into a register, then do the same dance in the other direction to go back to the call site. ## Solution Mark trivial functions as `#[inline]`. `inline(always)` may increase compilation time proportional to how many time the function is called **and the size of the function marked with `inline`**. Since we mark as `inline` functions that consists in a single instruction, the cost is absolutely negligible. I also took the opportunity to `inline` other functions. I'm not as confident that marking functions calling other functions as `inline` works similarly to very simple functions, so I used `inline` over `inline(always)`, which doesn't have the same downsides as `inline(always)`. More information on inlining in rust: https://nnethercote.github.io/perf-book/inlining.html |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |