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

Make subapps run in parallel with main app #9045

Open
PhaestusFox opened this issue Jul 5, 2023 · 1 comment
Open

Make subapps run in parallel with main app #9045

PhaestusFox opened this issue Jul 5, 2023 · 1 comment
Labels
A-App Bevy apps and plugins C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@PhaestusFox
Copy link

What problem does this solve or what need does it fill?

I was making a video about sub-apps as I thought they would be useful if someone wanted to brake a game up into differently controlled worlds (eg no hostile pathfinding systems in the sub-app and just swap the app and sub-app worlds when the player "moves" between them), but while I was doing some testing and reading the code I found that the sub-apps are run consecutively rather than in parallel, this undermines what I thought would be the biggest selling point of sub-app, they all have independent worlds and schedules so don't have to worry about conflicting systems with mutable access allowing for maximum concurrency. I know the render sub-app runs in parallel to the main app but I don't know enough about how it does this to make suggestions on how this could be replicated in other sub-apps. this would also pair well with #6700 allowing you to basically create a sup-app say a self-contained mini-dungeon like a scene, but unlike a scene, these two worlds don't have to worry about conflicting with each other since they don't share the same world and can therefore have there own self contained resources and states.

What solution would you like?

I would like to see sub-apps run their extract function consecutively and then all run updates in parallel rather than currently running one at a time (extract, extract, ext... parallel update) vs (extract, update, extract, update, ext, ext...)

What alternative(s) have you considered?

move sub-apps out of the App struct and into a resource inside the world, this also fixes #6700 since you could access the resource inside systems and change it. this may not be possible as I don't know why the sub-apps have a dedicated place in the main app, would make some sense if they run in parallel since then the app doesn't need world access to run them but schedulers found a way around this by removing them self from the world then running

Leaving it up to the community to make third-party plugins to achieve the same result, probably thou a resource containing worlds and schedulers and an exclusive system.

@PhaestusFox PhaestusFox added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jul 5, 2023
@Selene-Amanita Selene-Amanita added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-App Bevy apps and plugins and removed S-Needs-Triage This issue needs to be labelled C-Feature A new feature, making something new possible labels Jul 5, 2023
@starwolfy
Copy link

This would be helpful. My sub app can become relatively intense as it is used for netcode physics corrections which involves rollback and it can become CPU intensive.
To get parallel Worlds to calculate in Bevy you can also use Thread and ditch SubApp entirely with mpsc messages they can run in parallel and sync data together. However having two main Bevy threads as they're separated seems like a potential source of CPU inefficiencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

3 participants