bevyengine / bevyengine/bevy

Maximize distance between exclusive systems

Open
#12,153 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Performance
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?
After #11845, `handle_internal_asset_events`, an exclusive system, was moved to `PreUpdate`, however, due to it's ordering constraint, all of the `TrackAssets` events cannot start until it's done. However, the exclusive system conflicts with every other system that is topologically sorted before it, so it can't start until all of them are finished. Even though there is no strict ordering constraint between the exclusive system and the systems running before it, it will prevent these two groups of systems from running in parallel with each other, which may have a performance cost.

![image](https://github.com/bevyengine/bevy/assets/3137680/cf921f5d-c446-4f38-9a83-b9b37e1dba1e)

## What solution would you like?
Change the topological sort on a schedule's system to maximize the number of systems that can parallelize together by forcing exclusive systems apart as much as possible.

This was already done for `apply_deferred`, perhaps the same logic can be applied to other exclusive systems as well?

## What alternative(s) have you considered?
Leaving it as is.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.