Replies: 3 comments 2 replies
-
How can you apply commands without exclusive world access though? |
Beta Was this translation helpful? Give feedback.
-
Yeah good point, I hadn't thought about that. I guess to make this happen, it would require us to introduce a concept of a plugin-specific sub-world containing entities exclusive to the given plugin and its own command buffer. It could work for some plugins but likely not for others and might not be worth the complexity. The reason I was thinking in that direction is actually not for commands accessing entities, but for commands inserting resources. I have a couple of startup systems that load assets and insert an asset catalog (e.g. a struct with lots of |
Beta Was this translation helpful? Give feedback.
-
Option 1 is discussed in #7838, and is something the ECS crew is interested in implementing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So it seems in bevy 0.10, the new way to handle systems that need to wait for another system's commands to be applied before running is to add a separate
apply_system_buffers
system and make sure they're ordered correctly.What are the performance implications of this? Afaik
apply_system_buffers
is an exclusive system, so we could end up with lots of different plugins in the same game, all scheduling their ownapply_system_buffers
, causing the game to have a frame with lots of exclusive systems scheduled and little parallelism.Actually, for this use case, each plugin could be separate and each plugin only cares about its own commands being applied, it doesn't care about applying commands from other plugins. Can we improve parallelism here?
A couple of options jumping to my mind:
Option 1: Automatically de-duplicate calls to
apply_system_buffers
.For example, users wouldn't manually add a
apply_system_buffers
system, but instead define the dependencies with something likewhich would run
other_system
first, then apply its buffers, and then runmy_system
.If there are multiple such dependencies, the scheduler can try to be smart and schedule them so that
other_system_1
andother_system_2
run first, in parallel, then there is just one de-duplicated call toapply_system_buffers
, and thenmy_system_1
andmy_system_2
run in parallel.Option 2: Separate command buffers
Each plugin could have their own commands buffer and then add a system that just applies their own commands in a system that isn't world exclusive but only locks the command buffer for that specific plugin. This would allow other plugins to run while a plugin is applying its commands.
Beta Was this translation helpful? Give feedback.
All reactions