Fixnums: last mile for JRuby math perf
Per Bothner
per at bothner.com
Sun Jun 15 22:48:02 PDT 2008
Charles Oliver Nutter wrote:
> On a side note: any recommendations for optimizing fixnums on current
> JVMs?
"Optimizing fixnums" is of course a number of different problems.
One is "optimizing generic arithmetic" on unknown types - most
of which will be fixnums.
Kawa does pretty well on optimizing arbitrary-precision integers.
It wins over java.math.BigInteger by using just two fields, one
which is an int and on is an int[]. The latter is only non-null
when the value of the integer doesn't fit in the bounds of int.
I think this would be a worthwhile optimization for BigInteger.
The various operations "fast-path" the common case when the values
fit into an int (and thus the int[] is null).
Kawa also does preallocate the number -100 .. 1024. I haven't
done any measurements to see if this is a good range to
pre-allocate - that might be useful to get some numbers on.
--
--Per Bothner
per at bothner.com http://per.bothner.com/
More information about the mlvm-dev
mailing list