Skip to content

Add an optional bitmap-indexed query/filter path for high-churn ECS workloads #23985

@AGeorgy

Description

@AGeorgy

What problem does this solve or what need does it fill?

Bevy ECS is very fast for dense archetype/table iteration, but some workloads are less ideal for the current model:

  • many marker/tag components
  • frequent add/remove of temporary state components
  • queries with many With<T> / Without<T> filters
  • large simulations where most entities should be skipped quickly

In these cases, filtering cost and archetype churn can become significant. It would be useful to investigate whether Bevy ECS could benefit from an optional bitmap index for component presence, inspired by the approach used in StaticEcs.

What solution would you like?

Add an optional bitmap-indexed query/filter path to Bevy ECS.

The idea is that component presence could be represented as bitmaps, allowing queries like:

Query<Entity, (With<A>, With<B>, Without<C>)>

to be evaluated conceptually as:

bitmap(A) & bitmap(B) & !bitmap(C)

This should not replace Bevy’s current archetype/table storage. Instead, it could be an internal optimization for specific cases, such as marker-heavy or high-churn components.

Ideally, this would require little or no new query syntax. Existing queries could automatically use bitmap filtering when it is beneficial.

What alternative(s) have you considered?

  • Use Bevy’s existing archetype/table model.
  • Use sparse-set components for high-churn markers.
  • Store flags inside larger components instead of adding/removing marker components.
  • Maintain manual side indexes in user code.
  • Use a fully bitmap-based ECS architecture.

These workarounds can help, but they either reduce ECS ergonomics, require manual synchronization, or do not directly address filter-heavy query performance.

Additional context

This idea is inspired by the Bitmap Index / hierarchical inverted bitmap approach implemented in StaticEcs:

https://github.com/Felid-Force-Studios/StaticEcs

The request is not to replace Bevy ECS with StaticEcs’ architecture, but to explore whether a similar bitmap-based filtering mechanism could be useful as an optional optimization inside Bevy ECS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile timesD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-BenchmarkingThis set of changes needs performance benchmarking to double-check that they helpS-Needs-Design-DocThis issue or PR is particularly complex, and needs an approved design doc before it can be merged

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions