Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Threadripper 3990X vs. 5950X: 1 BILLION Lines Of Object Pascal Code For #Delphi26th


Celebrating Delphi’s 26th Anniversary with some modern hardware! Two of the fastest CPUs on the market right now are the AMD Ryzen 9 5950X and the AMD Threadripper 3990X. The 5950X features 16 cores and a higher clock speed while the Threadripper 3990X features 64 cores and a higher overall PassMark score (80923). In previous posts one billion lines of Object Pascal was compiled on the AMD Ryzen 9 5950X in ~5 minutes and one billion lines of C++ was compiled on the Threadripper 3990X in ~15 minutes. In this post we want to take these two powerful desktop CPUs and pit them head to head against each other. Ultimately, we are comparing the productivity of these modern desktop processors when combined with Delphi. Before we start you can visualize 1 billion lines of code here.

5950xvs3990x 6321831

Delphi is a single pass compiler and is not a parallel compiler so the 1 billion lines of code is split up into multiple projects. Based on what was learned in the previous benchmarks this time we are going with 1000 Delphi projects and 1 million lines of code each. In the previous post 250 projects with 4 million lines of code each was used but from what I’ve seen the 1 million lines of code files have a higher lines of code per second (LoC/s) compile time number than the 4 million lines of code units. We’re going to use Delphi Parallel Build (a FireMonkey GUI wrapper around MSBuild) to compile all the projects.

dpb127 4628233

As we’ve seen in the Delphi 26th Anniversary Showcase there are some truly massive projects built in Delphi. One billion lines of code and 1000 projects may sound like a lot but for massive projects in Delphi that are 25 years in the making and/or have hundreds of DLLs modern multi-core CPUs can really boost the productivity of these massive projects. It really speaks to the longevity of Delphi that there are these massive software projects at the core of successful businesses over such a long period of time. Modern hardware can really speed up working with these large projects.

In this version of the 1 billion lines of code I used a Scimark2a application built in Delphi. The app used for the C++ 1 billion lines of code was also Scimark2 so the source code is comparable (it does the same work). The resulting binary executes and produces the Scimark 2a benchmark. In this project I used the LU.pas unit and duplicated the LU_factor() function X number of times to create a unit with 1 million lines of code. Each LU.pas file is 18.6MB. There is a sample of the LU_factor() function below. As you can see it is not full of advanced language features.

Get a more insightful read on the distinctive features of 5950x vs 3950x and compare the two on different aspects such as cores, debugs, and threads.

As mentioned above each LU.pas file is 18.6MB but now let’s look at the entire 1000 project folder. As you can see in the below screenshot the 1000 projects consists of 3,000 folders and 16,000 files. The entire folder combined is a massive 18.7 GB. The visualization is done using TreeSize Free from JAM Software which is also built in Delphi.


I have uploaded the project to GitHub that will generate the 1 billion lines of code. The main project is called DelphiGen. It lets you specify how many functions to add to the LU.pas file and then how many projects to create from the root Project1 folder. The location of the Project1 folder gets specified in the edit field at the top. The SciMark2a project that is in the Project1 folder and used for the demonstration has a BSD license.

delphigen 8888066

In the next screenshot we have the Threadripper 3990X parallel compile of the 1000 Scimark2 projects during the compile. One difference between the 3990X machine and the 5950X machine is the 3990X machine is running Windows Server 2019 Standard while the 5950X machine is running Windows 10 Pro. The latest version of Task Manager DeLuxe (which is built in Delphi) was used for the screenshots and contains a scrollable window for all of the CPU graphs.

3990x1billionduringcompile 8681777

And in this screenshot we have the AMD Ryzen 9 5950X parallel compile of the 1000 Scimark2 projects during the compile. The RAM usage is not particularly high because each project is only 1 million lines of code compiled in parallel. While the C++ projects done in the previous post had all of the code compiling into a single binary.

5950x1billionduringcompile2 2459497

As you can see in the below graph the 1 billion lines of Object Pascal on the AMD Ryzen 9 5950X machine with the 16 cores took 304 seconds to compile. The Threadripper 3990X only needed 76 seconds to compile the same 1 billion lines of code on 64 cores. The 304 and 76 seconds are not hard numbers as in other compiles I saw numbers like 294 seconds and 72 seconds so it can change up and down in either direction between compiles. The single ~1 million line Scimark2a project takes around ~3 seconds to compile on both the 5950X and 3990X.

The Threadripper 3990X actually features 128 threads (2 threads per core) and the best setting I found for the number of compiler threads to use was 127. This is one less thread than the 128 it supports which I guess leaves 1 thread open to handle the system, Delphi Parallel Build, and everything else the machine is running. When the thread setting was set to 64 threads it did not fully utilize all 64 cores. While on the 5950X machine it didn’t make a huge difference to compile times when choosing between 16, 31, and 32 threads. 32 seemed the fastest for the 5950X.

delphi1billion 2463783

One billion lines of code is all well and good but how exactly does that translate to a real world project? Let’s look at it in terms of millions of lines of code per second or MLoC/s. The 5950X 16 core machine was able to push 3.289 MLoC/s while the Threadripper 3990X machine was able to push 13.157 MLoC/s which is pretty impressive. The AMD Ryzen 9 5950X is significantly cheaper than the 3990X as well and more in line with the pricing of standard desktop processors. For a massive project that is properly partitioned though the Threadripper 3990X brings significant productivity advantages.

delphimlocs 7254990

Now that we’ve seen how fast the Delphi compiler is for Object Pascal lets compare the C++ 1 billion lines of code compile time to the Delphi 1 billion lines of code compile time on the same Threadripper 3990X machine just for fun. The C++ Scimark2 project quad compiled with TDM-GCC 9.2 effectively took 918 seconds for all 4 projects to complete. The Delphi 10.4.1 1 billion lines of code 1000 projects took 76 seconds to complete. There is a bit of an Apples to Oranges comparison here because the C++ compiler bundled with Dev-C++ has parallel compilation support but was not able to fully utilize the 64 cores of the 3990X in a single project which is why it ended up as 4 separate projects with 250 million lines of code each. While the Delphi compiler is not a parallel compiler and was therefor split into 1000 projects instead of four. Both projects implement Scimark2 however and the same LU_factor() function was duplicated in each project.

gccvsdelphi1billion 3133123

C++ provides maximum computational performance while Delphi provides pretty good computational performance (compared to C++) and maximum productivity. With Delphi where you need more computational performance you can also call out to C++ via a DLL, use inline assembly, or even use third party math libraries like is available from DewResearch. At the same time C++Builder brings that maximum Delphi productivity to C++ for Windows applications. RAD Studio combines Delphi and C++Builder making it a powerhouse of maximum productivity and computational performance.

Working with Delphi on the AMD Ryzen 9 5950X and the Threadripper 3990X is a lot of fun and we’ve seen how modern multi-core machines can really push the performance envelope. Delphi was able to compile 1 billion lines of Object Pascal code (18.7GB) in ~76 seconds across 64 cores and 1000 projects on the Threadripper 3990X while the 5950X is no slouch either at 304 seconds and at a much more reasonable price point. The 5950X has a higher single core benchmark and clock speed as well. I’d say for truly massive Delphi projects with many hundreds of projects or for C++ the 3990X is the way to go. For small, medium, or large Delphi projects, the best in-IDE productivity, and the best price point the 5950X is the way to go.

It’s Delphi’s 26th Anniversary so Happy Birthday Delphi!

Join the celebration over at the anniversary site!

Check out Marco Cantu’s 26 Years… of Delphi post!

Investigate hundreds of different apps built in Delphi!

Additional Modern Hardware Series Reading…

Threadripper 3990X: The Quest To Compile 1 BILLION Lines Of C++ On 64 Cores

AMD Ryzen 9 5950x Powerhouse Compiles Three Fourths Of A Million Lines Of Delphi Code In 12 Seconds

Parallel Compiling 300 Native Windows Apps In 45 Seconds With Delphi On An AMD Ryzen 9 5950x

Compile 1 Million Lines Of C++ In ~2 Minutes With A 16 Core Ryzen 9 5950x

Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

Ryzen 9 5950x: Parallel Compile 124 Windows C++ Projects In ~1 Minute With 16 Cores

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

FMXExpress.com has over 600 articles with all kinds of tips and tricks for Delphi FireMonkey on Android, IOS, OSX, Windows, and Linux.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.