On Thu, Aug 30, 2001 at 11:38:34PM +0100, Daniel Barlow wrote:
> "Thomas F. Burdick" <tfb@...> writes:
> > There's a thread on comp.lang.lisp where someone's asking about how to
> > micro-optimize his code in LispWorks, and it got me wondering about
> > how to do that in SBCL. I don't remember ever seeing this in the
> > CMUCL manual, but I apologize if it's covered there. So, if I had an
> > inner loop that I couldn't get the compiler to produce sufficiently
> > optimized code for, how would I go about writing it in assembly?
> It's not covered in the manual, and I doubt it's officially supported
> either. But it's something I spent some time with recently, so here's
> the short guide. Note that this is largely based on experimentation
> and looking at the source code, so is quite likely all wrong. People
> who know more than me are welcome to chime in.
Officially supported? Not likely. Trying to ensure the stability of
the interface to this kind of thing looks like a nightmare.
However, some kinds of performance hacks could be officially
supported. If there's a relevant optimization that the compiler could
make and doesn't, and you can teach the compiler to make it, I'd
probably be happy to make it a permanent part of SBCL. Examples of
this kind of thing in the reasonably recent past include
* transforms for TRUNCATE, FLOOR, and friends to avoid consing,
added to CMU CL by Raymond Toy (I think) and ported to SBCL
* my new transforms for MAP, for quantifiers (e.g. EVERY), and
for adjustable arrays
* my tweaks in the type system so that keywords and other
intersection types can be handled better
So if, e.g., you need to do some kind of operation on bit vectors and
SBCL is currently doing it badly, consider teaching SBCL to optimize
it better and submitting the optimization as a patch, rather than
writing your optimized version in inline assembly language.
(Occasionally this can be pretty straightforward, e.g. if CMU CL
compiles your bottleneck code better than SBCL, figure out why and
William Harold Newman <william.newman@...>
"Smooth duct tape: the mark of a true craftsman."
-- someone at Bettis Lab, quoted by my father
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C