First of all I just want to say that I’m a giant fan or the Burst compiler + the Jobs system, it’s the core tech that runs the heart of my game, and I am floored basically daily at how fast it almost all of the time… however…
I’m encountering a new very annoying (bug? or) general 7-8x slow down when running burst compiled code with the safety checks on in the first release of 2022.1 with Burst 1.7.1 vs 2021.3.2f1 with Burst 1.6.5.
My test case is a very large and complex Burst compiled job system that I’ve made for high throughput audio processing. I’m used to having the safety checks roughly double to tripling the overall runtime of my code which up to this point hasn’t been a large issue normally (for my case in 2021.3 it added just an extra 1-2 sec max). However after trying out 2022.1 today that wait has increased to around 13-14 seconds (vs 600 ms w/o safety checks).
My test setup: Here are some example timings I’ve gather from builds from both versions of the editor, and their current standalone builds for my use case. All of the code being run is identical, and they’re all tested on the same 4 min long track. All of these tests shown are from the second runs of the code (or later) to remove any effect the JIT Burst compiler has in editor.
These first two tests are running safety checks in-editor for both Unity versions:
This is the case running 7-8x slower (1.76 → 13.45 sec in the new version). The last line indicates the actual runtime for each set of job, what I’m measuring on the first line is just the time it takes to launch and prepare all of the jobs in the series.
Here is the same task run in 2022.1 without safety checks turned on:
Luckily build times are unaffected (as they should be):
Although I can get around this just by turning off safety checks every time I load the editor, this is going to remain a sizable annoyance to me in the long term as I end up developing new burst code when it will inevitably need to be debugging it.
I also feel like it’s generally bad form to be writing burst code w/o that option turned on most of the time; especially when testing for bazar corner cases… which sometimes may not-pop-up on their own for months after a game breaking error is introduced / then it’s next to impossible to debug without leaving this feature on, or disabling burst entirely for a particular job (both of which blow my VR time budget out the window currently in most circumstances).
Additionally when I inevitably (often) end up exiting out of play modes accidentally w/o turning the safety checks off beforehand, this (bug?) is resulting in my having to wait sometimes close to a full minute just for the series of jobs to complete if a longer track (like 10 min) is randomly selected-- as there is no way of canceling a job once it’s scheduled; and exiting out of play mode (even accidently) while the jobs are running results in memory leaks that force me to reboot the whole editor. The my only real fallback to complete the series of jobs on the main thread when exiting play-mode… However this still ends resulting in a 1-2 minute full-editor-locking-task while it wait for the job to complete for longer tracks, and then deallocated all of the working data.
I guess mostly what I’m looking for is information as to if this is expected behavior? And if so what so radically changed from the previous system? I’m not even sure what I should/would report for this in a bug report (apart from what’s above) as it isn’t actually causing any of my code to break, just perform horribly when debugging…