Solved

Delphi 5 build speed

Posted on 2013-06-06
12
437 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 25

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 25

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
 

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 36

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 36

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now