[Ecls-list] ECL behavior on some array related code

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Tue May 18 19:23:19 UTC 2010


I am investigating the performance issues but one thing popped up. You are
writing things like

(defun run-array-set ()
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (let ((A (make-array '(100 100 100) :element-type 'single-float
:adjustable nil))
 (value 8.5))
    (time (dotimes (n 50)
    (dotimes (i 90)
      (dotimes (j 90)
 (dotimes (k 90)
  (setf (aref A i j k) value))))))))

Notice that TIME does not have to be "efficient" in any way. In particular
ECL uses a closure and an inner function that does the job. This means that
whenever it has to use the variable "A" in the loops it has to go through
extra effort and you are measuring not arrays but closures.

A more reasonable way would be to make sure that the variables are properly
isolated as in

(defun run-array-set ()
  (flet ((inner-loop (A value)
           (declare ..)
      ...))
    (time (funcall (make-array ...)))

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100518/391f569e/attachment.html>


More information about the ecl-devel mailing list