[gambit-list] [PATCH] Patch to speed string comparisons and hashing
Bradley Lucier
lucier at math.purdue.edu
Sat Feb 23 16:39:54 EST 2008
On Feb 23, 2008, at 3:21 PM, Christian Jaeger wrote:
> Be aware that this is untested: I wanted to test it, but couldn't
> figure out how to compile Gambit from Mercurial.
>
> The Page http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/
> How_to_Contribute suggests this should work:
>
> $ make bootstrap
You need to do this with a clean 4.2.2 installation, before any of
the .scm files have been modified. Then
hg pull
make update
make
and perhaps iterate the last two. (I haven't yet worked out
precisely how to pass through a 4.X level version number change.)
> +;; Global tweaking knobs:
> +
> +(##define-macro (macro-not-interrupts-enabled-for-speed)
> + '(##declare (not interrupts-enabled)))
That's a really good idea. (It's in the same spirit as "(##define-
macro (use-fast-bignum-algorithms) #t)" in _num.scm, which trades off
speed for space.) Any loops in the bignum library that are linear in
the size of the bignum have interrupts disabled for speed; disabling
interrupts may not be so important since Marc started using the
builtin_expect form to tell gcc that it is unlikely that interrupts
will be taken at POLLs.
There are a number of places in _std.scm where raw "memmove"s are
used for speed. I suppose one could audit all uses of (not
interrupts-enabled) in the runtime to see why each of them was put
there.
> +(define-macro (combine a b)
> + `(let ((a ,a)
> + (b ,b))
> + (##fixnum.bitwise-and
> + (##fixnum.* (##fixnum.+ a (##fixnum.arithmetic-shift-left b 1))
> + 331804471)
> + (macro-max-fixnum32))))
> +
That's not a bad idea either. Perhaps if it's not local to these
functions it could be renamed hash-combine or something like that.
Brad
More information about the Gambit-list
mailing list