←back to thread

141 points vblanco | 1 comments | | HN request time: 0.2s | source
Show context
Asooka ◴[] No.44436332[source]
I would like to see a comparison between modules and precompiled headers. I have a suspicion that using precompiled headers could provide the same build time gains with much less work.
replies(4): >>44436478 #>>44436777 #>>44436830 #>>44439283 #
w4rh4wk5 ◴[] No.44436830[source]
From my experience, compile times ain't an issue if you pay a little attention. Precompiled header, thoughtful forward declarations, and not abusing templates get you a long way.

We are commonly working with games that come with a custom engine and tooling. Compiling everything from scratch (around 1M lines of modern C++ code) takes about 30-40 seconds on my desktop. Rebuilding 1 source file + linking comes in typically under 2 seconds (w/o LTO). We might get this even lower by introducing unity builds, but there's no need for that right now.

replies(1): >>44436956 #
ttoinou ◴[] No.44436956[source]
40 seconds for 1M lines seems super fast, do you have a fast computer and/or did you spend a lot of time optimizing the compilation pipeline ?
replies(3): >>44437056 #>>44437789 #>>44441379 #
1. w4rh4wk5 ◴[] No.44437789[source]
We didn't create this code base ourselves, we are just working with it. I'd assume the original developers payed attention to compile times during development and introduced forward declarations whenever things got out of hand.

My computer is fast, AMD Ryzen 9 7950X, code is stored on an NVMe SSD. But there certainly are projects with fewer lines of code that take substantially longer to compile.