Skip to content

Remove ArchetypeComponentId and archetype_component_access #19143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 27, 2025

Conversation

chescock
Copy link
Contributor

@chescock chescock commented May 9, 2025

Objective

Remove ArchetypeComponentId and archetype_component_access. Following #16885, they are no longer used by the engine, so we can stop spending time calculating them or space storing them.

Solution

Remove ArchetypeComponentId and everything that touches it.

The System::update_archetype_component_access method no longer needs to update archetype_component_access. We do still need to update query caches, but we no longer need to do so before running the system. We'd have to touch every caller anyway if we gave the method a better name, so just remove System::update_archetype_component_access and SystemParam::new_archetype entirely, and update the query cache in Query::get_param.

The Single and Populated params also need their query caches updated in SystemParam::validate_param, so change validate_param to take &mut Self::State instead of &Self::State.

@chescock chescock added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 9, 2025
Copy link
Contributor

@ElliottjPierce ElliottjPierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy approve! Everything looks good to me.

Copy link
Contributor

@ItsDoot ItsDoot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! This should make queries as entities straightforward now, right?

Some stats on memory savings on 64-bit systems:

  • -8 bytes per component per archetype
  • -8 bytes per resource
  • -4 bytes per system (SystemState)
  • at least -128 bytes per system (SystemMeta)
  • at least -128 bytes per combinator system
  • at least -128 bytes per pipe system

@ItsDoot ItsDoot added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 10, 2025
Copy link
Contributor

@NthTensor NthTensor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration guide looks good -- although I doubt anyone will be broken by this change.

@alice-i-cecile
Copy link
Member

@chescock merge conflicts are non-trivial. Can you fix them up so I can get this in?

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels May 26, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone May 26, 2025
…component-id

# Conflicts:
#	crates/bevy_ecs/src/system/system_param.rs
@chescock chescock added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels May 27, 2025
@chescock
Copy link
Contributor Author

@chescock merge conflicts are non-trivial. Can you fix them up so I can get this in?

@alice-i-cecile Should be fixed now!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 27, 2025
Merged via the queue into bevyengine:main with commit 571b3ba May 27, 2025
34 checks passed
@ItsDoot ItsDoot mentioned this pull request May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Performance A change motivated by improving speed, memory usage or compile times M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants