# High build times for the shooter game example

**URL:** <https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 14, 2015, 10:34am UTC](https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382 "2015-04-14T10:34:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maikklein](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maikklein/32/918666_2.png) [@maikklein](https://forums.unrealengine.com/u/maikklein)\
**Post date:** [April 14, 2015, 10:34am UTC](https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382/1 "2015-04-14T10:34:51Z")

</div>

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

```auto

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bca41a09](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bca41a09](https://forums.unrealengine.com/u/anonymous_user_bca41a09)\
**Post date:** [April 14, 2015, 11:04am UTC](https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382/2 "2015-04-14T11:04:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maikklein](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maikklein/32/918666_2.png) [@maikklein](https://forums.unrealengine.com/u/maikklein)\
**Post date:** [April 14, 2015, 1:08pm UTC](https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382/3 "2015-04-14T13:08:31Z")

</div>

> [@karltheawesome;271484](#):
>
> If you change a header file anything that includes that file will also be recompiled.

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

> [@](#):
>
> As a test you can try changing something small in a .cpp file and see what the compile times are like comparatively.

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 ☹

---

<div class="post-metadata">

**Author:** ![maikklein](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maikklein/32/918666_2.png) [@maikklein](https://forums.unrealengine.com/u/maikklein)\
**Post date:** [April 15, 2015, 4:22pm UTC](https://forums.unrealengine.com/t/high-build-times-for-the-shooter-game-example/27382/4 "2015-04-15T16:22:02Z")

</div>

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.
