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

Cleanup the multithreaded executor #12969

Merged

Conversation

james7132
Copy link
Member

@james7132 james7132 commented Apr 15, 2024

Objective

Improve the code quality of the multithreaded executor.

Solution

  • Remove some unused variables.
  • Use Mutex::get_mut where applicable instead of locking.
  • Use a startup_systems FixedBitset to pre-compute the starting systems instead of building it bit-by-bit on startup.
  • Instead of using FixedBitset::clear and FixedBitset::union_with, use FixedBitset::clone_from instead, which does only a single copy and will not allocate if the target bitset has a large enough allocation.
  • Replace the Mutex around Conditions with SyncUnsafeCell, and add a Context::try_lock that forces it to be synchronized fetched alongside the executor lock.

This might produce minimal performance gains, but the focus here is on the code quality improvements.

@james7132 james7132 added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change labels Apr 15, 2024
@james7132 james7132 requested a review from maniwani April 15, 2024 01:16
@alice-i-cecile alice-i-cecile requested a review from hymm April 15, 2024 19:12
Copy link
Contributor

@hymm hymm left a comment

Choose a reason for hiding this comment

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

changes are pretty straightforward

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 16, 2024
Merged via the queue into bevyengine:main with commit 9dde99f Apr 16, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants