Option to limit "Unity Shader Compiler" processes

Unity spawns a lot of Unity Shader Compiler processes when building a Player. Unity spawns so many of these processes, that the PC is pretty much unusable, while the build process is running.

This is not a problem on a dedicated build machine. It’s however a problem when one would like to continue to work on the same machine, which is my typical work-scenario. When I trigger a build in Unity, I want to do other work on the same PC, while Unity is building the player.

However, since so many Unity Shader Compiler processes are running, the system has almost no resources left that allow to work in other applications. All cores pretty much go up to 100% utilization.

I would like to suggest an option, where one can limit the number of Unity Shader Compiler processes, so that the system has enough resources to allow me to continue to use the PC for other tasks, while the build process is running.

What do you think? :slight_smile:

CPU utilization screenshots

You can limit the number of job worker threads when starting Unity by passing a -job-worker-count command line parameter. This will also limit the number of shader compiler instances.
We have what you ask for in the backlog :slight_smile:

I assume the option would then be present in the Preferences window?

Likely somewhere in Preferences, yes.

Thank you for the quick help. The command-line option did the trick for me!

Are these command line options listed somewhere?

Yes, https://docs.unity3d.com/Manual/EditorCommandLineArguments.html but it does not quite go into detail what that argument does (does it only affect number of jobs for C#/Engine threading systems? Shader compilation? Lightmap baking? Player build? Something else? etc.)

The heuristic for the number of worker threads might need to be optimized… My 7590x w/ 32GB of RAM is memory bound during shader compilation instead of CPU bound.

A slight decrease in worker threads using -job-worker-count seems to yield improvements in shader compilation time. I’m not keen to delete my library folder for a definitive test, but it raises an interesting question: what is the heuristic for spinning up shader compilers? Is it based on CPU cores or does it account for total memory overhead?

It’s the number of CPU cores.

Hi, any progress on this item? I see it mentioned as being in the backlog since 2022.

Hi, unfortunately not. We’re working on other things.

Hi!
Is there any progress on the issue?
I have 20 cores and all of them are getting loaded up to 100% during build with URP (for built-in all good).
At the same time, my PC is getting not usable at all and just stack unless I restart it manually.

Why not lower the number of cores used with -job-worker-count ?

I tried to do it, but :

  1. It’s strange that such huge product by default trying to consume all your cores and kills you PC
  2. There is no such config in editor, so I always need to start editor via console
  3. Even using that, I still bumped into the issue with PC freeze

Also tried to Set affinity via task manager, it helped, but need to be set every time you open editor

Unity hub let’s you specify command line arguments on a per-project basis.

Didn’t know about that option, thanks, it’s very helpful

It absolutely ruins your PC when it uses all cores and the whole machine grinds to a halt so it doesn’t surprise me that making it lay off a bit improves performance.

But, the fix doesn’t work. I have “-job-worker-count 8” as an argument for this project and yet…

Rendering my PC entirely unusable. Checking the current launch arguments for Unity in Task Manager shows…

"-job-worker-count" "11" "-background-job-worker-count" "8"

… so is it just ignoring the jobs option specified in the Unity Hub for this project?

hmm so the setting doesn’t work at all?

I had posted my own thread about this issue Build times.. low priority - #4 by Player7 6.2alpha so hoping it gets fixed @aleksandrk