FastBig is a JVM library which is attempting to provide a faster drop-in replacement for
java.math.BigDecimal. The current approach is:
A tiny version which simply provides a single implementation for BigInteger and BigDecimal with deprecated stuff removed, based on
int(assume a 64 bit world), and any other tweeks we can make to eke out a bit more performance.
- The core libs working group are not dummies. They've got a pretty good impl already kicking around, so I don't have a whole lot of hope for the tiny version to actually be that much faster...
A full version with more classes, leveraging type information to route to optimized versions and provide specialized implementation. So, for instance, there would be a
FZerotype that would simply return
negate. I think this will give us substantial JIT
- On this point, it's important to note that code is routed based on the parameter's compile-time type, not their run-time type. This can become an annoying run-around for what could be useful optimizations.
One possibility for both versions to generate the optimized version at the bytecode level via ByteScript. This might give us just a bit more edge over the Java compiler, and it also opens up invokedynamic, which is the golden hammer of JDK7.
We don't yet know if either approach is actually faster than
java.math.BigInteger. If they're not, that's interesting,
This is tested using Google Caliper on a self-compiled Mac port of OpenJDK 7, build 23.0-b12.
To run the tests yourself, you will have to install caliper on your system, which involves
downloading the files and running Maven according to their README. The only tip I have is that when you get into the
starting measured section/
done measured section loop, it will seem like your computer hung or entered an infinite loop or
something, but just let it go. It will eventually end.
This code is based off the OpenJDK 8 versions of
java.math.BigDecimal, which means that it is
all licensed under the GPLv2.