integer speed #443
Replies: 4 comments
-
SBCL is very likely constant-folding all function calls since A and B
are effectively constant, so you're comparing apples with oranges.
You need to construct your test function differently - have A and B be
arguments to the function rather than variables in the code and then
redo the test by calling (integer-speed (expt 10007 8000) (expt 10009
8000)).
…On 10.03.2023 08:02, Barton Willis wrote:
Hi,
I'm a developer for the Maxima Computer Algebra system. Our testsuite
has some new tests that require dividing 1000s of numbers with tens of
thousands of digits. Maxima compiled with Clozure CL is much slower on
these tests than is Maxima compiled with SBCL. Here is a little
demonstration of the speed of arithmetic on large integers
|(defun integer-speed () (let ((a (expt 10007 8000)) (b (expt 10009
8000))) (time (/ a b)) (time (gcd a b)) (time (floor a b)) 0)) |
Using Clozure CL, I get
|? (integer-speed) (/ A B) took 3,581,000 microseconds (3.581000
seconds) to run. During that period, and with 4 available CPU cores,
3,578,125 microseconds (3.578125 seconds) were spent in user mode 0
microseconds (0.000000 seconds) were spent in system mode 128 bytes of
memory allocated. (GCD A B) took 3,491,000 microseconds (3.491000
seconds) to run. During that period, and with 4 available CPU cores,
3,468,750 microseconds (3.468750 seconds) were spent in user mode 0
microseconds (0.000000 seconds) were spent in system mode 96 bytes of
memory allocated. (FLOOR A B) took 0 microseconds (0.000000 seconds)
to run. During that period, and with 4 available CPU cores, 0
microseconds (0.000000 seconds) were spent in user mode 0 microseconds
(0.000000 seconds) were spent in system mode 13,376 bytes of memory
allocated. 0 |
For one bit of Maxima code, I was able to find a workaround that
replaced divide with floor. That greatly increased the speed of these
new tests.
Using SBCL, these same three tests are fast:
|* (integer-speed) Evaluation took: 0.000 seconds of real time
0.000000 seconds of total run time (0.000000 user, 0.000000 system)
100.00% CPU 441 processor cycles 0 bytes consed Evaluation took: 0.000
seconds of real time 0.000000 seconds of total run time (0.000000
user, 0.000000 system) 100.00% CPU 444 processor cycles 0 bytes consed
Evaluation took: 0.000 seconds of real time 0.000000 seconds of total
run time (0.000000 user, 0.000000 system) 100.00% CPU 458 processor
cycles 0 bytes consed 0 |
Any tips on making big number arithmetic faster under Clozure? Thanks.
--Barton Willis
—
Reply to this email directly, view it on GitHub
<#443>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSZHKXV2MVIWHAZLRJNXP3W3LGYJANCNFSM6AAAAAAVWBI3WA>.
You are receiving this because you are subscribed to this
thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
(defun integer-div (a b)
(/ (expt a 8000) (expt b 8000)))
(defun integer-gcd (a b)
(gcd (expt a 8000) (expt b 8000)))
(defun integer-floor (a b)
(floor (expt a 8000) (expt b 8000)))
(defun integer-speed (n)
(time (loop repeat n :do (integer-div 10007 10009)))
(time (loop repeat n :do (integer-gcd 10007 10009)))
(time (loop repeat n :do (integer-floor 10007 10009))))
(integer-speed 100) CCL v1.12.1-9-g14dd8939
SBCL 2.3.2
|
Beta Was this translation helpful? Give feedback.
-
SBCL uses GMP code to do the heavy lifting for bignums while CCL does it all in Lisp. I'm planning on rewriting CCL's bignum implementation to use e.g. Karatsuba multiplication and more assembly language which should alleviate some of these issues. It's on the agenda. |
Beta Was this translation helpful? Give feedback.
-
Good to hear that you all are planning to rewrite CCL's bignum code. When it's available, I'll test it using Maxima. For Maxima, I'll likely commit a patch that replaces a circa 1968 bit of code that uses a combination of
This change speeds up these new tests by a factor of about 15. Thanks to all who responded. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm a developer for the Maxima Computer Algebra system. Our testsuite has some new tests that require dividing 1000s of numbers with tens of thousands of digits. Maxima compiled with Clozure CL is much slower on these tests than is Maxima compiled with SBCL. Here is a little demonstration of the speed of arithmetic on large integers
Using Clozure CL, I get
For one bit of Maxima code, I was able to find a workaround that replaced divide with floor. That greatly increased the speed of these new tests.
Using SBCL, these same three tests are fast:
Any tips on making big number arithmetic faster under Clozure? Thanks.
--Barton Willis
Beta Was this translation helpful? Give feedback.
All reactions