10 years of SBCL performance improvements


A fun little Sunday experiment idea I got after cleaning my flat, since I follow SBCL's development closely. And since the Advent of Code 2026 is approaching, I used my 2025 code as benchmark material; could have added 2024 for more data points, but too lazy.

Important disclaimer: this code is mostly Python-like CL, with very few type declarations and optimizations beyond choosing the right data/loop structures, array element type and a bit of inlining. So, uh, keep that in mind when extrapolating those results.

Building ye olde SBCL 1.3.12 §

Said version was released on 2016-11-29 according to their tarball directory (SourceForge), so this is the one I picked.

But building it with a modern thus much less lenient gcc wasn't that easy! I also encountered a problem when trying to use my current SBCL as build host and didn't want to bootstrap so I reached for the venerable CLISP to do the job.

Had to apply this ucontext fix, homogenize some C prototypes that broke function pointer compatibility and a variable redefinition angering the linker. Here's the additional patch.

After clearing the building step, I still flailed around a bit to use the result without installing it (SBCL needs to find its core and builtin modules). Fortunately, the included run-sbcl.sh script was exactly what I needed!

Preparing the code §

For more realistic results, I decided to use compile-file instead of running SBCL in --script mode, which mean I had to fix my ad-hoc loads used to include other modules and non-compliant defconstants on vectors and lists (commit; NB: triggers sr.ht's clanker blocker unless logged in).

Then I just added time macros to get my numbers, not wanting to rely on external timing to avoid any result pollution due to compilation/loading overhead.

After that, some elbow grease, duck tape, sh, AWK and matplotlib got me where I wanted.

Results §

For curiosity, I separately timed parsing (file I/O and string parsing into the ideal data structure) and solving. Each run is averaged over 20 iterations (except for day 9 that takes almost a minute) with a full GC collection between each run.

speedup.svg

Benchmarking details
  • Versions used: SBCL 2.6.10 and 1.3.12
  • Hardware: AMD 5900X, 64 GB DDR4-3600
  • Software: Gentoo Linux, linux 6.12, amd-pstate-epp/performance CPU governor

Pretty impressive gains, I'd say! Feels pretty good to just sit on your ass and reap the fruits of the valiant SBCL developers' work =)

For the curious, this branch contains all the scripts and raw benchmark results.

Bonus: block compilation §

SBCL inherited this feature from its CMUCL heritage (cf manual for more) which is kinda like gcc's -fwhole-program to my eyes.

Since I already had the whole harness ready and just needed to add :block-compile t to my compile-file, I gave it a try.

Well, as expected (since these are small programs and I often manually inline functions), no significative change except a 30% solving speedup for day 7; firmly in the realm of timing noise, with an absolute delta of only 35 µs…