Skip to content

Commit 9e3307d

Browse files
authored
0.13: Fix author attribution in Entity Opt/Query for_each/TableRow sections (#986)
1 parent 4ca73cd commit 9e3307d

File tree

1 file changed

+6
-2
lines changed
  • content/news/2024-02-17-bevy-0.13

1 file changed

+6
-2
lines changed

content/news/2024-02-17-bevy-0.13/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ Here's a short example of how declaring a new layout looks:
11521152

11531153
```rust
11541154
let layout = render_device.create_bind_group_layout(
1155-
"post_process_bind_group_layout"),
1155+
"post_process_bind_group_layout",
11561156
&BindGroupLayoutEntries::sequential(
11571157
ShaderStages::FRAGMENT,
11581158
(
@@ -1398,7 +1398,7 @@ See the [Asset Processing Example](<https://github.com/bevyengine/bevy/blob/main
13981398

13991399
## Entity Optimizations
14001400

1401-
<div class="release-feature-authors">authors: @Bluefinger, @notverymoe, @scottmcm, @bushrat011899, @james7132</div>
1401+
<div class="release-feature-authors">authors: @Bluefinger, @notverymoe, @scottmcm, @james7132, @NathanSWard</div>
14021402

14031403
`Entity` (Bevy's 64-bit unique identifier for enitities) received a number of changes this cycle, combining laying some more groundwork for relations alongside _related_, and nice to have, performance optimizations. The work here involved a lot of deep-diving into compiler codegen/assembly output, with running lots of benchmarks and testing in order to ensure all changes didn't cause breakages or major problems. Although the work here was dealing with mostly _safe_ code, there were lots of underlying assumptions being changed that could have impacted code elsewhere. This was the most "micro-optimization" oriented set of changes in Bevy 0.13.
14041404

@@ -1429,6 +1429,8 @@ If that interests you, open some new tabs in the background!
14291429

14301430
## Porting `Query::for_each` to `QueryIter::fold` override
14311431

1432+
<div class="release-feature-authors">authors: @james7132</div>
1433+
14321434
Currently to get the full performance out of iterating over queries, `Query::for_each` must be used in order to take advantage of auto-vectorization and internal iteration optimizations that the compiler can apply. However, this isn't idiomatic rust and is not an iterator method so you can't use it on an iterator chain. However, it is possible to get the same benefits for some iterator methods, for which [#6773](https://github.com/bevyengine/bevy/pull/6773/) by @james7132 sought to achieve. By providing an override to `QueryIter::fold`, it was possible to port the iteration strategies of `Query::for_each` so that `Query::iter` and co could achieve the same gains. Not _every_ iterator method currently benefits from this, as they require overriding `QueryIter::try_fold`, but that is currently still a nightly-only optimisation. This same approach is within the Rust standard library.
14331435

14341436
This deduplicated code in a few areas, such as no longer requiring both `Query::for_each` and `Query::for_each_mut`, as one just needs to call `Query::iter` or `Query::iter_mut` instead. So code like:
@@ -1457,6 +1459,8 @@ As a plus, the same internal iteration optimizations in `Query::par_for_each` no
14571459

14581460
## Reducing `TableRow` `as` Casting
14591461

1462+
<div class="release-feature-authors">authors: @bushrat011899</div>
1463+
14601464
Not all improvements in our ECS internals were focused around performance. Some small changes were done to improve type safety and tidy-up some of the codebase to have less `as` casting being done on various call sites for `TableRow`. The problem with `as` casting is that in some cases, the cast will fail by truncating the value silently, which could then cause havoc by accessing the wrong row and so forth. [#10811](https://github.com/bevyengine/bevy/pull/10811) by @bushrat011899 was put forward to clean up the API around `TableRow`, providing convenience methods backed by `assert`s to ensure the casting operations could never fail, or if they did, they'd panic correctly.
14611465

14621466
Naturally, _adding_ asserts in potentially hot codepaths were cause for some concern, necessitating considerable benchmarking efforts to confirm there were regressions and to what level. With careful placing of the new `assert`s, the detected regression for these cases was in the region of 0.1%, well within noise.

0 commit comments

Comments
 (0)