bevy/crates
James Liu 286bc8cce5
Store only the IDs needed for Query iteration (#12476)
# Objective
Other than the exposed functions for reading matched tables and
archetypes, a `QueryState` does not actually need both internal Vecs for
storing matched archetypes and tables. In practice, it will only use one
of the two depending on if it uses dense or archetypal iteration.

Same vein as #12474. The goal is to reduce the memory overhead of using
queries, which Bevy itself, ecosystem plugins, and end users are already
fairly liberally using.

## Solution
Add `StorageId`, which is a union over `TableId` and `ArchetypeId`, and
store only one of the two at runtime. Read the slice as if it was one ID
depending on whether the query is dense or not.

This follows in the same vein as #5085; however, this one directly
impacts heap memory usage at runtime, while #5085 primarily targeted
transient pointers that might not actually exist at runtime.

---

## Changelog
Changed: `QueryState::matched_tables` now returns an iterator instead of
a reference to a slice.
Changed: `QueryState::matched_archetypes` now returns an iterator
instead of a reference to a slice.

## Migration Guide
`QueryState::matched_tables` and `QueryState::matched_archetypes` does
not return a reference to a slice, but an iterator instead. You may need
to use iterator combinators or collect them into a Vec to use it as a
slice.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2024-03-30 10:15:55 +00:00
..
bevy_a11y Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_animation Move FloatOrd into bevy_math (#12732) 2024-03-27 18:30:11 +00:00
bevy_app Move PanicHandlerPlugin into bevy_app (#12640) 2024-03-29 02:04:56 +00:00
bevy_asset Allow converting mutable handle borrows to AssetId. (#12759) 2024-03-28 15:53:26 +00:00
bevy_audio updated audio_source.rs documentation (#12765) 2024-03-28 19:10:09 +00:00
bevy_color Move Point out of cubic splines module and expand it (#12747) 2024-03-28 13:40:26 +00:00
bevy_core Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_core_pipeline Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
bevy_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_dev_tools Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_diagnostic Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_dylib Set the logo and favicon for all of Bevy's published crates (#12696) 2024-03-25 18:52:50 +00:00
bevy_dynamic_plugin Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_ecs Store only the IDs needed for Query iteration (#12476) 2024-03-30 10:15:55 +00:00
bevy_ecs_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_encase_derive Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gilrs Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_gizmos Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
bevy_gltf Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_hierarchy Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_input Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_internal Fix ambiguities causing a crash (#12780) 2024-03-29 16:00:13 +00:00
bevy_log Fix unhandled null characters in Android logs (#12743) 2024-03-29 03:04:46 +00:00
bevy_macro_utils Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_macros_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_math Fix Triangle2d/Triangle3d interior sampling to correctly follow triangle (#12766) 2024-03-29 13:10:23 +00:00
bevy_mikktspace Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_pbr Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
bevy_ptr Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_reflect Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_reflect_compile_fail_tests Fix Ci failing over dead code in tests (#12623) 2024-03-21 18:08:47 +00:00
bevy_render Vectorize reset_view_visibility (#12797) 2024-03-30 08:28:16 +00:00
bevy_scene Update the Children component of the parent entity when a scene gets deleted (#12710) 2024-03-29 13:13:32 +00:00
bevy_sprite Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
bevy_tasks Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_text Move FloatOrd into bevy_math (#12732) 2024-03-27 18:30:11 +00:00
bevy_time Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_transform Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_ui Improve performance by binning together opaque items instead of sorting them. (#12453) 2024-03-30 02:55:02 +00:00
bevy_utils Move FloatOrd into bevy_math (#12732) 2024-03-27 18:30:11 +00:00
bevy_window Forbid unsafe in most crates in the engine (#12684) 2024-03-27 03:30:08 +00:00
bevy_winit Add Clone to WinitSettings (#12787) 2024-03-29 17:24:11 +00:00