Closed gambiteer closed 7 years ago
I modified pi.scm to use the R[67]RS-required built-in exact-int-sqrt in a fork of the upstream Larceny benchmarks and sent the Larcenists a pull request, so we'll see what happens.
I also sent them a pull request for a new benchmark that uses the binary splitting on the Chudnovsky brothers' series for PI. They may like the new benchmark, it's fairly straightforward.
Larcenists have modified the pi.scm benchmark and added the chudnovsky.scm benchmark to the Larceny benchmark suite. I think these benchmarks are a much better measure of bignum performance than the version of pi.scm that you use now and I recommend you use chudnovsky.scm and the new version pi.scm in your benchmarks suite.
If you do import these new versions, then you'll need
(define (exact-integer-sqrt y)
(let ((s-r (##exact-int.sqrt y)))
(values (car s-r) (cdr s-r))))
added to src/GambitC-prelude.scm
before they will run on Gambit.
I looked at the larceny 0.99 sources, but cannot find chudnovsky.scm, and pi.scm looks like what I'm using (which is taken from 0.98 larceny, I think). Where did you find these changes?
Thanks, found it ;)
r7rs has exact-integer-sqrt.
In Gambit, if you replace square-root with integer-sqrt, and quartic root with (lambda (x) (integer-sqrt (integer-sqrt x)) then the results on my machine go from
+!CSVLINE!+gambitc-v4.8.5,pi:50:500:50:2,.7766382694244385
to
+!CSVLINE!+gambitc-v4.8.5,pi:50:500:50:2,.03497314453125
I.e., it's 20 times as fast. Perhaps it would be a better benchmark if a similar replacement were made. (In other words, perhaps you're spending most of the time in inefficient implementations of width and root, which may not be what you think the CPU is spending its time on.)