Skip to content

Modify bevy_ecs to support removing archetypes and unregistering components #17564

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

Open
7 tasks
alice-i-cecile opened this issue Jan 27, 2025 · 2 comments
Open
7 tasks
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times C-Tracking-Issue An issue that collects information about a broad development initiative

Comments

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jan 27, 2025

As discussed in bevyengine/rfcs#79 and laid out by @james-j-obrien, Bevy's ECS architecture is not optimized for use in worlds with a very large number of archetypes. Fundamentally:

bevy_ecs currently operates under the assumption that archetype and component ids are dense and strictly increasing.

While this is a blocker for efficient implementation of fragmenting / archetypal relations, it's also worth exploring and fixing in its own right.

There are several steps to this:

  • Remove the sparse set in table storage Remove sparse set in Table storage #14928
  • Replace the FixedBitSet in Access / FilteredAccess Replace FixedBitSet in Access and FilteredAccess with sorted vectors #16784
  • Implement a component index, which tracks the tables and archetypes each ComponentId belongs to as well as the column in that table the id inhabits (if any)
  • Query and system caches need to be easier to access.
  • Query and system caches must be updated to reflect changes to archetypes
  • Create and expose tools for deleting component ids
  • Create and expose tools for deleting archetypes

This is a tracking issue: as more related work comes along, please link it here and bother Alice to update this issue description.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times C-Tracking-Issue An issue that collects information about a broad development initiative labels Jan 27, 2025
@cart
Copy link
Member

cart commented Jan 27, 2025

Might be worth reframing this / renaming it. The "dense and strictly increasing" behavior works great (essentially optimally) with a large number of archetypes, provided they are all being used. This is about adapting Bevy ECS to dataflow where the set of archetypes is constantly changing.

@alice-i-cecile alice-i-cecile changed the title Ensure that bevy_ecs can handle large numbers of archetypes Modify bevy_ecs to support removing archetypes and unregistering components Jan 27, 2025
@chescock
Copy link
Contributor

#16885 may also be helpful. It would let us get rid of ArchetypeComponentId, which grows and changes even faster than ArchetypeId itself!

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-Feature A new feature, making something new possible C-Performance A change motivated by improving speed, memory usage or compile times C-Tracking-Issue An issue that collects information about a broad development initiative
Projects
None yet
Development

No branches or pull requests

3 participants