SBCL quicker than C?

December 5, 2010

after reading a nice conversation on comp.lang.lisp I decided to play a little bit with SBCL and Debian’s Shootout Benchmarks.

I considered the spectral norm benchmark and compared the C and SBCL implementations.

I started re-running the tests without any further optimization and the results were similar to the ones reported with C beating SBCL by a factor of 2.
(for the C optimization used, see here).

then, I noticed that there was no (declaim (optimize (speed 3) (safety 0) (space 0))) in the SBCL file!

I’ve added it and rerun the test. here are my results:

N=500
gcc 0.15u 0.00s 0.17r
sbcl 0.08u 0.02s 0.21r

N=3000
gcc 5.60u 0.00s 5.69r
sbcl 5.18u 0.01s 5.41r

N=5500
gcc 18.81u 0.01s 19.12r
sbcl 17.42u 0.02s 17.76r

the SBCL implementation is actually faster than C!

you can find the code for the tests here.

Advertisements

13 Responses to “SBCL quicker than C?”

  1. Anon Says:

    Did you consider submitting your benchmark to shootout?

  2. lbolla Says:

    This post triggered a nice discussion, with further analysis, on Reddit.

  3. Robert Says:

    I believe you are shooting yourself in the foot. You should not use -O3 with -Os. You should only use -O3.


  4. […] Read more here Posted in Uncategorized , interesting, science, tech | No Comments » […]

  5. Mateus Caruccio Says:

    Are you considering libc load time?
    Try strace both process to see how many libs, and it’s sizes, each link to.

  6. Isaac Gouy Says:

    benchmarks game

    N CPU Elapsed
    5,500 11.14 2.80 spectral-norm C GNU gcc #4
    5,500 15.25 3.97 Lorenzo Bolla 2010-12-06 Lisp SBCL #2

    http://shootout.alioth.debian.org/u64q/benchmark.php?test=spectralnorm&lang=all

    • lbolla Says:

      The numbers shown on the post are for the benchmark run on my box.
      In fact, after seeing the results “locally”, I submitted the code to the shootout, getting the numbers you (Isaac) correctly show.

      So, different numbers on different boxes, which is not at all unexpected.

      • Isaac Gouy Says:

        Do you get similar measurements when time isn’t a makefile action?

      • lbolla Says:

        yes, same results. why would they be different?

      • Isaac Gouy Says:

        Why would the results be any different on your box?

        You haven’t provided basic information that would allow readers to understand what’s the same about the way you made your measurements and what’s different about the way you made your measurements.

        You haven’t provided basic information about “your box” or the language tools on “your box”.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: