I recently consulted for a very big Common Lisp project having more than one million lines of code (including comments). Let's call it "System X" in the following. System X suffered from extremely long compilation times; i.e., a full recompile took about 33:17 minutes on a 3.1 GHz MacBook Pro Intel Core i7 with SSD and 16 GBs of RAM, using ACL 10.1. It turns out that a number of macros were causing an exponential code blowup. With these macros refactored, the system then recompiled in 5:30 minutes - a speedup by a factor of ~ 6. In this experience report, I will first illuminate the problem, and then demonstrate two potential solutions in terms of macro refactoring techniques. These techniques can be applied in related scenarios.
翻译:笔者近期为某包含百万余行代码(含注释)的大型 Common Lisp 项目提供咨询,下文将其称为"系统 X"。该系统存在编译时间过长的问题:在配备 SSD 及 16GB 内存的 3.1GHz MacBook Pro Intel Core i7 设备上,使用 ACL 10.1 进行完整重编译需耗时约 33 分 17 秒。经排查发现,部分宏定义导致代码量呈指数级膨胀。通过重构这些宏,系统重编译时间缩短至 5 分 30 秒,加速比达约 6 倍。本实践报告将首先阐释问题成因,继而通过宏重构技术展示两种潜在解决方案,这些技术可推广应用于同类场景。