-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Merged by Bors] - Add benchmarks for schedule dependency resolution #4961
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3a6bd4
bench schedule dependency resolution
joseph-gio 1af2276
actually run dependency resolver
joseph-gio a1f7f71
lower the upper bound for graph sizes
joseph-gio 6301fd5
move initialization code outside of the benchmark
joseph-gio 06b8dc6
change `App.run` to `App.update`
joseph-gio 3a5c231
add comments and use better names
joseph-gio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use bevy_app::App; | ||
use bevy_ecs::prelude::*; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
criterion_group!(benches, build_schedule); | ||
criterion_main!(benches); | ||
|
||
fn build_schedule(criterion: &mut Criterion) { | ||
// empty system | ||
fn empty_system() {} | ||
|
||
// Use multiple different kinds of label to ensure that dynamic dispatch | ||
// doesn't somehow get optimized away. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemLabel)] | ||
struct NumLabel(usize); | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemLabel)] | ||
struct DummyLabel; | ||
|
||
let mut group = criterion.benchmark_group("build_schedule"); | ||
group.warm_up_time(std::time::Duration::from_millis(500)); | ||
group.measurement_time(std::time::Duration::from_secs(15)); | ||
|
||
// Method: generate a set of `graph_size` systems which have a One True Ordering. | ||
// Add system to the stage with full constraints. Hopefully this should be maximimally | ||
// difficult for bevy to figure out. | ||
let labels: Vec<_> = (0..1000).map(NumLabel).collect(); | ||
|
||
// Benchmark graphs of different sizes. | ||
for graph_size in [100, 500, 1000] { | ||
// Basic benchmark without constraints. | ||
group.bench_function(format!("{graph_size}_schedule_noconstraints"), |bencher| { | ||
bencher.iter(|| { | ||
let mut app = App::new(); | ||
for _ in 0..graph_size { | ||
app.add_system(empty_system); | ||
} | ||
app.update(); | ||
}); | ||
}); | ||
|
||
// Benchmark with constraints. | ||
group.bench_function(format!("{graph_size}_schedule"), |bencher| { | ||
bencher.iter(|| { | ||
let mut app = App::new(); | ||
app.add_system(empty_system.label(DummyLabel)); | ||
|
||
// Build a fully-connected dependency graph describing the One True Ordering. | ||
// Not particularly realistic but this can be refined later. | ||
for i in 0..graph_size { | ||
joseph-gio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let mut sys = empty_system.label(labels[i]).before(DummyLabel); | ||
for a in 0..i { | ||
sys = sys.after(labels[a]); | ||
} | ||
for b in i + 1..graph_size { | ||
sys = sys.before(labels[b]); | ||
} | ||
app.add_system(sys); | ||
} | ||
// Run the app for a single frame. | ||
// This is necessary since dependency resolution does not occur until the game runs. | ||
// FIXME: Running the game clutters up the benchmarks, so ideally we'd be | ||
// able to benchmark the dependency resolution directly. | ||
app.update(); | ||
}); | ||
}); | ||
} | ||
|
||
group.finish(); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.