Skip to content

Benchmark replacement of immutable components with hooks #19616

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CrushedPixel
Copy link
Contributor

@CrushedPixel CrushedPixel commented Jun 13, 2025

Objective

#16372 added support for immutable components, enabling a pattern of using On<Insert> to be guaranteed to catch every mutation of a component on an entity.

There are currently no benchmarks to compare the performance of using On<Insert> with immutable components to directly mutating components and using Changed<C>.

Solution

  • Added benchmarks for reinsertion of immutable components, with and without On<Insert> hooks, similar to the benchmarks using Changed.

Caveats

  • It might make sense to move these benchmarks to a separate file.
  • The performance is very similar for table and sparse set storage types. Perhaps we should omit the variation in these tests.

Since this is only my second time contributing to bevy, I am especially open to more feedback.

Testing

  • I tested on a 2021 MacBook Pro 16'' with M1 Max CPU.

Showcase

pdf

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Benchmarks Stress tests and benchmarks used to measure how fast things are X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Needs-Release-Note Work that should be called out in the blog due to impact labels Jun 13, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Jun 13, 2025
@alice-i-cecile
Copy link
Member

I want to combine release notes for this plus #19602, and use these benches to help motivate further improvements. cc @ecoskey.

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-Benchmarks Stress tests and benchmarks used to measure how fast things are D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants