UE5.1使用VS2022Pro编译时,为什么VS2022只使用单线程编译?

我的CPU是 i7-6700k,4 核 8 线程,用 VS2022Pro 编译 UE5.1 时,为什么VS2022只使用单线程编译?

已启动编译
1>------ 已启动编译: 项目: UE5, 配置: Development_Editor x64 ------
1>Using bundled DotNet SDK version: 6.0.302
1>Running UnrealBuildTool: dotnet ".\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -Target="UnrealEditor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild
1>Log file: D:\UnrealEngine-5.1\Engine\Programs\UnrealBuildTool\Log.txt
1>Building UnrealEditor and ShaderCompileWorker.
1>Using Visual Studio 2022 14.31.31104 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.31.31103) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Determining max actions to execute in parallel (4 physical cores, 8 logical cores)
1>  Executing up to 4 processes, one per physical core
1>  Requested 1.5 GB free memory per action, 1.12 GB available: limiting max parallel actions to 1
1>Building 5394 actions with 1 process.
1>[1/5394] Compile Module.Core.4_of_19.cpp
1>[2/5394] Compile Module.Core.2_of_19.cpp
1>[3/5394] Copy AnimEncoding_VariableKeyLerp.ispc.generated.h
1>[4/5394] Compile Module.Core.12_of_19.cpp

如上,输出窗口提示了:Building 5394 actions with 1 process.
但是根据我的CPU核心数量,它应该是使用 8 线程编译才对。

我尝试修改 UnrealEngine-5.1\Engine\Saved\UnrealBuildTool\BuildConfiguration.xml,
改成如下内容:

<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
    <BuildConfiguration>
        <bAllowFASTBuild>false</bAllowFASTBuild>
        <bUseXGEController>false</bUseXGEController>
        <bAllowXGE>false</bAllowXGE>
    </BuildConfiguration>
    <LocalExecutor>
        <MaxProcessorCount>8</MaxProcessorCount>
        <ProcessorCountMultiplier>1</ProcessorCountMultiplier>
    </LocalExecutor>
</Configuration>

也是不起作用的,还是 1 个线程在编译。
我再将上面的 LocalExecutor 改为 ParallelExecutor,
仍然不行,依旧是 1 个线程在编译。
有人知道怎么让它以 8 线程编译吗?
非常感谢。

看起来像是 UnrealBuildTool 在判断最大并行构建数量时,可能没有正确地读取可用内存数。它可能将最大并行构建数量限制为 1,因为它认为没有足够的内存。

可以试试在 BuildConfiguration.xml 文件中更改以下内容:

<LocalExecutor>
    <MinFreeMemoryMb>0</MinFreeMemoryMb>
    <MinFreeMemoryPercentage>0</MinFreeMemoryPercentage>
</LocalExecutor>

这样UnrealBuildTool 将不会考虑可用内存数,并使用 CPU 的所有核心进行构建。

另外也可以在命令行中使用 -j 参数来指定最大并行构建数量。例如可以使用以下命令行来使用 8 个线程进行构建:

UnrealBuildTool -j8

注意在使用较大的并行构建数量时,可能会出现系统内存不足的情况。可能需要调整系统中的其他设置,以便在构建过程中更多的内存可供使用。
仅供参考,望采纳,谢谢。

UE5 + VS2022和UE4 + VS2019 编译踩坑
https://blog.csdn.net/asiwxy/article/details/128234332

您的 UE5.1 项目的构建过程当前可能设置为使用单个构建线程。您可以检查和调整正在使用的构建线程数,如下所示:

在 Visual Studio 中,转到菜单栏并选择“工具”>“选项”。
在“选项”对话框中,转到“项目和解决方案”>“构建和运行”类别。
在“MSBuild 项目构建输出详细程度”设置下,您会找到一个“设置并行项目构建数”的选项。此选项允许您指定要使用的构建线程数。
如果您发现该设置已设置为使用多个构建线程,则构建过程可能由于某些其他原因被限制为单个线程。一些可能的原因可能包括:

项目或解决方案生成设置已专门配置为使用单个线程。
构建过程的不同部分之间存在冲突或依赖关系,导致无法有效使用多个线程。
您的计算机的硬件或系统配置可能不支持有效地使用多个构建线程。
如果您继续遇到构建线程使用问题,检查项目的构建设置并确保它们配置正确可能会有所帮助。您可能还需要考虑查阅文档或寻求 UE5.1 或 Visual Studio 开发人员的支持。