Optimized Pascal compilation time | Fredrik Haglund’s blog
Posted by jpluimers on 2018/08/14
Long uses lists especially of units circularly referencing each other are killing for compiler performance both in CPU and memory consumption.
To solve it:
Ingredients
- ICARUS – a free tool from the maker of Pascal Analyzer. [WayBack] http://www.peganza.com/products.htm. Icarus parses Delphi or Borland Pascal source code and generates a Uses Report. This report will help you remove unneeded units from your uses lists. You will also know which units that can be moved from the interface uses list to the implementation uses list.
- Uses Cleanup Tool – by Oleg Zhukov [WayBack] http://cc.borland.com/Item.aspx?id=23199.
Step-by-step
- Run ICARUS on your delphi project to get a report of which units depends on each other.
- Input this report in the Uses Cleanup tool to automatically update all uses-clauses in your source code.
- Delete all DCU-files and recompile.
Source: [WayBack] Optimized Pascal compilation time | Fredrik Haglund’s blog
Edit
Bit-rot galore!: Since Fredrik published his article, some links have vanished, so they are invalid in the above quote as well:
- [WayBack] http://cc.borland.com/Item.aspx?id=23199 moved to [WayBack] http://cc.codegear.com:80/Item.aspx?id=23199 with a retracted item.
- [WayBack] http://www.peganza.com/products.htm is moved to [WayBack] https://www.peganza.com/products.html.
Uwe Raabe was the first to notice on [WayBack] G+ Long uses lists especially of units circularly referencing each other are killing for compiler performance both in CPU and memory consumption… – Jeroen Wiert Pluimers – Google+ that the Uses Cleanup Tool by Oleg Zhukov can now be downloaded from [WayBack] Files as [WayBack] UsesCleanupceaf.zip.
Several people suggest using cnPack in the above G+ thread, but [WayBack] their Delphi parser is far behind [WayBack] Delphi AST.
Cleaning uses lists is a tough thing, it very much depends in getting the dependencies really right, then interpreting them correctly.
–jeroen






Rudy Velthuis said
FWIW, Try this for the Uses Cleanup Tool: http://www.olegzhukov.com/UsesCleanupceaf.zip?fileticket=R__cxggc2OA%3d&tabid=73&mid=402
jpluimers said
Thanks! Does it have source code available?
IL said
Unfortunately, both last version of ICARUS and its successor Peganza Pascal Analyzer Lite produce “USES.txt file corrupt” error for D7 project in Uses Cleanup Tool.
Time to refresh grammar parser code in UCT or switch it to Delphi AST (;
jpluimers said
I think Delphi AST is the way to go anyway.
jpluimers said
I have seen that happen as well.
EMB said
Cnpak has an uses cleaner too…
jpluimers said
It was suggested at https://plus.google.com/+JeroenPluimers/posts/ZeUPLAke6zv as well and I have seen https://github.com/cnpack/cnwizards/blob/master/Source/Utils/CnPasCodeParser.pas, so no thanks.