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

50 Allow systems to access components from multiple entities at once #83

Merged
merged 7 commits into from
Apr 3, 2023

Conversation

EdvinNilsson
Copy link
Collaborator

This pull request adds the Query system parameter that allows a system to access components from entities other than the currently iterated. Query implements IntoIterator and it can be used to iterate over queried entities. Here is an example how Query can be used:

fn system(query: Query<(Read<A>, Read<B>)>) {
    for (a, b) in query {

    }
}

Closes #50

@github-actions
Copy link

Benchmark for 80d5950

Click to view benchmark
Test Base PR %
sleep 166.9±12.74µs 162.8±2.78µs -2.46%
sleep x/1 61.9±2.98µs 15.8 KElem/sec N/A N/A
sleep x/2 66.7±4.93µs 29.3 KElem/sec N/A N/A
sleep x/3 65.7±2.57µs 44.6 KElem/sec N/A N/A
sleep x/4 65.5±2.33µs 59.6 KElem/sec N/A N/A
sleep x/5 70.7±14.07µs 69.1 KElem/sec N/A N/A
sleep x/6 66.9±2.84µs 87.5 KElem/sec N/A N/A
sleep x/7 69.5±3.71µs 98.4 KElem/sec N/A N/A
sleep x/8 72.6±7.49µs 107.6 KElem/sec N/A N/A
sleep x/9 71.2±2.02µs 123.4 KElem/sec N/A N/A

Copy link
Owner

@martinjonsson01 martinjonsson01 left a comment

Choose a reason for hiding this comment

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

LGTM! Nicely done.

crates/ecs/src/systems/mod.rs Outdated Show resolved Hide resolved
crates/ecs/src/systems/mod.rs Show resolved Hide resolved
crates/ecs/src/systems/mod.rs Outdated Show resolved Hide resolved
Co-authored-by: Martin <martinjonsson01@gmail.com>
@github-actions
Copy link

Benchmark for 4e5460e

Click to view benchmark
Test Base PR %
sleep 167.3±7.91µs 170.1±11.48µs +1.67%
sleep x/1 67.1±7.54µs 14.6 KElem/sec N/A N/A
sleep x/2 66.9±5.89µs 29.2 KElem/sec N/A N/A
sleep x/3 71.0±6.70µs 41.3 KElem/sec N/A N/A
sleep x/4 72.7±12.38µs 53.7 KElem/sec N/A N/A
sleep x/5 71.7±7.86µs 68.1 KElem/sec N/A N/A
sleep x/6 71.6±5.02µs 81.9 KElem/sec N/A N/A
sleep x/7 73.0±9.73µs 93.7 KElem/sec N/A N/A
sleep x/8 75.4±10.33µs 103.6 KElem/sec N/A N/A
sleep x/9 75.8±12.30µs 115.9 KElem/sec N/A N/A

Copy link
Collaborator

@ChristofferPerssons ChristofferPerssons left a comment

Choose a reason for hiding this comment

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

Looks good!

Quite interested in how performance of a system is affected when intra-system parallelization is disallowed and whether or not it would be more performant and possible to bypass this by uses of commands that add component flags to specific entities instead.

@github-actions
Copy link

github-actions bot commented Apr 1, 2023

Benchmark for 148ffb6

Click to view benchmark
Test Base PR %
sleep 158.8±2.02µs 158.8±1.19µs 0.00%
sleep x/1 59.6±0.89µs 16.4 KElem/sec N/A N/A
sleep x/2 60.6±0.88µs 32.2 KElem/sec N/A N/A
sleep x/3 61.7±0.88µs 47.5 KElem/sec N/A N/A
sleep x/4 62.7±1.39µs 62.3 KElem/sec N/A N/A
sleep x/5 63.7±1.38µs 76.7 KElem/sec N/A N/A
sleep x/6 64.9±0.79µs 90.3 KElem/sec N/A N/A
sleep x/7 65.9±1.41µs 103.8 KElem/sec N/A N/A
sleep x/8 66.8±1.15µs 117.0 KElem/sec N/A N/A
sleep x/9 67.6±0.81µs 129.9 KElem/sec N/A N/A

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

Benchmark for 734b3d2

Click to view benchmark
Test Base PR %
sleep 162.9±4.58µs 166.6±7.48µs +2.27%
sleep x/1 62.6±2.53µs 15.6 KElem/sec N/A N/A
sleep x/2 65.5±4.50µs 29.8 KElem/sec N/A N/A
sleep x/3 65.2±3.79µs 44.9 KElem/sec N/A N/A
sleep x/4 66.7±2.32µs 58.5 KElem/sec N/A N/A
sleep x/5 68.2±3.55µs 71.6 KElem/sec N/A N/A
sleep x/6 71.4±4.35µs 82.0 KElem/sec N/A N/A
sleep x/7 70.7±6.70µs 96.7 KElem/sec N/A N/A
sleep x/8 70.2±3.30µs 111.2 KElem/sec N/A N/A
sleep x/9 72.3±4.19µs 121.6 KElem/sec N/A N/A

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

Benchmark for bdc7d03

Click to view benchmark
Test Base PR %
sleep 159.0±0.99µs 159.4±2.65µs +0.25%
sleep x/1 59.5±0.56µs 16.4 KElem/sec N/A N/A
sleep x/2 61.9±3.13µs 31.5 KElem/sec N/A N/A
sleep x/3 61.8±1.38µs 47.4 KElem/sec N/A N/A
sleep x/4 62.8±1.94µs 62.2 KElem/sec N/A N/A
sleep x/5 65.2±3.74µs 74.9 KElem/sec N/A N/A
sleep x/6 64.8±1.26µs 90.5 KElem/sec N/A N/A
sleep x/7 66.0±1.95µs 103.6 KElem/sec N/A N/A
sleep x/8 67.0±2.15µs 116.6 KElem/sec N/A N/A
sleep x/9 69.2±4.43µs 127.0 KElem/sec N/A N/A

@github-actions
Copy link

github-actions bot commented Apr 3, 2023

Benchmark for 44f8852

Click to view benchmark
Test Base PR %
sleep 161.5±3.87µs 158.8±0.77µs -1.67%
sleep x/1 59.6±1.04µs 16.4 KElem/sec N/A N/A
sleep x/2 61.4±2.98µs 31.8 KElem/sec N/A N/A
sleep x/3 63.1±3.38µs 46.4 KElem/sec N/A N/A
sleep x/4 62.6±1.77µs 62.4 KElem/sec N/A N/A
sleep x/5 63.5±1.30µs 76.9 KElem/sec N/A N/A
sleep x/6 64.4±1.55µs 90.9 KElem/sec N/A N/A
sleep x/7 66.5±1.96µs 102.9 KElem/sec N/A N/A
sleep x/8 68.1±2.91µs 114.7 KElem/sec N/A N/A
sleep x/9 67.5±1.09µs 130.3 KElem/sec N/A N/A

@EdvinNilsson EdvinNilsson merged commit 675b7ea into master Apr 3, 2023
@EdvinNilsson EdvinNilsson deleted the 50-foreign-entity-access branch April 3, 2023 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow systems to access components from multiple entities at once
3 participants