Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Feedback Option to limit "Unity Shader Compiler" processes

Discussion in '2023.2 Beta' started by Peter77, Apr 5, 2023.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,629
    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? :)

    upload_2023-4-5_9-10-55.png

    upload_2023-4-5_9-11-4.png
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,046
    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 :)
     
  3. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    517
    I assume the option would then be present in the Preferences window?
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,046
    Likely somewhere in Preferences, yes.
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,629
    Thank you for the quick help. The command-line option did the trick for me!
     
    aleksandrk likes this.
  6. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    934
    Are these command line options listed somewhere?
     
  7. aras-p

    aras-p

    Joined:
    Feb 17, 2022
    Posts:
    75
    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.)
     
    Ruchir likes this.
  8. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    671
    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?
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,046
    It's the number of CPU cores.