You have to use CoreMinimal.h
instead of Core.h
to reduce your game’s compilation time.
You have to use CoreMinimal.h
instead of Core.h
to reduce your game’s compilation time.
I still have Engine.h in my main common header. That’s probably the problem. Switching to CoreMinimal.h is bringing in lots of errors as there are plenty of classes missing, like ConstructorHelpers, all the physics collision components, etc… I’ll have to go over all of the cpp files and hunt down the dependencies by hand.
I have changed all of my classes to include the correct headers (only those really needed) and my compile times have changed a little bit. They’re down to 20 seconds instead of 30 seconds when I change a single line of code in a single cpp file.
Log:
Recompiling Test2DPlatformer...
Launching UnrealBuildTool... [/Users/Shared/Epic Games/UE_4.15/Engine/Binaries/DotNET/UnrealBuildTool.exe Test2DPlatformer -ModuleWithSuffix Test2DPlatformer 6247 Mac Development -editorrecompile -canskiplink "/Users/tanis/Documents/Unreal Projects/Test2DPlatformer/Test2DPlatformer.uproject" ]
Warning: Starting HotReload took 0.0s.
CompilerResultsLog: New page: Compilation - Feb 16, 2017, 1:44:34 PM
CompilerResultsLog: Info
CompilerResultsLog: Info Running Mono...
CompilerResultsLog: Info
CompilerResultsLog: Info Setting up Mono
CompilerResultsLog: Info /Users/Shared/Epic Games/UE_4.15/Engine /Users/Shared/Epic Games/UE_4.15/Engine/Binaries/Mac
CompilerResultsLog: Info Compiling game modules for hot reload
CompilerResultsLog: Info Compiling with MacOSX SDK 10.12
CompilerResultsLog: Info Parsing headers for Test2DPlatformerEditor
CompilerResultsLog: Info Running UnrealHeaderTool "/Users/tanis/Documents/Unreal Projects/Test2DPlatformer/Test2DPlatformer.uproject" "/Users/tanis/Documents/Unreal Projects/Test2DPlatformer/Intermediate/Build/Mac/Test2DPlatformerEditor/Development/Test2DPlatformerEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattende
d -WarningsAsErrors -installed
CompilerResultsLog: Info Reflection code generated for Test2DPlatformerEditor in 7,4884564 seconds
CompilerResultsLog: Info Performing 2 actions (4 in parallel)
CompilerResultsLog: Info [1/2] Compile HeroPawn.cpp
CompilerResultsLog: Info [2/2] Link UE4Editor-Test2DPlatformer-6247.dylib
CompilerResultsLog: Info Total build time: 20,05 seconds (Local executor: 5,40 seconds)
LogMainFrame: MainFrame: Module compiling took 21.586 seconds
LogClass: ENavAreaFlag HotReload.
LogHotReload: Re-instancing EnemyPawn after hot-reload.
LogHotReload: Re-instancing NavArea_Jump after hot-reload.
LogContentBrowser: Native class hierarchy updated for 'Test2DPlatformer' in 0.0032 seconds. Added 21 classes and 3 folders.
Display: HotReload successful (5 functions remapped 0 scriptstructs remapped)
LogContentBrowser: Native class hierarchy populated in 0.0125 seconds. Added 2264 classes and 452 folders.
Display: HotReload took 21.9s.
The headers included in my HeroPawn.cpp:
#include "Test2DPlatformer.h"
#include "HeroPawn.h"
#include "PaperFlipbookComponent.h"
#include "BunnyManager.h"
#include "PixelPerfectCameraComponent.h"
#include "Particles/ParticleSystem.h"
#include "PaperFlipbook.h"
#include "PaperSprite.h"
#include "UObject/ConstructorHelpers.h"
#include "Components/BoxComponent.h"
#include "Components/InputComponent.h"
#include "Kismet/GameplayStatics.h"
#include "EngineUtils.h"
And Test2DPlatformer.h is including only “CoreMinimal.h”
It’s a bit better even though I don’t get why it’s taking 5.4 seconds to compile my class, 7.5 seconds to build the reflection stuff and the rest of the time isn’t shown. What’s the build tool doing for the remaining 7.1 seconds?
Have you tried Incredibuild? If not, give it a shot. It speeds up compile time significantly.
I turned off the Unity (no not the other engine, part of the compiler stage) compiler and turned on & setup up precompiled headers. That helped alot.
In xxx.Build.cs…
using UnrealBuildTool;
public class RidicRugby : ModuleRules {
public RidicRugby(ReadOnlyTargetRules Target) : base(Target) {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PrivatePCHHeaderFile = "MaulProtoPrecompiled.h";
MinFilesUsingPrecompiledHeaderOverride = 1;
bUseUnity = false;
...
I also purged as much of big header overuse like Engine.h.
UE4 is largely disk bound in my experience. An NVME drive will do wonders if you can grab one.
The latest VS releases have a multithreaded linker now, speeding up incremental builds:
Do you have an M.2 NVME drive? If not, get one! A SATA SSD is better than spinning rust platters, but if you’re already upgrading, going to M.2 is worth it.
Also, if your project isn’t just a very small test project, more memory will help, and more cores will help.
Finally, there are some settings in Visual Studio to turn on multi-process / multi-threaded builds; if those are not on for your project, you might want to turn those on.
Don’t know if this topic is still actual but I found something to do in case compile time is too long :