Faster Compilation for Delphi Win32 Generics in 10.1 Berlin


While the Delphi compiler is recognized as an extremely fast compiler, when it comes to generics it can significantly slow down, along with the linker. The latest version of Delphi offers a significant improvement.
During the development of 10.1 Berlin Delphi’s R&D team, and in particular the compiler team, looked into areas in which we could improve the compiler quality, both in terms of code generation and in terms of compiler speed. Out of many improvements, one worth calling out it the significantly faster compilation for code involving a large number of generic data types.
This wasn’t actually a single fix, but a collection of 6 different compiler optimizations, each of which contributes to the overall improvement. Ranging from small to very large projects, we have internal test cases that show different gains for each of these individual optimizations – well, in general, as there are individual optimizations that make compilation slower in given scenarios.
As an example, one of our customers (thanks, Guenther) had submitted a demo (and actually even a demo generator) as part of That demo code on Win32 in 10 Seattle takes on average 25 seconds for a full build. The same exact code compiles in 10.1 Berlin in less than 10 seconds. That is, it is taking only 40% of the original time – a 150% improvement.
Other code scenarios, specifically those not so extreme, will see a more moderate advantage, but the changes are applicable to almost all code and both the compiler and the linker. As a more real-world scenario, I downloaded the latest Spring4D library, and compiled the Win32 version of the Spring.Tests projects of 10 Seattle and 10.1 Berlin, and got the following numbers:

10 Seattle: 6.01 seconds
10.1 Berlin: 4.50 seconds

As a further test (although less significant because it is very fast) I also compiled the Demo.Spring.Collections.Stack demo and saw the following timing:

10 Seattle: 1.02 seconds
10.1 Berlin: 0.70 seconds

The summary is there is a consistent improvement in compiling code with generics, in this real-world cases the compilation is about 30% faster. I had a chat with Stefan Glienke, and he confirmed seeing similar numbers. 
There is a caveat, though. The original request was to speed up the Win64 compiler, and that hasn’t actually seen a significant gain in this cycle, I only see a 10% improvement in that case. That clearly means we still have a lot of room for improvement, and need to keep focusing on the compiler performance (but without forgetting code generation quality and performance of the compiled code, of course).
In any case, 10.1 Berlin represents a good step in the right direction in terms of compilation of Delphi code with generics and I hope this is appreciated.

Comments are closed.