Compile with ALL the cores
Add these lines to BuildConfiguration.xml:
<?xml version="1.0" encoding="utf-8" ?> <Configuration xmlns="https://www.unrealengine.com/BuildConfiguration"> <ParallelExecutor> <ProcessorCountMultiplier>2</ProcessorCountMultiplier> <MemoryPerActionBytes>0</MemoryPerActionBytes> </ParallelExecutor> </Configuration>
The file can be found here:
- Launcher Builds: %AppData%/Unreal Engine/UnrealBuildTool/BuildConfiguration.xml
- Source Builds: UE_5.X/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml
When compiling each compilation process reserves a specific amount of memory to work with. By default that is 1.5 GB. Depending on how much RAM you have or how many other process are running the build log might show something like this:
Determining max actions to execute in parallel (8 physical cores, 16 logical cores) Executing up to 8 processes, one per physical core Requested 1.5 GB free memory per action, 4.61 GB available: limiting max parallel actions to 3 Building 267 actions with 3 processes...
In my opinion the allocated amount of memory is very pessimistic. In my use cases the amount used per process stays between 100 and 400 mb. The MemoryPerActionBytes setting can be changed to a different default amount. Setting it to 0 will disable it completely. I’ve never had problems disabling it, but if you run into memory problems consider setting a non-zero value.
This change improves the utilization a lot already:
Determining max actions to execute in parallel (8 physical cores, 16 logical cores) Executing up to 8 processes, one per physical core Building 267 actions with 8 processes...
However note it says 8 physical cores and 16 logical ones. This means some form of hyperthreading is available. The build tool does not take that into account by itself, but you can force it to multiply the number of compilation threads based on processors with the ProcessorCountMultiplier setting. Setting it to 2 in this case gives:
Determining max actions to execute in parallel (8 physical cores, 16 logical cores) Requested 2 process count multiplier: limiting max parallel actions to 16 Building 267 actions with 16 processes...
Having all cores and all memory go to compilation can make the computer pretty unusable and unresponsive for anything else while it is compiling. I prefer the compilation to take less time though.