[Merged by Bors] - Inline world get#2520
Conversation
|
Looks like the comparable |
|
Aha, the underlying bevy/crates/bevy_ecs/src/query/state.rs Line 164 in 19db1e4 Is that worth doing? Should it be a seperate PR? |
it does improve bench |
af55067 to
dcb10e1
Compare
|
Awesome! I love free performance. I think not including get_unchecked_manual is the right call, given the Table iterator regressions (which we try to keep in check). Lets merge this as is and we can consider get_unchecked_manual later / maybe try tweaking other things so the stars align favorably. |
|
bors r+ |
# Objective While looking at the code of `World`, I noticed two basic functions (`get` and `get_mut`) that are probably called a lot and with simple code that are not `inline` ## Solution - Add benchmark to check impact - Add `#[inline]` ``` group this pr main ----- ---- ---- world_entity/50000_entities 1.00 115.9±11.90µs ? ?/sec 1.71 198.5±29.54µs ? ?/sec world_get/50000_entities_SparseSet 1.00 409.9±46.96µs ? ?/sec 1.18 483.5±36.41µs ? ?/sec world_get/50000_entities_Table 1.00 391.3±29.83µs ? ?/sec 1.16 455.6±57.85µs ? ?/sec world_query_for_each/50000_entities_SparseSet 1.02 121.3±18.36µs ? ?/sec 1.00 119.4±13.88µs ? ?/sec world_query_for_each/50000_entities_Table 1.03 13.8±0.96µs ? ?/sec 1.00 13.3±0.54µs ? ?/sec world_query_get/50000_entities_SparseSet 1.00 666.9±54.36µs ? ?/sec 1.03 687.1±57.77µs ? ?/sec world_query_get/50000_entities_Table 1.01 584.4±55.12µs ? ?/sec 1.00 576.3±36.13µs ? ?/sec world_query_iter/50000_entities_SparseSet 1.01 169.7±19.50µs ? ?/sec 1.00 168.6±32.56µs ? ?/sec world_query_iter/50000_entities_Table 1.00 26.2±1.38µs ? ?/sec 1.91 50.0±4.40µs ? ?/sec ``` I didn't add benchmarks for the mutable path but I don't see how it could hurt to make it inline too...
Objective
While looking at the code of
World, I noticed two basic functions (getandget_mut) that are probably called a lot and with simple code that are notinlineSolution
#[inline]I didn't add benchmarks for the mutable path but I don't see how it could hurt to make it inline too...