[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Faster structure accesses?



At  2:49 PM 2/3/94 -0500, Andrew Newell Mickish wrote:
>We have done some timing tests of our system under MCL, and found some
>surprising results.  In MCL (on a Mac IIx), an array reference is about
>4 times slower than in Allegro on a SPARCstation ELC, but a structure
>access is about 60 times slower!  Is this consistent with other people's
>experience?

The IIx runs at 16MHz. How fast is a SPARCstation ELC?

>
>Our system has been optimized for Allegro lisp, and our data structures are
>fundamentally based on DEFSTRUCT.  It would be nice if there was some way
>to speed up structure references.  We already have our optimization flags
>set to (speed 3) (safety 1) (space 0) (debug 3), which is the same as we
>do in Allegro.  Is there any way to speed up this operation?
>
>We would obviously prefer not to have a parallel implementation for the Mac,
>where we used Pascal records (with ccl:rref and friends).  However, what are
>the fastest alternatives available to us if this is the only way to get
>satisfactory performance?
>
>--Andrew Mickish

The (debug 3) optimization is causing MCL to do no inlining on structure refs.
This causes it to go out of line to the structure accessor, then go out of line
once more to a subprim to do structure access. If you leave out the (debug 3),
you'll generate a single out of line call to the subprim. If you optimize
for (speed 3) (safety 0), all the accessing will be inline. The following
was run on a Quadra 800:

Welcome to Macintosh Common Lisp Version 2.0!
? (defstruct foo a b)
FOO
? (without-interrupts
   (let ((foo (make-foo)))
     (locally (declare (optimize (debug 3)))
       (time (dotimes (i 10000) (foo-a foo))))
     (time (dotimes (i 10000) (foo-a foo)))
     (locally (declare (optimize (speed 3) (safety 0)))
       (time (dotimes (i 10000) (foo-a foo))))))
(DOTIMES (I 10000) (FOO-A FOO)) took 43 milliseconds (0.043 seconds) to run.
(DOTIMES (I 10000) (FOO-A FOO)) took 28 milliseconds (0.028 seconds) to run.
(DOTIMES (I 10000) (FOO-A FOO)) took 8 milliseconds (0.008 seconds) to run.
NIL
?