Skip to content

[Merged by Bors] - Change Detection Benchmarks#4972

Closed
ThierryBerger wants to merge 8 commits intobevyengine:mainfrom
ThierryBerger:4883-benchmark-change
Closed

[Merged by Bors] - Change Detection Benchmarks#4972
ThierryBerger wants to merge 8 commits intobevyengine:mainfrom
ThierryBerger:4883-benchmark-change

Conversation

@ThierryBerger
Copy link
Member

Objective

Fixes #4883.

Solution

  • Add benchmarks for Changed and Added

Disclaimer: I'm not that much familiar with benchmarking.

@ThierryBerger ThierryBerger added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times labels Jun 9, 2022
@ThierryBerger ThierryBerger force-pushed the 4883-benchmark-change branch from 3cf2d37 to a4c6a83 Compare June 9, 2022 09:36
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start, thanks.

No significant complaints from me, but a few things which need addressing

#[component(storage = "SparseSet")]
struct Sparse(f32);

const RANGE: std::ops::Range<u32> = 5..7;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good constant name. However, I see that it's consistent with world_get, so it's probably fine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm coming from there, I agree on the criticism though.

@ThierryBerger ThierryBerger force-pushed the 4883-benchmark-change branch from 1a4f878 to d0d09d9 Compare June 30, 2022 07:32
@ThierryBerger ThierryBerger marked this pull request as ready for review July 1, 2022 10:31
@ThierryBerger ThierryBerger added the S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help label Jul 5, 2022
@ThierryBerger ThierryBerger removed the S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help label Aug 8, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this; it's not perfect, but it's consistent with its siblings.


impl BenchModify for Table {
fn bench_modify(&mut self) {
self.0 += 1f32;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't change the situation since this function returns (), also a ZST that is being black_box'ed. Might be better to just directly use this in the benchmarks:

self.0 += 1f32;
black_box(self.0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would that work with the generic trait over Table and Sparse ? I could deref..? Or should we just keep the redundancy for now and address generics on a follow up PR ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you probably mean that I change the implementation of each bench_modify ; I can do that tomorrow 👍

black_box(&mut *table);
let mut query = world.query::<&mut T>();
for mut component in query.iter_mut(&mut world) {
black_box(component.bench_modify());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about that black_box, probably doesn't hurt but as it is inside bench_modify now it's probably not useful here ?

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Nov 4, 2022
# Objective

Fixes #4883.

## Solution

- Add benchmarks for Changed and Added

Disclaimer: I'm not that much familiar with benchmarking.
@bors bors bot changed the title Change Detection Benchmarks [Merged by Bors] - Change Detection Benchmarks Nov 4, 2022
@bors bors bot closed this Nov 4, 2022
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

Fixes bevyengine#4883.

## Solution

- Add benchmarks for Changed and Added

Disclaimer: I'm not that much familiar with benchmarking.
github-merge-queue bot pushed a commit that referenced this pull request Jun 26, 2024
# Objective

- #4972 introduce a benchmark to measure chang detection performance
- However,it uses `iter_batch ` cause a lot of overhead in clone data to
each routine closure(it feels like a bug in`iter_batch `) and constructs
new query in every iter.This overhead masks the real change detection
throughput we want to measure. Instead of evaluating raw change
detection, the benchmark ends up dominated by data cloning and
allocation costs.


## Solution

- Use iter_batch_ref to reduce the benchmark overload 
- Use cached query to better reflect real-world usage scenarios.
- Add more benmark

---

## Changelog
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-Performance A change motivated by improving speed, memory usage or compile times

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change Detection Benchmarks

5 participants