bevyengine / bevyengine/bevy

Sparse set components in filters force sparse set iteration

Open
#2,144 2 comments 1 reaction 0 assignees View on GitHub
A-ECS C-Performance D-Complex S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

To refresh on sparse sets vs table component storages:
* Table iteration is 2-4x faster than sparse set iteration at the moment.
* Adding and removing sparse set components is faster than tables.

If a query has *any* sparse set components, we must use sparse set iteration as we don't have a single query. This is suboptimal if the sparse set components only exist in the filters, e.g `Query<&Dense, With`. All of the actual data we need to iterate over exists in table storage though, so this is a needless cost.

This is a common and natural pattern, especially if you're using sparse set marker components, so fixing this problem would help ensure that sparse-set components actually accomplish their promised perf benefits in real applications.

@cart raised this on [Discord](https://discord.com/channels/691052431525675048/749335865876021248/841742319136014337).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.