From 5dcef5e771e2a3a918b4f634ab01c7f2b3244a31 Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 17 Mar 2020 13:27:38 +0100 Subject: [PATCH] Added 16-thread limiter to VRAD VRAD can run a maximum of 16 CPU threads. (see wiki: https://developer.valvesoftware.com/wiki/VRAD ) On CPUs with more than 16 cores, the process keeps bouncing between cores, creating a severe slowdown.* By setting the Processor affinity to cores 0-15, we improve the performance significantly --- CompilePalX/Compilers/CompileExecutable.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CompilePalX/Compilers/CompileExecutable.cs b/CompilePalX/Compilers/CompileExecutable.cs index 2d80bbf6..0ab7a787 100644 --- a/CompilePalX/Compilers/CompileExecutable.cs +++ b/CompilePalX/Compilers/CompileExecutable.cs @@ -47,6 +47,15 @@ public override void Run(CompileContext c) Process.Start(); Process.PriorityClass = ProcessPriorityClass.BelowNormal; + //VRAD can only use up to 16 cores, more cores reduces performance, and increased compile time. + //By assigning affinity to the process significantly speed up compiles on CPUs with more than 16 cores. + if (this.Name == "VRAD" && + Environment.ProcessorCount > 16) + { + //Hex 0xffff means core use core 0 through 15. + Process.ProcessorAffinity = (IntPtr)0xffff; + } + if (Metadata.ReadOutput) readOutput(); }