Add an optional bitmap-indexed query/filter path for high-churn ECS workloads
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## 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` / `Without` 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:
```rust
Query, With, Without)>
```
to be evaluated conceptually as:
```text
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](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.
Contributor guide
Assessment
This issue has not been assessed yet.