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

Performance enhancement to component addition/removal #3

Closed
wants to merge 2 commits into from

Conversation

adlarkin
Copy link
Owner

@adlarkin adlarkin commented May 11, 2021

I'm using an "ignore" flag for components to help keep track of valid/invalid entity <-> component tuple data in views so that adding components and updating views doesn't take as long

@adlarkin adlarkin force-pushed the remove_component_v2 branch from 1d71bcb to 285a187 Compare May 11, 2021 02:30
@adlarkin
Copy link
Owner Author

adlarkin commented May 11, 2021

Test results

All tests are done with 5000 initially created entities (10 components per entity).

Using the approach in this PR

adding/removing a component from 5000 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
36.3065 ms
1.49101 ms
1.41873 ms

Removing a component from 5000 entities: 12.1498 ms
Each(...): 0.001793 ms
Adding a component to 5000 entities: 10.8932 ms
Each(...): 1.58831 ms
Removing a component from 5000 entities: 11.488 ms
Each(...): 0.001062 ms
Adding a component to 5000 entities: 10.6213 ms
Each(...): 1.55036 ms
Removing a component from 5000 entities: 11.7511 ms
Each(...): 0.001092 ms
Adding a component to 5000 entities: 10.7517 ms
Each(...): 1.56957 ms
adding/removing a component from 2500 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
36.6814 ms
1.67233 ms
1.62286 ms

Removing a component from 2500 entities: 5.7999 ms
Each(...): 0.804949 ms
Adding a component to 2500 entities: 5.3506 ms
Each(...): 1.61504 ms
Removing a component from 2500 entities: 5.43221 ms
Each(...): 0.79517 ms
Adding a component to 2500 entities: 5.1949 ms
Each(...): 1.60387 ms
Removing a component from 2500 entities: 5.42225 ms
Each(...): 0.809498 ms
Adding a component to 2500 entities: 5.114 ms
Each(...): 1.627 ms

Using the approach in PR #2

adding/removing a component from 5000 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
32.2436 ms
2.02792 ms
2.04356 ms

Removing a component from 5000 entities: 7.7292 ms
Each(...): 0.186444 ms
Adding a component to 5000 entities: 12.6264 ms
Each(...): 23.83 ms
Removing a component from 5000 entities: 6.23013 ms
Each(...): 0.205129 ms
Adding a component to 5000 entities: 12.9046 ms
Each(...): 23.7412 ms
Removing a component from 5000 entities: 6.54169 ms
Each(...): 0.222332 ms
Adding a component to 5000 entities: 12.9882 ms
Each(...): 23.6674 ms
adding/removing a component from 2500 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
29.8369 ms
1.93962 ms
1.99772 ms

Removing a component from 2500 entities: 3.80207 ms
Each(...): 1.09954 ms
Adding a component to 2500 entities: 6.24457 ms
Each(...): 12.1475 ms
Removing a component from 2500 entities: 3.1095 ms
Each(...): 1.11571 ms
Adding a component to 2500 entities: 6.1806 ms
Each(...): 12.1484 ms
Removing a component from 2500 entities: 3.04152 ms
Each(...): 1.12562 ms
Adding a component to 2500 entities: 6.14581 ms
Each(...): 12.2008 ms

Using ign-gazebo

adding/removing a component from 5000 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
25.6061 ms
16.2299 ms
16.1693 ms

Removing a component from 5000 entities: 283.637 ms
Each(...): 0.006502 ms
Adding a component to 5000 entities: 9.57608 ms
Each(...): 16.835 ms
Removing a component from 5000 entities: 280.793 ms
Each(...): 0.006652 ms
Adding a component to 5000 entities: 9.3002 ms
Each(...): 16.8664 ms
Removing a component from 5000 entities: 275.992 ms
Each(...): 0.0051 ms
Adding a component to 5000 entities: 9.32078 ms
Each(...): 16.8772 ms
adding/removing a component from 2500 entities
Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
24.5563 ms
15.7098 ms
15.6535 ms

Removing a component from 2500 entities: 215.569 ms
Each(...): 8.16513 ms
Adding a component to 2500 entities: 5.06104 ms
Each(...): 15.9749 ms
Removing a component from 2500 entities: 213.968 ms
Each(...): 8.09454 ms
Adding a component to 2500 entities: 4.89191 ms
Each(...): 15.8767 ms
Removing a component from 2500 entities: 213.77 ms
Each(...): 8.08845 ms
Adding a component to 2500 entities: 4.97967 ms
Each(...): 15.9555 ms

EnTT

adding/removing a component from 5000 entities
entt group implementation

Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
23.3246 ms
7.71712 ms
4.34767 ms

Removing a component from 5000 entities: 18.3849 ms
Each(...): 0.003086 ms
Adding a component to 5000 entities: 19.5877 ms
Each(...): 4.49723 ms
Removing a component from 5000 entities: 18.051 ms
Each(...): 0.003877 ms
Adding a component to 5000 entities: 19.7719 ms
Each(...): 4.43244 ms
Removing a component from 5000 entities: 18.0925 ms
Each(...): 0.004359 ms
Adding a component to 5000 entities: 19.6453 ms
Each(...): 4.48773 ms

-----

entt view implementation

Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
10.041 ms
10.1022 ms
10.0356 ms

Removing a component from 5000 entities: 1.5156 ms
Each(...): 0.001783 ms
Adding a component to 5000 entities: 1.36686 ms
Each(...): 10.0015 ms
Removing a component from 5000 entities: 1.50777 ms
Each(...): 0.002354 ms
Adding a component to 5000 entities: 1.35401 ms
Each(...): 9.91831 ms
Removing a component from 5000 entities: 1.49448 ms
Each(...): 0.001182 ms
Adding a component to 5000 entities: 1.34498 ms
Each(...): 9.94744 ms
adding/removing a component from 2500 entities
entt group implementation

Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
22.2671 ms
4.68461 ms
4.70994 ms

Removing a component from 2500 entities: 9.07347 ms
Each(...): 2.36124 ms
Adding a component to 2500 entities: 9.87231 ms
Each(...): 4.65461 ms
Removing a component from 2500 entities: 9.07685 ms
Each(...): 2.34463 ms
Adding a component to 2500 entities: 9.87278 ms
Each(...): 4.70128 ms
Removing a component from 2500 entities: 9.0728 ms
Each(...): 2.34198 ms
Adding a component to 2500 entities: 9.87492 ms
Each(...): 4.65911 ms

-----

entt view implementation

Calling Each(...) 3 times on 5000 created entities, with 10 components per entity
10.0808 ms
10.0578 ms
10.1144 ms

Removing a component from 2500 entities: 0.757409 ms
Each(...): 5.06985 ms
Adding a component to 2500 entities: 0.681234 ms
Each(...): 10.1062 ms
Removing a component from 2500 entities: 0.749514 ms
Each(...): 5.05669 ms
Adding a component to 2500 entities: 0.674832 ms
Each(...): 10.1238 ms
Removing a component from 2500 entities: 0.756757 ms
Each(...): 5.04981 ms
Adding a component to 2500 entities: 0.68405 ms
Each(...): 10.1009 ms

include/simpleECM/View.hh Outdated Show resolved Hide resolved
@adlarkin
Copy link
Owner Author

I'm closing this since the prototype proposed here has been implemented in gazebosim/gz-sim#856.

@adlarkin adlarkin closed this Jun 14, 2021
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.

2 participants