Change the priority of ShaderCompileWorker.exe

The poor performance of Materials/Shaders in UE4 has been a great deal of frustration for me…the first video below should illustrate how bad this is.

If i make a very simple change to a material ie color. it takes at least 2 mins 30 secs to preview/nodes, show in the game editor, and update the swatch in content editor…

However if I manually boost ShaderCompileWorker.exe’s priority to Above normal it takes seconds…

As you can see I have to do it couple of times, I guess UE4 re-spawns the process a couple of times( in this simple example)…

How can I permanently set the exes priority to Above Normal or even just Normal?

(I’ve found an app called prio that might temporarily fix this…just testing that now…)

3 Likes

Prio works but there is a bit of a delay, it has to poll for the app and update the priority. Would be better if this was an option or default in UE4

I’ve spotted in the source code, that the priority of the ShadeCompileWorker is hard coded :frowning:

https://github.com/EpicGames/UnrealEngine/blob/c009a7ad436601b404f3aef7f54914d6bca4a8bb/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp

not sure if you have found this or not, but it is also configurable in the options. if you reed the very next line :
GConfig->GetInt(TEXT(“DevOptions.Shaders”), TEXT(“WorkerProcessPriority”), PriorityModifier, GEngineIni);
its reading an option from Engine/Config/BaseEngine.ini

in that file do a search for WorkerProcessPriority which will also equal -1, simply change that and it will use that value instead.

the following numbers match priority:
-2 = Low, -1 = Below Normal, 0 = Normal, 1 = Above Normal, 2 = High

4 Likes

hmmm you must be a few revisions ahead of the code I looked at…but still my ini file( v 4.25.4) does not have that value…I’ll add it and see if makes a difference.

My cpu has changed since …but adding WorkerProcessPriority=1 to DevOptions.Shaders seems to make a difference!..I only did some vey quick testing though…

2 Likes

I don’t understand why you have to make this solution confidential, why don’t you share the folder location, file name and command line to be changed?

%UnrealEngineInstallPath%/Engine/Config/BaseEngine.ini

Ctrl+F

Type “shadercompileworker” Press Enter

Change WorkerProcessPriority=-1 to WorkerProcessPriority=1

3 Likes

I have set the ProcessWorker in the BaseEngine.ini to the Value 2. Which is the highest i think.
But the engine still takes ages to load the 6000 shaders when it starts up the project, every single time.

I can not believe that it is an issue with my hardware, because the CPU is at 12% and the GPU is at 3%
My RAM is at 33%
So it clearly isn’t even trying to work faster. Its just super slow for some other reason.

End of April 2023 and 5.11 is STILL recompiling all shaders upon project open, even if you only open close an open again, (and around 6,000 for me too) As far as I can tell,. 5.2 is doing the same,… So much so way more ‘efficient’ shader calcs.

Changing the Priority of the Shader process in the Unreal Ini is not intended to bypass or remove the need to compile project shaders, it only tells your PC to prioritize the shader compilng more than other periferal tasks. There are other ways to mitigate the shader compile time by in a way “caching” the compilied shaders for a standard project. Hope this helps you better understand what this thread helps you achieve!

2 Likes

Do you have ray tracing enabled or disabled?

Same issue here. I found shader compiling always does not take large percent of cpu utilization in task manager, any solution for that?

Fixed for myself, actually changing back to default settings in consolevariables would work, mostly caused by r.Shaders.AllowCompilingThroughWorkers