Solved

Delphi 5 build speed

Posted on 2013-06-06
12
449 Views
Last Modified: 2013-06-28
I have an application with 1.56 million lines of code in Delphi 5. I am compiling it on a Lenovo computer i5, 6 GB of RAM, 500 GB 7200 RPM hard drive. When I build the project, it takes approximately 15 min. The first 500,000 lines of code fly by, and then the compiler indicates it is working on one unit at a time, often taking many seconds to compile a single unit with perhaps 1000 lines of code within it. The project is not build any faster when I use DCC32.EXE ( outside the IDE). I don't know why the build starts out so fast and then slows down so much. My best guess is that there are many unit dependencies which Delphi is trying to sort out before compiling the next unit. It is not feasible for me to break it into packages; the project builds it into 2 different versions which use virtually all of the units based on conditional compiler directives embedded within the units. When I look at the Resource Monitor, I am only using 25% of the CPU, and about 4 GB of the 6 GB of RAM. It does not appear that the hard drive is getting much use at all when it slows down; I don't think it is spending its time reading data from the hard drive. I am wondering if upgrading to an i7 or more RAM will make any appreciable difference in the build time, or whether there are any other tricks to speeding up the build process. I am reluctant to upgrade to a newer version of Delphi, because in the past I have upgraded multiple versions of Delphi and each time I had to make extensive changes to my source code because they did not make the new version 100% compatible with the previous version, and locating all of the changes in the source code that need to be modified and tested in a project this size would be a very daunting task. Furthermore, I'm not sure that upgrading to a new version of Delphi would necessarily speed up the build process.
0
Comment
Question by:Onionsinger
  • 6
  • 2
  • 2
  • +1
12 Comments
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39225679
Did you click on Compile or Build project? Do you have checked Optimization in Project/Options/Compiler?
0
 

Author Comment

by:Onionsinger
ID: 39227692
I am referring to Building, not Compiling, the project. (Compiling is fast if I just make a few changes; Building is the slow issue). Yes, I have Optimization checked in Project/Options/Compiler.
0
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39228139
Always use compile. Building is using in very rare case when you want to make release 4 example. Delphi is very "smart" and knows what is changed and what is not - and what is not - it is not compiled - and don't needs to be.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Onionsinger
ID: 39228613
As I explained above, I cannot always compile. My program consists of 2 different versions, which vary based on settings of conditional compiler directives. Each time I wish to switch from one version to the other, I must build the program all over again so that each unit is recompiled based on the different conditional compiler directives.
i.e.
{$IFDEF MainVersion}
Caption:='Main Version';
{$ELSE} {other version}
Caption:='Other Version';
{$ENDIF} {other version}

The program consists of hundreds of thousands of sections of code which look like the above in which some code is compiled in one version, and other code is compiled in the other version. One has to build the project, changing the conditional compiler setting, in order to re-create each version. If one simply changes the conditional compiler setting and presses Compile instead of Build, Delphi fails to compile as soon as it hits a unit which is still built using the other conditional compiler setting. It is not feasible from a maintenance point of view to have all the code of one version in one set of units and all of the code of the other version in a different set of units; that ends up requiring that any changes I make in one unit I have to make sure I make in the other unit in exactly the same place.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39228770
check if the folders containing your source files are in the exclusions of the virusscanner
virusscanner can check every access to a file and cause slowdown

putting the folder in the exclusions (.dfm + .pas) can help
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39228785
lol, compiler directives ... are a real pain
a long time ago i did a project on a few projects with such directives and reworked the code to avoid all the compiler directives
 > the pain was compiler directives in common code of 3 projects.
 > once the directives were removed, these issues you seem to have also, were resolved
 > we couldn't work simultaneously on 2 projects at the same time, after that resolving we could

it's possible to program around that so you don't need them
> units would only need to be compiled once no matter what version you need
0
 

Author Comment

by:Onionsinger
ID: 39231834
1. Thank you for the suggestion regarding my virus scanner. I have Norton 360. I could not find a place where I could specifically tell it to skip checking certain files. I therefore tried disabling it altogether and timed how long it took to build the project with Norton 360 enabled versus disabled. In both cases it took 19 min., virtually indistinguishable amount of time difference. This does not surprise me because when I watch the compiler during the build process, as I stated it flies through the first 500,000 lines in a few seconds, opening dozens of files without any apparent slowness; then it crawls along, naming one file at a time for many seconds; I cannot imagine that Norton is causing this behavior since it would seem to me it would slow it down for each file or none of them but not just the ones being opened after the first 500,000 lines of code. So I don't believe that this will speed up the build process.
2. Although it might be theoretically possible to write the program in such a way that all of the units of one version do not overlap any of the units of the other version, this program is so complex that I am doubtful that that is even possible. Even if it were possible, it is not practical for me to go through all 1.5 million lines of code and rewrite them into new separate units. So I don't consider this to be a solution to my question.
3. My real question is that I'm contemplating buying a new computer and I am wondering whether Delphi will build the program faster if I have a faster processor, faster RAM, a faster hard drive etc.  My gut feeling is that the rate limiting step inside Delphi is the processor in this case rather than the RAM or the hard drive given the data that I described in my first posting, but I don't know if there is anyone out there who knows the actual inner workings of Delphi's compiler to know what is slowing it down after the first 500,000 lines of code.
0
 
LVL 1

Expert Comment

by:Syntess
ID: 39265132
Try using the fixes created by Andreas Hausladen. He does a really good job improving the speed of the Delphi IDE. I would suggest the following fixes:
DCC32Speed: Improves the speed of the compiler
Delphi Speedup: Improves the speed of the Delphi IDE.
While you're at it, also download DDevExtensions from his site, it has very useful features like disabling the annoying "Source has been modified. Rebuild?" dialog and making backups of your sourcefiles after every succesfull compile. Keep in mind to download the versions for Delphi 5.
0
 

Accepted Solution

by:
Onionsinger earned 0 total points
ID: 39269744
I moved to a faster computer and it made a little difference. The new computer is i7 at 2.7 gHz with 8 G RAM, same size & speed hard drive, plus a 16GB SATA drive, and it comes down from 19 minutes on the i5 at 2.6 GHz with 6 G RAM to 14:42.
0
 

Author Comment

by:Onionsinger
ID: 39269795
I tried DelphiSpeedUp on the faster computer (i7 2.7 gHz) and it shaved the time down from 14:42 to 14:30.  Not a big difference, but I award the solution to Syntess. It appears to me that the likely rate-limiting factor is the CPU speed. In all cases (i5, i7 without Delphi SpeedUp, and i7 with DelphiSpeedup), the compiler zooms through the first 500K lines in just a few seconds, then slows to a crawl for the final 1000K lines.
0
 
LVL 1

Expert Comment

by:Syntess
ID: 39270458
Besides DCC32Speed and DelphiSpeedup, you could try to remove all unused units from the use and remove circular references. See this answer on StackOverflow.
0
 

Author Closing Comment

by:Onionsinger
ID: 39283781
It did speed up the compiler by 12 seconds (out of 14 minutes 42 seconds) which is something but not very much.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question