Skip to content

Inline "small" systems into the multithreaded executor#7693

Closed
james7132 wants to merge 1 commit intobevyengine:mainfrom
james7132:inline-small-systems
Closed

Inline "small" systems into the multithreaded executor#7693
james7132 wants to merge 1 commit intobevyengine:mainfrom
james7132:inline-small-systems

Conversation

@james7132
Copy link
Member

Objective

Minimize overhead from scheduling large numbers of systems with very little work to do. Partially address #7208.

Solution

Keep a exponential moving average for how long it takes to run each system. If a system has historically run in under 2 microseconds, run it inside the multithreaded executor.

The threshold is currently hard-coded and is rather conservative to avoid potentially inlining too many systems and forcing it large sections to run single threaded.

TODO:

  • Defer inline execution until all non-inlinable system tasks are spawned to avoid blocking
  • Add an escape hatch for cases where systems have highly kurtotic behavior.

Performance

TODO

@james7132 james7132 added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times labels Feb 16, 2023
@alice-i-cecile alice-i-cecile added the X-Needs-SME This type of work requires an SME to approve it. label Feb 16, 2023
@james7132
Copy link
Member Author

With #11906 now running the multithreaded executor immediately after every system, we can achieve similar results without needing to inline the systems. I've also come to realize that running systems inline is likely an all around bad practice given that it potentially blocks starting new systems even without a strict before/after relationship, and that's a huge risk in any cooperative task scheduler. Closing this out.

@james7132 james7132 closed this Mar 30, 2024
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-Performance A change motivated by improving speed, memory usage or compile times X-Needs-SME This type of work requires an SME to approve it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants