Notes on Refactoring Exponential Macros in Common Lisp Or: Multiple @Body Considered Harmful

Citation

Michael Wessel, arXiv:2305.02991, https://doi.org/10.48550/arXiv.2305.02991

Abstract

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.

Notes on Refactoring Exponential Macros in Common Lisp Or: Multiple @Body Considered Harmful

Keywords: Common Lisp, Macros, Exponential Code Blowup, Macro Refactor- ing, Very Large Lisp Systems


Read more from SRI

  • surgeons around a surgical robot

    The SRI research behind today’s surgical robotics

    Intuitive’s da Vinci 5 system represents a major leap in robotic-assisted medicine. It all started at SRI, which continues to advance teleoperation technologies.

  • a collage of digital graphs

    A banner year for quantum

    SRI-managed QED-C’s annual report on quantum trends captures an industry accelerating rapidly from technical promise toward major global impact.

  • ICE Cube containing SRI’s aerogel experiment, photographed prior to launch. Source: Aerospace Applications North America

    An SRI carbon capture experiment launches into space

    By synthesizing carbon-absorbing aerogels in microgravity, SRI research will give us a rare glimpse into how these materials could be radically improved.