[Ecls-list] Changes in sequences

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri May 21 20:23:17 UTC 2010


I have committed about twenty or so patches reimplementing the functions
that operate on sequences. More precisely, REMOVE, DELETE, [N]SUBSTITUTE,
POSITION, FIND, COUNT are implemented using specialized iterations for
vectors and lists. Interestingly the resulting code is not only faster, but
smaller!

While there may be still corners to be polished, I am pretty happy about the
results. I benchmarked the code below which includes two cases without
consing and one that should cons a large array on each iteration.
Surprisingly ECL works better than SBCL on 64-bit platforms when no consing
is involved. If some consing is needed, the ECL/32-bits platform works worse
but this is due to the garbage collector -- something similar is experience
with plain bignums as discussed here before.

As a side effect you should find the new code much more readable and easier
to maintain. Another piece of obsolete, legacy code is flushed down the
toilet :-)

Juanjo

platform / time (seconds)
        CASE 1   CASE 2   CASE 3
ECL/32  2.586    2.531    8.841
ECL/64  0.880    0.880    2.930
SBCL/32 3.239    2.780    3.222
SBCL/64 2.209    2.052    2.206

(let ((a (make-array 1024 :initial-element 'a)))
  (time (dotimes (i 100)
          (dotimes (i 1000)
            (remove 'b a :start i :end 1000)))))

(let ((a (make-array 1024 :initial-element 'a :fill-pointer 1024)))
  (time (dotimes (i 100)
          (dotimes (i 1000)
            (setf (aref a 999) 'b
                  (fill-pointer a) 1024)
            (delete 'b a :start i :end 1000)))))

(let ((a (make-array 1024 :initial-element 'a)))
  (setf (aref a 999) 'b)
  (time (dotimes (i 100)
          (dotimes (i 1000)
            (remove 'b a :start i :end 1000)))))

-- 
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/20100521/29d34cff/attachment.html>


More information about the ecl-devel mailing list