-
Notifications
You must be signed in to change notification settings - Fork 0
a Zarith benchmark #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: head_shape
Are you sure you want to change the base?
Conversation
|
In the benchmark numbers given above, I was testing for n=20, which only ever uses "short" integers (you need "factorial 21" to overflow 63-bit integers). On @nchataing's requests, here are benchmark numbers for n=23, which spends iterations 22 and 23 with "long" numbers: We can see in this result that the boxing of "long" integers in unboxed.ml does have an impact on performance, giving a solution that is intermediary between zarith.ml (no boxing whatsoever) and boxed.ml (both short and long numbers are boxed). But let's keep in mind that the performance of these libraries on "short" numbers is way more important in practice for most use-cases. |
51f6664 to
5674bfe
Compare
This reverts commit 3a09ced4e0391f745755972d947faa6080af6370. The overflow-counting logic may change the performance profile, so it is simpler to not have it at all in normal benchmarking mode. The figure we computed is that with BENCH_SIZE=22, 16% of operations overflow.
2f1f3e8 to
bda7606
Compare
|
I implemented preliminary support for declaring restricted shapes for abstract FFI types, and used this to unbox the |
Here is a toy benchmark for
[@unboxed]inspired by the Zarith codebase. The idea is to compare four implementations of big-integers:Objfunctions instead)type boxed = Short of int | Long of tShort int [@unboxed]cc @nchataing
The results are very nice: the unboxed implementation generates exactly the same code, in the "short" path, as the Zarith implementation, so it is exactly as fast.
(In the "slow" path where an overflow occurs, we have extra allocations in the "unboxed" version, which corresponds to the
Longconstructor. We could allow unboxing it if we supported shape constraints on abstract types, but this is not a priority.)Benchmark timings (for bytecode and native-code compilation):