Skip to content
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

[Merged by Bors] - Bevy ECS V2 #1525

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
[package]
name = "benches"
version = "0.1.0"
authors = ["Carter Anderson <[email protected]>"]
authors = [
"Bevy Contributors <[email protected]>",
"Carter Anderson <[email protected]>",
]
edition = "2018"

[dev-dependencies]
criterion = "0.3"
bevy = { path = "../" }

[[bench]]
name = "bench"
path = "benches/bevy_ecs/bench.rs"
harness = false
required-features = ["macros"]

[[bench]]
name = "system_stage"
path = "benches/bevy_ecs/stages.rs"
Expand Down
94 changes: 0 additions & 94 deletions benches/benches/bevy_ecs/bench.rs

This file was deleted.

59 changes: 29 additions & 30 deletions benches/benches/bevy_ecs/stages.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use bevy::ecs::{IntoSystem,World,SystemStage,Resources,Query,Stage};
use bevy::ecs::{
world::World,
schedule::{Stage, SystemStage},
system::{IntoSystem, Query},
};
use criterion::{criterion_group, criterion_main, Criterion};

criterion_group!(benches, empty_systems, busy_systems, contrived);
criterion_main!(benches);

fn run_stage(stage: &mut SystemStage, world: &mut World, resources: &mut Resources) {
// !!NB!! Uncomment next line when running with old executor.
//stage.initialize(world, resources);
stage.run(world, resources);
fn run_stage(stage: &mut SystemStage, world: &mut World) {
stage.run(world);
}
cart marked this conversation as resolved.
Show resolved Hide resolved

struct A(f32);
Expand All @@ -20,7 +22,6 @@ const ENTITY_BUNCH: usize = 5000;

fn empty_systems(criterion: &mut Criterion) {
let mut world = World::new();
let mut resources = Resources::default();
let mut group = criterion.benchmark_group("empty_systems");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(3));
Expand All @@ -30,10 +31,10 @@ fn empty_systems(criterion: &mut Criterion) {
for _ in 0..amount {
stage.add_system(empty.system());
}
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
bencher.iter(|| {
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
});
});
}
Expand All @@ -47,10 +48,10 @@ fn empty_systems(criterion: &mut Criterion) {
.add_system(empty.system())
.add_system(empty.system());
}
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
bencher.iter(|| {
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
});
});
}
Expand All @@ -59,22 +60,21 @@ fn empty_systems(criterion: &mut Criterion) {

fn busy_systems(criterion: &mut Criterion) {
fn ab(mut q: Query<(&mut A, &mut B)>) {
for (mut a, mut b) in q.iter_mut() {
q.for_each_mut(|(mut a, mut b)| {
std::mem::swap(&mut a.0, &mut b.0);
}
});
}
fn cd(mut q: Query<(&mut C, &mut D)>) {
for (mut c, mut d) in q.iter_mut() {
q.for_each_mut(|(mut c, mut d)| {
std::mem::swap(&mut c.0, &mut d.0);
}
});
}
fn ce(mut q: Query<(&mut C, &mut E)>) {
for (mut c, mut e) in q.iter_mut() {
q.for_each_mut(|(mut c, mut e)| {
std::mem::swap(&mut c.0, &mut e.0);
}
});
}
let mut world = World::new();
let mut resources = Resources::default();
let mut group = criterion.benchmark_group("busy_systems");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(3));
Expand All @@ -95,7 +95,7 @@ fn busy_systems(criterion: &mut Criterion) {
.add_system(cd.system())
.add_system(ce.system());
}
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
group.bench_function(
&format!(
"{:02}x_entities_{:02}_systems",
Expand All @@ -104,7 +104,7 @@ fn busy_systems(criterion: &mut Criterion) {
),
|bencher| {
bencher.iter(|| {
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
});
},
);
Expand All @@ -115,25 +115,24 @@ fn busy_systems(criterion: &mut Criterion) {

fn contrived(criterion: &mut Criterion) {
fn s_0(mut q_0: Query<(&mut A, &mut B)>) {
for (mut c_0, mut c_1) in q_0.iter_mut() {
q_0.for_each_mut(|(mut c_0, mut c_1)| {
std::mem::swap(&mut c_0.0, &mut c_1.0);
}
});
}
fn s_1(mut q_0: Query<(&mut A, &mut C)>, mut q_1: Query<(&mut B, &mut D)>) {
for (mut c_0, mut c_1) in q_0.iter_mut() {
q_0.for_each_mut(|(mut c_0, mut c_1)| {
std::mem::swap(&mut c_0.0, &mut c_1.0);
}
for (mut c_0, mut c_1) in q_1.iter_mut() {
});
q_1.for_each_mut(|(mut c_0, mut c_1)| {
std::mem::swap(&mut c_0.0, &mut c_1.0);
}
});
}
fn s_2(mut q_0: Query<(&mut C, &mut D)>) {
for (mut c_0, mut c_1) in q_0.iter_mut() {
q_0.for_each_mut(|(mut c_0, mut c_1)| {
std::mem::swap(&mut c_0.0, &mut c_1.0);
}
});
}
let mut world = World::new();
let mut resources = Resources::default();
let mut group = criterion.benchmark_group("contrived");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(3));
Expand All @@ -153,7 +152,7 @@ fn contrived(criterion: &mut Criterion) {
.add_system(s_1.system())
.add_system(s_2.system());
}
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
group.bench_function(
&format!(
"{:02}x_entities_{:02}_systems",
Expand All @@ -162,7 +161,7 @@ fn contrived(criterion: &mut Criterion) {
),
|bencher| {
bencher.iter(|| {
run_stage(&mut stage, &mut world, &mut resources);
run_stage(&mut stage, &mut world);
});
},
);
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_tasks/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ where
}

fn bench_overhead(c: &mut Criterion) {
fn noop(_: &mut usize) {};
fn noop(_: &mut usize) {}

let mut v = (0..10000).collect::<Vec<usize>>();
c.bench_function("overhead_iter", |b| {
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ keywords = ["bevy"]

[features]
trace = []
default = ["bevy_reflect"]

[dependencies]
# bevy
bevy_derive = { path = "../bevy_derive", version = "0.4.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.4.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.4.0", optional = true }
bevy_utils = { path = "../bevy_utils", version = "0.4.0" }

# other
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::app_builder::AppBuilder;
use bevy_ecs::{Resources, Schedule, Stage, World};
use bevy_ecs::{
schedule::{Schedule, Stage},
world::World,
};
#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;

Expand Down Expand Up @@ -27,7 +30,6 @@ use bevy_utils::tracing::info_span;
/// ```
pub struct App {
pub world: World,
pub resources: Resources,
pub runner: Box<dyn Fn(App)>,
pub schedule: Schedule,
}
Expand All @@ -36,7 +38,6 @@ impl Default for App {
fn default() -> Self {
Self {
world: Default::default(),
resources: Default::default(),
schedule: Default::default(),
runner: Box::new(run_once),
}
Expand All @@ -53,7 +54,7 @@ impl App {
}

pub fn update(&mut self) {
self.schedule.run(&mut self.world, &mut self.resources);
self.schedule.run(&mut self.world);
}

pub fn run(mut self) {
Expand Down
Loading