Is it possible to update two or more worlds in parallel? ie: Have the world update be 100% jobified such that multiple world updates could be scheduled at the same time?
That is the default behavior.
Oh intersting! What conditions do you need to meet for this to be the case? For example, reading the documentation on SystemBase, it says that OnUpdate is called on the main thread, does that mean SystemBase would need to be avoided?
All system’s update, in all world, needs to run in mainthread. Jobs are scheduled on worker threads.
DOTS’s parallel happen in the job level, not system update level.
In other words, all worlds’s systems’s scheduled jobs run in parallel. One world’s job can depend on another world’s job to fninsh.
Ok that’s great to know. Does this also still apply when manually updating a world through World.Update? What actually triggers the Complete() of system jobs?
Does this also still apply when manually updating a world through World.Update?
Yes, and it must be in mainthread.
What actually triggers the Complete() of system jobs?
Syncpoint completes related component type’s job dependency, this is managed by ECS.
And your own job working with or without your own native collections dose not trigger Complete() unless you do it.
Follow up question / confirmation. It seems like by default any structural changes are going to be automatically completed at the end of the system update on the main thread, preventing two worlds from updating in parallel. I notice that when i call world.Update() the entire system and jobs execute and complete before my call to Update() finishes. In the presence of structural changes, would it be accurate to say that a more elaborate management would be needed?
Pseudocode here:
world1.Update(); //kick off world update but do not complete!
world2.Update();
//world1 *and* world2 updates should both be in flight here
FinishUpdate(world1); //for end-of-frame structural changes??
FinishUpdate(world2);
@Lieene-Guo Are you certain that one world’s job can depend on another world’s job? I had the understanding that each dependency graph was isolated to the world and that they were traversed and scheduled independently. That made it necessary to sync both worlds at some point in your frame if you wished to share data between or synchronization between them. If I am wrong I would be very happy to be wrong and would love to know. Thanks!
JobHandle is irrelevant to ECS package and World. You can schedule your job with any dependency. one world’s job depending on some other world’s jobHandle is just a matter of how you access them.
@Lieene-Guo That does indeed make sense and seems more fundamentally-correct. I am glad to confirm this as I was quite annoyed when I thought I learned the dependency graphs were independent.