I upgraded from 4.16.1 to 4.17.0 recently, and I noticed that hot reloading is much slower than it used to be.
I tried hot-reloading on a backup of the 4.16.1 version of my project and verified this.
The following is the build log when adding a space and compiling a single bare-bones (25 line) cpp file for an actor in my project via the Build->Build Solution menu in Microsoft Visual Studio Community 2015 (Microsoft Windows 10 Pro). The 4.17 QFE fixing a build issue (QFE-4.17-UBT-CL-3578350-PF-3578389-Job-7937603.exe) has also been applied. I have not made any modifications to the engine’s code.
4.17.0 Build Log:
1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: Project, Configuration: Development_Editor x64 ------
2> Compiling game modules for hot reload
2> Parsing headers for ProjectEditor
2> Running UnrealHeaderTool "D:\UnrealProjects\Project\Project.uproject" "D:\UnrealProjects\Project\Intermediate\Build\Win64\ProjectEditor\Development\ProjectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2> Reflection code generated for ProjectEditor in 6.8945103 seconds
2> Performing 3 actions (4 in parallel)
2> ShortActorCppFile.cpp
2> [2/3] Link UE4Editor-Project-3558.dll
2> [3/3] Link UE4Editor-Project-3558.lib
2> Creating library D:\UnrealProjects\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-3558.suppressed.lib and object D:\UnrealProjects\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-3558.suppressed.exp
2> Creating library D:\UnrealProjects\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-3558.lib and object D:\UnrealProjects\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-3558.exp
2> Deploying ProjectEditor Win64 Development...
2> Total build time: 13.49 seconds (Local executor: 1.94 seconds)
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
4.16.1 Build Log:
1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: Project, Configuration: Development_Editor x64 ------
2> Compiling game modules for hot reload
2> Performing 3 actions (4 in parallel)
2> ShortActorCppFile.cpp
2> [2/3] Link UE4Editor-Project-8506.dll
2> [3/3] Link UE4Editor-Project-5015.lib
2> Creating library D:\UnrealProjects\BENCHMARK_4_16_1\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-8506.lib and object D:\UnrealProjects\BENCHMARK_4_16_1\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-8506.exp
2> Creating library D:\UnrealProjects\BENCHMARK_4_16_1\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-8506.suppressed.lib and object D:\UnrealProjects\BENCHMARK_4_16_1\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-8506.suppressed.exp
2>ERROR : UBT error : Failed to produce item: D:\UnrealProjects\BENCHMARK_4_16_1\Project\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-Project-5015.lib
2> Total build time: 2.92 seconds (Local executor: 0.00 seconds)
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(41,5): error MSB3075: The command ""C:\Program Files\Epic Games\UE_4.16\Engine\Build\BatchFiles\Build.bat" ProjectEditor Win64 Development "D:\UnrealProjects\BENCHMARK_4_16_1\Project\Project.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
As you can see above, the 4.16.1 build took 2.92 seconds, whereas the 4.17.0 build took 13.49 seconds.
The vast majority of the build time seems to be taken by the following, which executes every time in 4.17.0, but which does not display when building in 4.16.1:
2> Parsing headers for ProjectEditor
2> Running UnrealHeaderTool "D:\UnrealProjects\Project\Project.uproject" "D:\UnrealProjects\Project\Intermediate\Build\Win64\ProjectEditor\Development\ProjectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2> Reflection code generated for ProjectEditor in 6.8945103 seconds
I don’t know what’s going on internally, but it seems strange that it needs to take 6.89 seconds doing the above reflection code generation when I add a single whitespace to a cpp file. Perhaps it is superfluously regenerating reflection code for the entire project even though this might be unnecessary? Note that this reflection code generation only occurs when the editor is open (for hot reloading). Building the cpp file with the 4.17 editor closed takes a mere 3 seconds.
Also, you might have noticed that a build error (“UBT error : Failed to produce item”) occurs when building the 4.16.1 version. Please note that even though this error displays, the build and hot reload actually both succeed. This error displaying was a bug that occurred in projects updated to version 4.15 (more info here), and it stopped occurring when I updated to 4.17. I have no idea if this bug being fixed is the reason why the hot reload time increased. However, hot reloading was also fast for me in older versions like 4.13.1, which gives me the impression that this is a new bug introduced into 4.17.
In any case, is this issue (slow hot reloading) occurring with anyone else, and does anyone know of a way to increase hot reload speed? Also, what’s the deal with the ~7sec reflection code generation every time I build?