From: Christophe Rhodes
Subject: Summer of Code project (x86 calling conventions, SBCL)
Date: 
Message-ID: <sqhd681uti.fsf@cam.ac.uk>
One of the Summer of Code projects I proposed to the lispNYC which
ended up not being funded was to investigate the effect of calling
conventions on the x86 platform; my original proposal is still
viewable at [1].  Since some of the work in that proposal has now been
done, a report is due; this is probably the best place for it.

Juho Snellman performed some investigations on code related to but
separate from that which SBCL produces, and reported what he measured
on his blog [2]; the executive summary is that, yes, the calling
convention potentially makes a significant difference in performance
of function call on current hardware: up to a factor of four (on code
that doesn't do very much other than function calls :-).

Some time later, Alastair Bridgewater had a spare couple of hours, so
he actually came up with a patch [3] coming up with a different
convention for one of the call types (specifically the
"unknown-values" convention), as well as documentation for the
internals manual [4].  

This patch (as well as a similar one for the 64-bit x86-64 backend)
was recently merged into SBCL's CVS; the automated build-and-benchmark
machines have had some time to run, so I'll leave the interested
parties to guess which revision incorporated the patch from inspecting
one of the graphs [5].

There are other benchmarks in the Gabriel suite which test function
call; TAK, in particular.  The function call convention which SBCL
uses there suffers from the same problem as the one Alastair changed
(unpaired CALL/RET) but is sufficiently different that it did not get
reimplemented in the same changeset.

Christophe

[1] <http://www.alphageeksinc.com/cgi-bin/lispnyc.cgi?SbclCallingConvention>

[2] <http://jsnell.iki.fi/blog/archive/2005-10-12.html>

[3] <http://article.gmane.org/gmane.lisp.steel-bank.devel/6439>

[4] <http://www.sbcl.org/sbcl-internals/Calling-Convention.html>

[5] <http://sbcl-test.boinkor.net/bench/?HOST=baker&IMPLEMENTATIONS=SBCL%2C%28%3AARCH+%3AEMULATED-X86+%3AFEATURES+NIL%29&IMPLEMENTATIONS=SBCL%2C%28%3AARCH+%3AX86_64+%3AFEATURES+NIL%29&ONLY-RELEASE=0.9.10#ACKERMANN>