Job system - Different results in speed

I’ve got a question concerning job system and burst system.
I made a hierarchical pathfinding algorithm (tilebased) with just an empty test map (only a few obstachles). I use the same start and target tiles, same obstachles, and same mapsize every time.
I feel like testing it over and over again without changing anything. I measure the time that the job system needs to complete the tasks.
What I noticed is, that I get different results from time to time. Sometimes pre-calculating about 300.000 short paths takes 250ms. I get this result over and over again. After taking a short break (watching youtube for a few minutes or something like this) this exact same task with exact the same parameters take 9700ms. I retryed several times and it takes 9700 ms. I changed NOTHING but this is a complete different result in speed. Trying at a later point of time it is 250ms again.

Is unity job / burst system caching the results or what can cause these different results?

Here is an example of what I’m observing:

Any idea?

Hi @crazyguy90 - please could you check in the Jobs > Burst menu, do you have “Synchronous Compilation” checked or unchecked? If it’s unchecked, then you could see this kind of behaviour, because Unity will use the Mono version of the method until the Burst version is available, which can take a few milliseconds. If “Synchronous Compilation” is checked, then the Burst version will be used immediately.

2 Likes

@tim_jones - Thanks for your reply. It was indeed unchecked. Now with the checked option there is much less variation. But still I’m getting highly different results from time to time. I wonder if it’s possible to test efficiency of my methods written in burst more percisely?

@crazyguy90 you can use Unity’s ProfilerMarker API, in combination with Unity’s built-in Profiler window.

If you’re using Burst 1.5.0+ and Unity 2020.2+, then you can both create and use ProfilerMarkers from within Burst code.

Otherwise, you can still call .Begin() and .End() on the ProfilerMarker instances, but you must create ProfilerMarker instances outside of Burst code.

1 Like