<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is a stupid thing to test, I was just curious about it, and I’m wondering what obvious thing it is I’m doing wrong to get really bad results.<div class=""><br class=""></div><div class="">For starters, a silly little function to sum up an arithmetic series:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" class="">(defun sum-test-iterative ()</font></div><div class=""><font face="Courier New" class=""> (let ((sum 0))</font></div><div class=""><font face="Courier New" class=""> (dotimes (i 2147483647)</font></div><div class=""><font face="Courier New" class=""> (setf sum (+ sum i)))</font></div><div class=""><font face="Courier New" class=""> sum))</font></div></div><div class=""><br class=""></div><div class="">In ClozureCL 1.11, this is horribly slow and conses like crazy:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">? (time (sum-test-iterative))<br class="">(SUM-TEST-ITERATIVE)<br class="">took 62,875,836 microseconds (62.875835 seconds) to run.<br class=""> 2,818,179 microseconds ( 2.818179 seconds, 4.48%) of which was spent in GC.<br class="">During that period, and with 4 available CPU cores,<br class=""> 55,949,019 microseconds (55.949020 seconds) were spent in user mode<br class=""> 7,153,305 microseconds ( 7.153305 seconds) were spent in system mode<br class=""> 20,127,468,688 bytes of memory allocated.<br class=""> 10,397 minor page faults, 8 major page faults, 0 swaps.<br class="">2305843005992468481</font></div><div class=""><br class=""></div><div class="">SBCL 1.3.17 does much better:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">* (time (sum-test-iterative))<br class=""><br class="">Evaluation took:<br class=""> 7.741 seconds of real time<br class=""> 7.677832 seconds of total run time (7.594504 user, 0.083328 system)<br class=""> 99.19% CPU<br class=""> 18,536,585,073 processor cycles<br class=""> 0 bytes consed<br class=""> <br class="">2305843005992468481<br class=""></font><br class=""></div><div class="">If I sprinkle in some declarations I can get SBCL down to a bit over 3 seconds, but ClozureCL’s still pretty bad:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">(defun sum-test-iterative ()<br class=""> (declare (optimize speed (safety 0)))<br class=""> (let ((sum 0))<br class=""> (declare ((signed-byte 64) sum))<br class=""> (dotimes (i 2147483647)<br class=""> (setf sum (the (signed-byte 64) (+ sum i))))<br class=""> sum))</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">? (time (sum-test-iterative))<br class="">(SUM-TEST-ITERATIVE)<br class="">took 48,308,393 microseconds (48.308390 seconds) to run.<br class=""> 2,875,113 microseconds ( 2.875113 seconds, 5.95%) of which was spent in GC.<br class="">During that period, and with 4 available CPU cores,<br class=""> 42,849,312 microseconds (42.849310 seconds) were spent in user mode<br class=""> 6,040,092 microseconds ( 6.040092 seconds) were spent in system mode<br class=""> 20,127,468,707 bytes of memory allocated.<br class=""> 14,039 minor page faults, 1 major page faults, 0 swaps.<br class="">2305843005992468481</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">* (time (sum-test-iterative))<br class=""><br class="">Evaluation took:<br class=""> 3.267 seconds of real time<br class=""> 3.248668 seconds of total run time (3.228591 user, 0.020077 system)<br class=""> 99.45% CPU<br class=""> 7,821,424,512 processor cycles<br class=""> 0 bytes consed<br class=""> <br class="">2305843005992468481<br class=""></font><br class=""></div><div class="">How can I help ClozureCL out here? Both of these are running 64-bit on macOS, btw.</div></body></html>