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

Setup PhysicsSchedule and SubstepSchedule to use single-threaded executor #92

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

LeshaInc
Copy link
Contributor

By default schedules use multi-threaded executor, but since all systems are chained together and run one after another, using the multi-threaded executor is pointless and adds overhead.

This improves performance in benchmarks by between 12% and 50%:

3x3 cubes, 30 steps:
image

5x5 cubes, 30 steps:
image

10x10 cubes, 30 steps:
image

The relative speedup is smaller with more cubes, since task overhead is static.

In the future, systems should be internally parallelized (probably using rayon), so using the single threaded executor will free other threads for performing parallel work.

@Jondolf Jondolf added C-Enhancement New feature or request C-Performance Improvements or questions related to performance A-Scheduling Relates to scheduling or system sets labels Jul 20, 2023
@Jondolf
Copy link
Owner

Jondolf commented Jul 20, 2023

Thanks, this definitely seems like a pretty substantial decrease in overhead. I appreciate the benchmarks!

To be clear, not all systems are chained together and some of the chaining could maybe be removed, but these are mostly very cheap systems, so having them run in parallel is probably not worth the overhead.

Collision detection and the solver should definitely be parallelized in the future. For the solver, we would probably need to form some kind of constraint graph and use e.g. red-black graph coloring to find partitions that can be run in parallel. That's a problem for the future though, and it will probably require quite a bit of work and research

@Jondolf Jondolf merged commit 66d112f into Jondolf:main Jul 20, 2023
3 checks passed
DanielHZhang pushed a commit to DanielHZhang/bevy_xpbd that referenced this pull request Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scheduling Relates to scheduling or system sets C-Enhancement New feature or request C-Performance Improvements or questions related to performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants