BlueRoseNote/03-UnrealEngine/流程管理与部署/提升FastBuild编译UnrealEngine的速度.md

515 lines
12 KiB
Markdown
Raw Permalink Normal View History

2023-06-29 11:55:02 +08:00
---
title: 提升FastBuild编译UnrealEngine的速度
date: 2021-11-09 22:34:16
excerpt:
tags: FastBuild
rating: ⭐
---
在上一篇文章之后我进行了进一步测试,下面是结果。
## 测试结果
**测试配置**
i7-8700 3.2Ghz 12线程
16GB内存
WDC PC SN730 SDBQNTY-256G-1001 固态硬盘
ST1000DM003-1SB102 机械硬盘
**服务器配置**
Inter Xeon Silver 4114 2.2GHz 2处理器40线程
64GB内存
引擎版本`4.27.0 Release`
网络:百兆网络
### 引擎放在机械硬盘
![](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/FastBuildDefault.PNG)
总共花费时间与编译量:
```
1>[2328/2328] UnrealBuildTool.exe UE4Editor.target
1>Total time in FASTBuild executor: 8160.80 seconds
1>Total execution time: 8501.83 seconds
```
141min
### 引擎放在机械硬盘并禁用插件
![](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/FastBuildDisablePlugins.png)
总共花费时间与编译量:
```
3>[1000/1000] UnrealBuildTool.exe UEToonRenderingEditor.target
3>Total time in FASTBuild executor: 3765.71 seconds
3>Total execution time: 3902.75 seconds
```
65min
这里我额外测试了一下开启`ForceRemote`的情况:
![](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/FastBuildForceRemote_DisablePlugins.png)
```
3>[1000/1000] UnrealBuildTool.exe UEToonRenderingEditor.target
3>Total time in FASTBuild executor: 4508.08 seconds
3>Total execution time: 4708.38 seconds
```
78min
### 引擎放在固态硬盘并禁用插件
因为将引擎从机械硬盘移动到固态硬盘中间删除了一些东西导致引擎多编译了一些实际时间要比测试的要短3~8min。
![](https://cdn.jsdelivr.net/gh/blueroseslol/ImageBag@latest/ImageBag/Images/FastBuildSolidDisk.png)
```
3>[1006/1006] UnrealBuildTool.exe UEToonRenderingEditor.target
3>Total time in FASTBuild executor: 2478.80 seconds
3>Total execution time: 2584.69 seconds
```
43min
## 猜想与总结
首先FastBuild的大致编译流程为分发编译任务=》远程机编译完之后下载obj文件=》所有编译任务完成后在本地进行链接并且生成对应文件。了解此我们才能对瓶颈进行分析。
- 远程机经常“偷懒”:本人在测试中发现远程机在编译时经常“偷懒”,且该阶段下内存、网络经常处于满负荷状态。因此本人认为这是因为没有使用千兆网络,下载时间过场而导致这种情况的产生。
- 任务显示超时:在编译过程中,远程机有时会出现超时的情况,个人猜测可能是因为动用了所有核心编译,导致网络连接的心跳检测失败而导致的。
基于以上结果我
但我经过一系列测试之后发现以下方法可以提升编译速度,影响程度由高到低排列如下:
1. 在uproject文件中禁用不必要插件。
2. 将源码放在固态硬盘中。
3. 使用千兆网络而非百兆。预计能加快5min
4. 使用缓存模式。
## 在uproject文件中禁用不必要插件
直接在插件管理界面中禁用插件即可。也可以直接将禁用的列表复制到uproject文件中。本人禁用的插件如下
```json
"Plugins": [
{
"Name": "AlembicImporter",
"Enabled": false
},
{
"Name": "AppleMoviePlayer",
"Enabled": false
},
{
"Name": "AppleImageUtils",
"Enabled": false
},
{
"Name": "OnlineSubsystemGooglePlay",
"Enabled": false,
"SupportedTargetPlatforms": [
"Android"
]
},
{
"Name": "AndroidPermission",
"Enabled": false
},
{
"Name": "AndroidMoviePlayer",
"Enabled": false
},
{
"Name": "AndroidMedia",
"Enabled": false
},
{
"Name": "AndroidDeviceProfileSelector",
"Enabled": false
},
{
"Name": "AudioCapture",
"Enabled": false
},
{
"Name": "AutomationUtils",
"Enabled": false
},
{
"Name": "AvfMedia",
"Enabled": false
},
{
"Name": "ChaosClothEditor",
"Enabled": false
},
{
"Name": "ChaosCloth",
"Enabled": false
},
{
"Name": "ChaosEditor",
"Enabled": false
},
{
"Name": "ChaosNiagara",
"Enabled": false
},
{
"Name": "ChaosSolverPlugin",
"Enabled": false
},
{
"Name": "CodeLiteSourceCodeAccess",
"Enabled": false
},
{
"Name": "CLionSourceCodeAccess",
"Enabled": false
},
{
"Name": "Paper2D",
"Enabled": false
},
{
"Name": "GooglePAD",
"Enabled": false
},
{
"Name": "MagicLeapMedia",
"Enabled": false,
"SupportedTargetPlatforms": [
"Lumin"
]
},
{
"Name": "MagicLeap",
"Enabled": false,
"SupportedTargetPlatforms": [
"Lumin",
"Mac",
"Win64"
]
},
{
"Name": "MagicLeapPassableWorld",
"Enabled": false,
"SupportedTargetPlatforms": [
"Lumin",
"Mac",
"Win64"
]
},
{
"Name": "OpenImageDenoise",
"Enabled": false
},
{
"Name": "IOSDeviceProfileSelector",
"Enabled": false
},
{
"Name": "LinuxDeviceProfileSelector",
"Enabled": false
},
{
"Name": "CharacterAI",
"Enabled": false
},
{
"Name": "DatasmithContent",
"Enabled": false
},
{
"Name": "GeometryCache",
"Enabled": false
},
{
"Name": "SpeedTreeImporter",
"Enabled": false
},
{
"Name": "LuminPlatformFeatures",
"Enabled": false,
"SupportedTargetPlatforms": [
"Lumin"
]
},
{
"Name": "MLSDK",
"Enabled": false
},
{
"Name": "WmfMedia",
"Enabled": false
},
{
"Name": "WebMMoviePlayer",
"Enabled": false
},
{
"Name": "MediaCompositing",
"Enabled": false
},
{
"Name": "ImgMedia",
"Enabled": false
},
{
"Name": "OnlineSubsystemNull",
"Enabled": false
},
{
"Name": "OnlineSubsystemUtils",
"Enabled": false
},
{
"Name": "OnlineSubsystemIOS",
"Enabled": false,
"SupportedTargetPlatforms": [
"IOS",
"TVOS"
]
},
{
"Name": "ChunkDownloader",
"Enabled": false
},
{
"Name": "OnlineSubsystem",
"Enabled": false
},
{
"Name": "XCodeSourceCodeAccess",
"Enabled": false
},
{
"Name": "EditableMesh",
"Enabled": false
},
{
"Name": "PerforceSourceControl",
"Enabled": false
},
{
"Name": "PlasticSourceControl",
"Enabled": false
},
{
"Name": "SubversionSourceControl",
"Enabled": false
},
{
"Name": "SteamVR",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Linux"
]
},
{
"Name": "OpenXRHandTracking",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Linux",
"HoloLens",
"Android"
]
},
{
"Name": "OpenXREyeTracker",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Linux",
"HoloLens",
"Android"
]
},
{
"Name": "OpenXR",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Linux",
"Android",
"HoloLens"
]
},
{
"Name": "OculusVR",
"Enabled": false,
"SupportedTargetPlatforms": [
"Win32",
"Win64",
"Android"
]
},
{
"Name": "EnvironmentQueryEditor",
"Enabled": false
},
{
"Name": "AISupport",
"Enabled": false
},
{
"Name": "Synthesis",
"Enabled": false
},
{
"Name": "MotoSynth",
"Enabled": false
},
{
"Name": "SoundFields",
"Enabled": false
},
{
"Name": "LocationServicesBPLibrary",
"Enabled": false
},
{
"Name": "XGEController",
"Enabled": false
},
{
"Name": "OodleData",
"Enabled": false
},
{
"Name": "OodleNetwork",
"Enabled": false
},
{
"Name": "TextureFormatOodle",
"Enabled": false
},
{
"Name": "ExampleDeviceProfileSelector",
"Enabled": false
},
{
"Name": "GeometryMode",
"Enabled": false
},
{
"Name": "MeshPainting",
"Enabled": false
},
{
"Name": "TcpMessaging",
"Enabled": false
},
{
"Name": "UdpMessaging",
"Enabled": false
},
{
"Name": "MacGraphicsSwitching",
"Enabled": false
},
{
"Name": "MobileLauncherProfileWizard",
"Enabled": false
},
{
"Name": "PlatformCrypto",
"Enabled": false
},
{
"Name": "MobilePatchingUtils",
"Enabled": false
},
{
"Name": "WindowsMoviePlayer",
"Enabled": false
},
{
"Name": "GoogleCloudMessaging",
"Enabled": false
},
{
"Name": "PhysXVehicles",
"Enabled": false
},
{
"Name": "NullSourceCodeAccess",
"Enabled": false
},
{
"Name": "FacialAnimation",
"Enabled": false
},
{
"Name": "PostSplashScreen",
"Enabled": false,
"SupportedTargetPlatforms": [
"XboxOne"
]
},
{
"Name": "KDevelopSourceCodeAccess",
"Enabled": false
},
{
"Name": "MatineeToLevelSequence",
"Enabled": false
},
{
"Name": "MediaPlayerEditor",
"Enabled": false
},
{
"Name": "VisualStudioCodeSourceCodeAccess",
"Enabled": false
}
]
```
其实还可以禁用更多的插件,我在测试的时候没有全部禁用。
除了可以减少编译量以节约时间外。同时也可以减少编译完之后所占用的空间。占用空间165G=>108G。
## 使用缓存模式
经过测试仅仅是将`bEnableCaching`设置为true好像是不能开启缓存模式的。应该还需要设置`CacheMode`。在源码中`CacheMode`分别为ReadWrite、ReadOnly、WriteOnly,枚举对应的值依次为0,1,2。因为缓存模式适用于多人引擎团队对于我这种独狼爱好者来说意义不大所以就没测试。有兴趣的可以自己跟一下UBT的代码。
```xml
<FASTBuild>
<bEnableCaching>true</bEnableCaching>
<CacheMode>0</CacheMode>
</FASTBuild>
```
## 本地核心控制
在编译UE4时FastBuildWorker.exe无法控制本地使用核心数。如果你不想占用本地资源可以将bForceRemote设置为true,引擎编译过程中就不会占用本地核心了开头还是会使用一些以及Link阶段只能进行
如果只想让本地不会卡死,则可以使用一下参数:
```xml
<LocalExecutor>
<ProcessorCountMultiplier>0.9</ProcessorCountMultiplier>
<MaxProcessorCount>11</MaxProcessorCount>
</LocalExecutor>
<ParallelExecutor>
<ProcessorCountMultiplier>0.9</ProcessorCountMultiplier>
<MaxProcessorCount>11</MaxProcessorCount>
</ParallelExecutor>
```
本人测试结果不设置MaxProcessorCount是不行的。
## BuildConfigure
```xml
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
<BuildConfiguration>
<bAllowFASTBuild>true</bAllowFASTBuild>
</BuildConfiguration>
<SourceFileWorkingSet>
<Provider>None</Provider>
<RepositoryPath></RepositoryPath>
<GitPath></GitPath>
</SourceFileWorkingSet>
<LocalExecutor>
<ProcessorCountMultiplier>0.95</ProcessorCountMultiplier>
<MaxProcessorCount>11</MaxProcessorCount>
</LocalExecutor>
<ParallelExecutor>
<ProcessorCountMultiplier>0.95</ProcessorCountMultiplier>
<MaxProcessorCount>11</MaxProcessorCount>
<bStopCompilationAfterErrors>true</bStopCompilationAfterErrors>
</ParallelExecutor>
<FASTBuild>
<bEnableCaching>true</bEnableCaching>
</FASTBuild>
</Configuration>
```