-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Added initial benchmarks #551
Conversation
Both approaches make sense: using Is there any way to initialize the scene, and then have divan benchmark each frame of the bevy world update? |
I did implement that with 2cda622 |
benches_common/src/lib.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of benches_common
be its own create, it should just be a subdirectory in the bevy_rapier3d/benches
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the same hierarchy of avian : https://github.com/Jondolf/avian/tree/main/crates ; I'd have preferred a way to enable feature on benches_common to support either 2d or 3d, but I didn't try that.
Either way, it's not too much code, and we can probably focus on 3d for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually allows me to share some logic with the custom benchmark.
I did add this logic in the custom benchmark, and call into this custom benchmark library from the "simpler" benches.
custom_benches/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cargo bench
section should be removed to the last position in this file. The Custom benches
section should be a bit more wordy by saying that it runs benchmarks manually, without bench harnesses, to obtain more detailed results on long-running simulations.
The cargo bench
section should say something like "For short-lived benchmarks based on statistical analysis, benchmarks can be run through the divan
bench harness.`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note: I imagine we could use the bench approach (with our own custom bench harness) for better control over custom benchmarks, i.e. run specific custom benches, but I'd need to research that a bit, that can probably be a follow up.
custom_benches/src/main.rs
Outdated
//! Translated from rapier benchmark. | ||
//! | ||
//! <https://github.com/dimforge/rapier/blob/87ada34008f4a1a313ccf8c3040040bab4f10e69/benchmarks3d/many_pyramids3.rs> | ||
|
||
use benches_common::default_app; | ||
use benches_common::wait_app_start; | ||
use bevy::prelude::*; | ||
use bevy_rapier3d::dynamics::RigidBody; | ||
use bevy_rapier3d::geometry::Collider; | ||
use bevy_rapier3d::math::Vect; | ||
use bevy_rapier3d::plugin::RapierContext; | ||
|
||
pub fn create_pyramid(commands: &mut Commands, offset: Vect, stack_height: usize, rad: f32) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of code duplication with bevy_rapier3d/benches
; but I'm not sure how to solve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added shared setup code to the custom benchmark bevy_rapier_benches3d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks!
Objective
bevy_rapier currently has no benchmarks, making it difficult to be confident with refactoring, or consider performance improvements. This PR aims to implement foundation to address this.
Avian comparison
I doubt the benchmarks are comparable with avian's, as the time management from avian is customized, it might not be running full speed in avian.
bevy_rapier
Avian
Suspicious bad performance
I looked into
pipeline.counters.step_time.time()
, originally to compare with the total update time, in order to get an idea of the overhead frombevy
/bevy_rapier
, but I had surprising results:Flamegraph
flamegraph.zip
^ above numbers reported with f3a3d79