Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

optimization - 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...