Thursday  4 July 2024

Performance difference between Clisp and SBCL
=============================================

Recently I build a replacement for my static site builder,
which builds http://box.matto.nl.

I build it in Clisp, starting from scratch. When done, the compiled
binary takes 48 seconds to build the complete site, including the tag
files and the RSS feed.

My expectations were that this could run much faster when compiled
with SBCL. See also [1]

Migration to SBCL
-----------------
Today I set SBCL up to use the Quicklisp local-projects mechanism and
copied the project into the ~/quicklisp/local-projects directory.

I turned out I had to make some small adjustments due to
incompatibilities between Clisp and SBCL. For example, Clisp uses
`ext:probe-directory', which is unknown by SBCL.

Also the program has to end differently, in Clisp with `ext:exit' and
in SBCL `sb-ext:exit'.

After these minor adjustments, the code compiled fine. The result is a
much faster execution:

  `time ./static-site-builder' reported a total time of 2.4 seconds.

This is a big difference, 48 seconds with Clisp and 2,4 seconds with
SBCL. The application converts a lot of Markdown files to HTML. I
guess the main difference is that SBCL uses threading, and Clisp
doesn't.

FreeBSD jails
-------------
My small FreeBSD server, a tiny HP Elite desktop system with a Intel
Core i5-6500 CPU, has several jails. For the Lisp development I have a
separate jail for SBCL and a separate jail for Clisp, both cloned from
the same basejail. Therefor, the systems are completely comparable,
the only difference is the installation of the specific Common Lisp
package.

Closing words
-------------
I had a lot of fun and learned a lot using Clisp to build the static
site builder.

I use the outcome, the compiled static site builder, to build new
versions of my website, f.e. when a new page is added or when the
contents of a page is updated. One could say that it is "in
production". Given the big difference, the SBCL version will be used
for this.

Regarding new projects, I am not sure how to proceed, building
in Clisp, in SBCL, or building in the one and testing in the
other. We'll see how it goes.

Either way, coding in Common Lisp is fun!


[1]: gopher://box.matto.nl/0/clisp-static-site-builder-working.txt


Last edited: $Date: 2024/07/04 10:50:26 $