Running fixed rate jobs parallel with non-fixed rate jobs.

I have an enemy type that is the primary thing that takes up CPU in the gameplay. I run their update in jobs in parallel with a lot of other stuff happening on the main thread, it works very well and it saves up to like 6 ms in extreme cases. But I would like to move it into a fixed update group to make more deterministic across the network clients. But I’m unsure how to approach the parallelism when it’s in a fixed rate group.

The stuff that is running parallell does not interact with the enemy in any way, and it should definitely not run in fixed rate. So ideally my CPU complex enemy would update every 1/30 ms and when it does, the other stuff runs in parallell, but on the frames that the enemy is not updated the other stuff would still execute, but by itself or maybe parallell with something else.

I don’t know really how to think about this issues. Maybe I should just roll my own time based update guard for the enemy update?

Any thoughts on this?

I’m having trouble understanding the issue, so let’s say you just do this:

  • In a FixedStepSimGroup system, schedule your fixed step jobs
  • In a regular SimGroup system, schedule your variable step jobs

Would there be problems with that approach?

Jobs scheduled from a fixed step system will simply be scheduled X times alongside other jobs in the regular update (where X is the amount of fixed updates needed to catch up), so normally it’s something you don’t really have to think about. If your variable step jobs depend on fixed step jobs, they’ll execute after. If they don’t; they’ll execute at the same time in parallel

In all cases, the job scheduler will just figure out how to organize all those jobs in the correct order over the available threads. Unless you deal with native collections in your jobs; in which case you’ll have to do a bit of manual dependency handling, but it’s the same handling you’d do between 2 variable step jobs using collections

1 Like

Yeah… You are right, that should work fine. Maybe I’m actually not understaning my problem here or making it more complicated than it needs to. Although I have it setup with an EntityCommandBufferSystem that ends the update of my enemy as well as everything that I update parallell with it. It’s just like the SimulationSystemGroup with EndSimulationEntityCommandBufferSystem, just mine is nested inside that. So I think my confusion is having a syncpoint in EntityCommandBufferSystem complete the jobs started from a system that is not inside the same SystemGroup.

I will investigate this further, hopefully it’s as straight forward as you pointed out it should be.