bevy/crates/bevy_gizmos/src
Chris Russell bb4ea9c28b
Stop storing access for all systems (#19477)
# Objective

Reduce memory usage by storing fewer copies of
`FilteredAccessSet<ComponentId>`.

Currently, the `System` trait exposes the `component_access_set` for the
system, which is used by the multi-threaded executor to determine which
systems can run concurrently. But because it is available on the trait,
it needs to be stored for *every* system, even ones that are not run by
the executor! In particular, it is never needed for observers, or for
the inner systems in a `PipeSystem` or `CombinatorSystem`.


## Solution

Instead of exposing the access from a method on `System`, return it from
`System::initialize`. Since it is still needed during scheduling, store
the access alongside the boxed system in the schedule.

That's not quite enough for systems built using `SystemParamBuilder`s,
though. Those calculate the access in `SystemParamBuilder::build`, which
happens earlier than `System::initialize`. To handle those, we separate
`SystemParam::init_state` into `init_state`, which creates the state
value, and `init_access`, which calculates the access. This lets
`System::initialize` call `init_access` on a state that was provided by
the builder.

An additional benefit of that separation is that it removes the need to
duplicate access checks between `SystemParamBuilder::build` and
`SystemParam::init_state`.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-06-13 17:56:09 +00:00
..
primitives Improve Segment2d/Segment3d API and docs (#18206) 2025-03-09 20:21:31 +00:00
aabb.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
arcs.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
arrows.rs
circles.rs
config.rs Revert "don't use bevy_pbr for base bevy_gizmos plugin" (#18327) 2025-03-17 22:23:42 +00:00
cross.rs
curves.rs
gizmos.rs Stop storing access for all systems (#19477) 2025-06-13 17:56:09 +00:00
grid.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00
lib.rs bevyengine.org -> bevy.org (#19503) 2025-06-05 23:09:28 +00:00
light.rs Adopt consistent FooSystems naming convention for system sets (#18900) 2025-05-06 15:18:03 +00:00
line_joints.wgsl
lines.wgsl
pipeline_2d.rs Remove Shader weak_handles from bevy_gizmos. (#19394) 2025-05-27 22:32:32 +00:00
pipeline_3d.rs Remove Shader weak_handles from bevy_gizmos. (#19394) 2025-05-27 22:32:32 +00:00
retained.rs Revert "don't use bevy_pbr for base bevy_gizmos plugin" (#18327) 2025-03-17 22:23:42 +00:00
rounded_box.rs Upgrade to Rust Edition 2024 (#17967) 2025-02-24 03:54:47 +00:00