Optimizing Common Lisp
a year ago
- #Performance Optimization
- #Common Lisp
- #Parser Combinators
- The author used sb-sprof, a statistical profiler in SBCL, to identify CPU and memory allocation hotspots in their Common Lisp Parser Combinator library.
- By profiling, they improved the runtime speed of the parcom/json module by 3x and reduced memory allocation by 25x.
- Key optimizations included replacing list allocations with slices, using schar for faster string access, and leveraging multiple-value-bind to reduce garbage collection.
- Stack allocation of local variables and caching of lambda closures were also employed to further reduce memory usage.
- The article emphasizes the importance of profiling to guide optimizations and demonstrates that parser combinators can be both elegant and performant in Common Lisp.