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

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

delphiparallel

Let’s see if we can take the Delphi compiler to the next level with the latest AMD Ryzen 9 5950x powerhouse CPU featuring 16 cores and 32 threads. According to CPU Benchmark the AMD Ryzen 9 5950x has the fastest single core CPU score right now with a score of 3524. Generally, the Delphi compiler only uses one core to build a project. On the C++Builder side there is TwineCompile which allows you to use multiple cores to build a native C++ project for Windows (and iOS). There may be some ways to push the Delphi side to do multi-core compilation with MSBuild but we will save that for another day. In the previous blog post we compiled almost 750,000 lines of generics heavy Object Pascal code in 12 seconds. The other notable CPU available right now is the AMD Ryzen Threadripper 3990x which features 64 cores and 128 threads but as you can see in the chart below from CPU Benchmark the 5950x is 37% faster per thread.

amd5950x
ryzen9-7006780
AMD Ryzen 5000 series image curtesy AMD.

The full specs on the AMD Ryzen 9 5950x benchmark machine are AMD Ryzen 9 5950x, 64GB DDR4 3200MHz RAM, 1TB NVMe SSD + 2TB HDD, NVIDIA GeForce RTX 3070 8GB, and Windows 10 Pro.

In any event we want to use the AMD Ryzen 9 5950x 16 cores and 32 threads to the maximum so we will use the Delphi Parallel Build utility which will build a number of different Delphi projects all at the same time using MSBuild. Delphi Parallel Build is an open source Delphi project built in FireMonkey that uses the Parallel Programming Library to scan and directory and build Delphi projects in parallel by passing them to MSBuild. The command line we are using for MSBuild is:

The important command line switch here is the -maxcpucount which is described as “Specifies the maximum number of concurrent processes to use when building. If you don’t include this switch, the default value is 1. If you include this switch without specifying a value, MSBuild will use up to the number of processors in the computer.” You can also find out more about the MSBuild command line options in relation to Delphi in the Embarcadero DocWiki.

Delphi 10.4.1 comes with 333 projects in it’s Object Pascal demos directory. I used Delphi Parallel Build to scan this directory and it found 333 projects. Only 300 of the projects compiled via Delphi Parallel Build with the other ~33 failing for various reason (they might not be Win32 apps or have other dependencies).

I ran Delphi Parallel Build on the Object Pascal demos directory and received a number of different compile times between 45 seconds (being the fastest) and 54 seconds. Additionally, it is running Clean before building each project which may be taking some time. Suffice to say it compiles 300 Delphi native Windows 32-bit apps in around 45 seconds.

parallelbuild-2478752

In order to monitor the CPU and Disk IO usage of Delphi Parallel Build I used Task Manager DeLuxe or TMX (which is also built in Delphi). Task Manager DeLuxe is pretty amazing in the amount of information it provides regarding your Windows system. TMX is available from MiTeC which also makes a wide varity of Delphi components that give you access to a lot of the same information found in TMX. Below is the 32 CPU thread view TMX provides. I took the screenshot shortly after Delphi Parallel Build completed building the 300 Delphi projects. You can see how it used all 32 threads and TMX also provides a handy CPU clock speed monitor as the AMD Ryzen 9 5950x turbo boosts up to 4.9Ghz.

multicore

In the next screenshot here from TMX you can see an aggregate view of the CPU usage during the compilation of the 300 Delphi projects using Delphi Parallel Build. This screenshot as also taken shortly after the compilation completed. At the bottom of the screenshot you can see the RAM usage of the benchmark machine.

multicoregraph

The last screenshot here is of the Disk IO usage during the Delphi Parallel Build compile. The machine has an ADATA Swordfish NVMe 1TB SSD (these may be the specs) which both RAD Studio and the demo projects used for the compilation were located on during the compile. The NVMe SSD is middle of the road speed wise so there is probably still room for compilation speed improvements.

diskio

This was a pretty fun exercise in compiling a massive amount of Windows apps in less than a minute and shows some of the power of a modern machine and CPU like the AMD Ryzen 9 5950x combined with Delphi. Using a powerful machine for software development can really speed up your development time. It doesn’t matter as much with Delphi because it is a single pass compiler and is already pretty fast to begin with but on larger projects (that have grown and expanded over 20 years) or a large number of projects (in this case 300) it can make a difference whether you are waiting around for your app to compile or not.


What's New for RAD Studio 11

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.
Related posts
C++DelphiRAD Studio

The High-Performance Future Of AI Is REST APIs

CodeDelphiTech Partner

How To Create Your Own Components For The FastReport Dialog

C++Code

What Are The New C++ Posts From LearnCPlusPlus.org?

DelphiRAD Studio

Delphi in the Galileo Project in Brazil

Leave a Reply

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

IN THE ARTICLES