-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Synchronized component registration #17569
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
ElliottjPierce
wants to merge
50
commits into
bevyengine:main
from
ElliottjPierce:synchronized-component-registration
Closed
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
54d411d
outlined structure
ElliottjPierce 8112810
removed storages from registration
ElliottjPierce 6761337
re-archetected synchronization
ElliottjPierce 41b243c
sorted out registering
ElliottjPierce 98ba5c3
consolidated components together
ElliottjPierce d5232d1
gets component info
ElliottjPierce 0bd939e
some mutable gets
ElliottjPierce d009642
repaired some signatures
ElliottjPierce 49ee1dc
component interface MVP
ElliottjPierce 0c04a57
cleaned up most usages
ElliottjPierce 788b61d
components are cleaned
ElliottjPierce 9cc0537
cleaned up implementation
ElliottjPierce 578491a
re-aranged for convinience
ElliottjPierce 139eedb
re-organized to use previous implementations where possible
ElliottjPierce 4d9fb2b
use trait interface
ElliottjPierce 070e629
fixed most errors
ElliottjPierce bc8cbbb
redid required components read interface
ElliottjPierce 0fb4071
replace instead of merge.
ElliottjPierce e3c8833
inlined some functions
ElliottjPierce e37011f
final utils
ElliottjPierce 58f7443
reserve space before spawning
ElliottjPierce 9f8fe6f
no panics on missing set
ElliottjPierce ac6ce01
fixed docs
ElliottjPierce b6845bd
keep a changed flag.
ElliottjPierce 3dd2b32
fixed no_std
ElliottjPierce 4f86c9b
fixed more docs
ElliottjPierce f7e07e4
add mut and ref for components
ElliottjPierce 22ea546
split the trait into ref and mut variants
ElliottjPierce 12a9a5d
separated ComponentsView again for refs
ElliottjPierce 924ae2b
implemented these traits for Components
ElliottjPierce e46d267
cleaned up imports
ElliottjPierce 2693a23
fixed final error
ElliottjPierce 55c918a
forward common synced methods through world
ElliottjPierce 69e68b1
fixed docs
ElliottjPierce 95713a6
Merge branch 'main' into synchronized-component-registration
ElliottjPierce 3303567
added basic benchmarks
ElliottjPierce dcbecd3
amended benchmarks
ElliottjPierce 5383023
added read locks
ElliottjPierce 99d020e
ComponentsVew can see required components
ElliottjPierce e359432
removed old required components ref
ElliottjPierce 6bf934e
don't clone required by when staging changes
ElliottjPierce ca03214
don't clone required components for staging
ElliottjPierce c8bed70
bit of polish
ElliottjPierce 00ed24c
Merge branch 'main' into synchronized-component-registration
ElliottjPierce aa1af43
fixed docs
ElliottjPierce 7934879
quick rename
ElliottjPierce 4242865
renamed is_new to is_staged
ElliottjPierce fe58464
Merge branch 'main' into synchronized-component-registration
ElliottjPierce c57a570
Merge branch 'main' into synchronized-component-registration
ElliottjPierce 3993bc5
Apply suggestions from code review
ElliottjPierce 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,224 @@ | ||
use core::hint::black_box; | ||
|
||
use bevy_ecs::component::{require, Component, Components, ComponentsData, ComponentsView}; | ||
use criterion::Criterion; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA0; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA1; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA2; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA3; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA4; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA5; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA6; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA7; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA8; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentA9; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA2)] | ||
struct ComponentB0; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA3, ComponentA7)] | ||
struct ComponentB1; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA2)] | ||
struct ComponentB2; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA1)] | ||
struct ComponentB3; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA1)] | ||
struct ComponentB4; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA1, ComponentA8, ComponentA4)] | ||
struct ComponentB5; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentA0, ComponentA1, ComponentA6)] | ||
struct ComponentB6; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentB7; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentB8; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentB9; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentC0; | ||
|
||
#[derive(Component, Default)] | ||
struct ComponentC1; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1)] | ||
struct ComponentC2; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1)] | ||
struct ComponentC3; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB2, ComponentB3, ComponentB4)] | ||
struct ComponentC4; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB2, ComponentB4)] | ||
struct ComponentC5; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB9, ComponentB3)] | ||
struct ComponentC6; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB8, ComponentB4)] | ||
struct ComponentC7; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB2, ComponentB6)] | ||
struct ComponentC8; | ||
|
||
#[derive(Component, Default)] | ||
#[require(ComponentB1, ComponentB5, ComponentB8)] | ||
struct ComponentC9; | ||
|
||
fn register_direct(components: &mut impl ComponentsView) { | ||
components.register_component::<ComponentA0>(); | ||
components.register_component::<ComponentA1>(); | ||
components.register_component::<ComponentA2>(); | ||
components.register_component::<ComponentA3>(); | ||
components.register_component::<ComponentA4>(); | ||
components.register_component::<ComponentA5>(); | ||
components.register_component::<ComponentA6>(); | ||
components.register_component::<ComponentA7>(); | ||
components.register_component::<ComponentA8>(); | ||
components.register_component::<ComponentA9>(); | ||
components.register_component::<ComponentB0>(); | ||
components.register_component::<ComponentB1>(); | ||
components.register_component::<ComponentB2>(); | ||
components.register_component::<ComponentB3>(); | ||
components.register_component::<ComponentB4>(); | ||
components.register_component::<ComponentB5>(); | ||
components.register_component::<ComponentB6>(); | ||
components.register_component::<ComponentB7>(); | ||
components.register_component::<ComponentB8>(); | ||
components.register_component::<ComponentB9>(); | ||
components.register_component::<ComponentC0>(); | ||
components.register_component::<ComponentC1>(); | ||
components.register_component::<ComponentC2>(); | ||
components.register_component::<ComponentC3>(); | ||
components.register_component::<ComponentC4>(); | ||
components.register_component::<ComponentC5>(); | ||
components.register_component::<ComponentC6>(); | ||
components.register_component::<ComponentC7>(); | ||
components.register_component::<ComponentC8>(); | ||
components.register_component::<ComponentC9>(); | ||
} | ||
|
||
fn register_synced(components: &Components) { | ||
components.register_component_synced::<ComponentA0>(); | ||
components.register_component_synced::<ComponentA1>(); | ||
components.register_component_synced::<ComponentA2>(); | ||
components.register_component_synced::<ComponentA3>(); | ||
components.register_component_synced::<ComponentA4>(); | ||
components.register_component_synced::<ComponentA5>(); | ||
components.register_component_synced::<ComponentA6>(); | ||
components.register_component_synced::<ComponentA7>(); | ||
components.register_component_synced::<ComponentA8>(); | ||
components.register_component_synced::<ComponentA9>(); | ||
components.register_component_synced::<ComponentB0>(); | ||
components.register_component_synced::<ComponentB1>(); | ||
components.register_component_synced::<ComponentB2>(); | ||
components.register_component_synced::<ComponentB3>(); | ||
components.register_component_synced::<ComponentB4>(); | ||
components.register_component_synced::<ComponentB5>(); | ||
components.register_component_synced::<ComponentB6>(); | ||
components.register_component_synced::<ComponentB7>(); | ||
components.register_component_synced::<ComponentB8>(); | ||
components.register_component_synced::<ComponentB9>(); | ||
components.register_component_synced::<ComponentC0>(); | ||
components.register_component_synced::<ComponentC1>(); | ||
components.register_component_synced::<ComponentC2>(); | ||
components.register_component_synced::<ComponentC3>(); | ||
components.register_component_synced::<ComponentC4>(); | ||
components.register_component_synced::<ComponentC5>(); | ||
components.register_component_synced::<ComponentC6>(); | ||
components.register_component_synced::<ComponentC7>(); | ||
components.register_component_synced::<ComponentC8>(); | ||
components.register_component_synced::<ComponentC9>(); | ||
} | ||
|
||
pub fn bench(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("registration"); | ||
group.warm_up_time(core::time::Duration::from_millis(500)); | ||
group.measurement_time(core::time::Duration::from_secs(4)); | ||
group.bench_function("raw", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(ComponentsData::default()); | ||
register_direct(&mut components); | ||
}); | ||
}); | ||
group.bench_function("mut", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(Components::default()); | ||
register_direct(&mut components.as_mut()); | ||
components.clean(); | ||
}); | ||
}); | ||
group.bench_function("locked", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(Components::default()); | ||
register_direct(&mut components.lock()); | ||
components.clean(); | ||
}); | ||
}); | ||
group.bench_function("full", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(Components::default()); | ||
register_direct(&mut components); | ||
components.clean(); | ||
}); | ||
}); | ||
group.bench_function("full_staged", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(Components::default()); | ||
components.register_component_synced::<ComponentA0>(); // to trigger a staged change | ||
register_direct(&mut components); | ||
components.clean(); | ||
}); | ||
}); | ||
group.bench_function("synced", |b| { | ||
b.iter(move || { | ||
let mut components = black_box(Components::default()); | ||
register_synced(&components); | ||
components.clean(); | ||
}); | ||
}); | ||
group.finish(); | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.