Thomas Fischbacher <[EMAIL PROTECTED]> writes: > Dear LISP hackers, > > yesterday, a colleague of mine caused quite some confusion on my side by > showing to me a function he had written to calculate the system of > positive roots of a semi-simple finite-dimensional Lie algebra (blah blah > - does not matter). This is given as cartan->posroots-v1 in the > attachment. I tried to make it fast by heeding the compiler's notes and > giving additional type declarations (there are also a lot of > consing-reduction techniques that can be applied, I know, and our current > version has all of them); amazingly, when I gave CMUCL enough type > info so that the function compiled without notes (see the -v2 variant), > the resulting code turned out to be *slower* by a factor 2. > > > *What* is going on here?
I don't know for sure, but I also observed that declaring something to be FIXNUM does not help very much, so I dropped it in many cases. (It is quite clear that it will not help much, because FIXNUMs have a compact representation which has only little overhead when being manipulated, but it is of course strange that declarations make code slower. Maybe someone else knows more.) Some other remarks on your code: First, I would suggest dropping all the special macros like i-dotimes (hint: macroexpand dotimes), often CMUCL can find out itself if something is a fixnum, especially if you declare types more specifically like (integer 0 1000). Second, you should use iteration instead of recursion whenever possible (your array*vector looks rather Schemeish, and could probably be accelerated very much - even more, if you simply hard-code the trivial array structure of Ex). Last, use the profile package to find out where the hot spot really lies. Nicolas.
