RecastGraph Bake

Hi
I just noticed the following performance issues during debugging:

I understand the purpose of the tilesPerJob parameter, but I still don’t understand what this piece of code does:

var dep = new JobHandle();
for (int j = 0; j < jobSteps; j++) {
    dep = jobTemplate.Schedule(dep);
}
dependencies = JobHandle.CombineDependencies(dependencies, dep);

Can’t we just replace it with something like this?

dependencies = JobHandle.CombineDependencies(dependencies, jobTemplate.Schedule());
  • A* version: [5.0.4]
  • Unity version: [enter version here]

Hi

To avoid starving other jobs that may want to be run, each worker only does a small-ish bit of work each step. That’s why we schedule the same job multiple times after each other.

Thanks
There’s one thing I’d like to confirm.
Does “other jobs” here refer to the baking tasks of other graphs, or the other tileBuilders of the current graph?
Does “a small-ish bit of work” refer to the tileBuilder, or other job tasks?
Do you have any good suggestions for this issue?
Thanks Again!

Other jobs means anything else unity might want to do.

This is particularly important when doing an async scan, as the rest of the game needs to continue running.
If the recast graph scan was using all unity’s worker threads for multiple seconds, the rest of the game wouldn’t be particularly happy.

1 Like