Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: How to organize source code to increase compiler performance?

I'm working on a large delphi 6 project with quite a lot of dependancies. It takes several minutes to compile the whole project. The recompilation after a few changes is sometimes much more longer so that it is quicker to terminate Delphi, erase all dcu files and recompile everything.

Does anyone know a way to identify, what makes the compiler slower and slower? Any tips how to organize the code to improve compiler performance?

I have already tried following things:

  • Explicitly include most of the units in the dpr instead of relying on the search path: It didn't improve anything.
  • Use the command line compiler dcc32: it isn't faster.
  • Try to see what the compiler does (using ProcessExplorer from SysInternals): apparently it runs most of the time a function called 'KibitzGetOverloads'. But I can't do anything with this information...

EDIT, Summary of the answers until now:

The answer that worked best in my case:

  • The function "Clean unused units references" from cnpack. It almost automatically cleaned more than 1000 references, making a "cold" compilation about twice faster. ("cold" compilation = erase all dcu files before compiling). It gets the reference list from the compiler. So if you have some {$IFDEF } check that all your configurations still compile.

The next thing I would like to try:

  • Refactoring the unit references manually (eventually using an abstract class) but it is much more work, since I first need to identify where the problems are. Some tools that might help:
    • GExperts adds a project dependencies browser to the delphi IDE (but unfortunately it can not show the size of each branch)
    • Delphi Unit Dependency Viewer V1.0 do about the same thing but without Delphi. It can calculate some simple statistics (Which units is the most referenced, ...)
    • Icarus which is referenced on a link in one of the answer.

Things that didn't change anything in my case:

  • Putting every files from my program and all components in one folder without subfolders.
  • Defragmenting the disk (I tried with a ramdisk)
  • Using a ramdisk for the code source and output folders.
  • Turning off the live scanning antivirus
  • Listing all the units in the dpr file instead of relying on the search path.
  • Using the command line compiler dcc32 or ecc32.

Things that didn't apply to my case:

  • Avoiding having dependencies on network shares.
  • Using DelphiSpeedUp, because I already had it.
  • Using a single folder for all dcu (I always do it)

Things that I didn't try:

  • Upgrading to another Delphi version.
  • Using dcc32speed.exe
  • Using a solid-state drive (I didn't tried it, but I tried with a ramdisk where I put all the source code. But maybe I should have installed delphi on the ramdisk too)
like image 892
Name Avatar asked May 28 '09 12:05

Name


2 Answers

Some things that could slow down the compiler

  • Redundant units in your uses clause. See this question for a link to CnPack.
  • Not explicitly adding units to your project file. You've already seem to have covered that.
  • Changed compiler settings, most notably include TDD32 info.

Try to get rid of unused units in your uses clause and see if it makes a difference.

like image 126
Lieven Keersmaekers Avatar answered Sep 21 '22 11:09

Lieven Keersmaekers


using Delphi 7 and 2009, last week I pass from almost 2 minutes for compiling and another 45 seconds from hitting f9 and get the main form of my app to 20 seconds compiling and running. This things has drive me crazy for about 6 months and nothing I tried seems to work. Using filemon from SysInternals, I realize than every unit (mostly components) that compiler requires was searched in every folder that was in Search Path, yes, this produce a LOT of FileOpen, FileExists and FileNotFound, etc. What I do was, put every DCU, DFM, RES, etc from components all in a single folder, and having just this folder in the search path, and a couple of others folders required by the project; the results were amazing. Other problem prior to the fix, was debugging. It takes almos 40 seconds in each F7, F8 key press while debuging, this has been fixed too. Hope this info can help you. Greetings form Isla de Margarita, Venezuela. Excuse my english, if any error ;)

like image 37
José Romero Avatar answered Sep 19 '22 11:09

José Romero