Download

High build times for the shooter game example

I used the Shooter Game example to bootrap my project but I am encountering some heavy build times. A simple change in ShooterCharacter.h will result in > 70 sec build time.

I think that is pretty heavy. I already put everything on an SSD. I have an i5 2500k which is only a dual core with 4 threads.

I tried to change some settings. I realized Ue4 defaults to a unity build so I thought I would try


bFasterWithoutUnity = true

The strange thing is it still seems to compile every single file again just like the unity build but without putting everything in one file.

The build time goes up from ~70sec to ~220sec for a simple change. That doesn’t seem quite right. I expected it to only recompile a couple of files.

If you change a header file anything that includes that file will also be recompiled. In the case of UE4 this is also going to also going to mean re-compiling a bunch of generated stuff and then there’s even more overhead if it’s a UPROPERTY.

So even though it’s only one change it can flow on to lots of files. I haven’t looked to closely at this example but check how many files include the file your changing.

As a test you can try changing something small in a .cpp file and see what the compile times are like comparatively.

I know but it actually compiles every file again, seems more like a bug to me.

Yes I have tested this before, for ShoterCharacter.cpp the compile time goes down to 5 sec, which is kinda what I expected and this is great.

Edit:

I found the cause of the problem, there is a ShooterGameClasses.h which includes every header. Of course this will cause a full recompile.

I would have to fix the includes for ~50 .h files :frowning:

I completely added all includes manually, it took me over 3 hours and here are my results.

Shooter Game default:

With Unity: Change in ShooterCharacter.h/ShooterCharacter.cpp : average ~71sec both
Without Unity: Change in ShooterCharacter.h 220sec ShooterCharacter.cpp : ~10sec

Shooter Game with manual includes:

With Unity: Change in ShooterCharacter.h/ShooterCharacter.cpp : average ~41sec both
Without Unity: Change in ShooterCharacter.h ~39 sec ShooterCharacter.cpp : ~10sec

Strangely enough I got also an speed boost for unity builds aswell. I think this is because UBT doesn’t have to reparse as many headers as before.

Also note that ShooterCharacter.h is a dependency of many other files. I think it currently is included in 26 files from 77 files. I see it as a worst case for builds that do not use unity.