Fixing Delphi project compilation time

TL;DR: When compilation time goes out of hand – prune “uses” sections.

Over the time the game`s EXE compilation time grew longer and longer. Today it clocked at 70sec! Of course codebase has also increased (~350kLoc now), but still it was weird, given that 330kLoc compiled in 12 or so seconds just a few months ago. Such long times are very counter-productive, given that project has to be compiled and tested every now and then during active development.

Delphi is known for it’s super-fast compiler. So I had to check what’s going on.

Thanks to Source-Code-Versioning (which is SVN for the project) I was able to roll-back to older versions and find the one that increased the compile-time from 15 to 68sec. It was made a month ago. Why did it make such a big change – I can’t say. There was nothing special in it, apart from shuffling several files between folder and changing a few bits in “uses” sections. This was a good lead though – I started to check what will affect compilation time between this and previous versions. It seemed like moving files between “uses” sections was the answer. So I did a quick optimization – removing unused units and demoting them wherever possible from “interface” to “implementation” sections. This was the answer! With 10 min refactoring sprints the time dropped down to 36 sec, then to 26 sec, then to 18 sec. I was on the right track.

Now I have returned to the latest version and started optimizing  .. An hour later I’m happy to have project compilation time back at lightning-fast 8.5 sec! Praise the fast Delphi compiler! 🙂

P.S. All times are given full rebuild from SSD drive. Every time I did several builds in a row – times were very consistent.

This entry was posted in How things work, Sidenotes. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *