[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CLOS Speed
- To: Brad.Myers@a.gp.cs.cmu.edu
- Subject: Re: CLOS Speed
- From: Gregor.pa@Xerox.COM
- Date: Fri, 24 Jun 88 16:49 PDT
- Cc: commonloops.pa@Xerox.COM, email@example.com
- Fcc: BD:>Gregor>mail>outgoing-mail-2.text.newest
- In-reply-to: <19220.127.116.11.21.48.Brad.Myers@A.GP.CS.CMU.EDU>
- Line-fold: no
Date: Fri, 24 Jun 88 10:36:58 EDT
Our project is using the February 3rd, 1988 version of PCL (CLOS). I
am trying to convince our group to continue to use CLOS, but the problem
is that the speed of slot access and method call is so slow that we are
thinking of using a home-brewed object system. Our measurements show
that using CLOS is between 3 to 5 times slower than using structs and
procedure calls on CMU Common Lisp on an IBM-RT. The times we are getting
Simple CLOS Slot access: 17 microseconds
Simple struct access: 4.7 "
Method call: 56 "
Procedure call: 20 "
You can expect to see some improvement in these times. Particularly the
time take by slot access. You should expect something like the
* Ordinary method call will be between 2 and 3 times a corresponding
function call. It may well be close to 2, but it is unlikely to go
below that. Your time will certainly go down some from where it is
now, but how much is unclear.
Method call of a method which uses slot-value in its body will be
slightly slower. Expect it to be slower by about 25% of a function
Method call of a method which uses call-next-method will be slower
than ordinary method call. It may be as much as a factor of 1
function call slower.
These last two times are additive, so if you have a method which uses
both call-next-method and slot-value in its body it will take about
1.25 times a procedure call more than ordinary method call.
Ordinary procedure call: 1
Ordinary method call: 2-3
Method with slot-value: 2.25-3.25
Method with call-next-method: 3-4
Method with call-next-method and slot-value 3.25 - 4.25
* Slot access done by calling an accessor method will take about 1.3
times the time take by an ordinary procedure call.
* Slot access done by using slot-value inside the body of a method will
take time equivalent to that shown by the following code. This is
basically the time taken by two memory reads.
(defmacro aref* (array dimension)
;; This is a version of aref that runs like the wind.
;; It doesn't have to check that the array is an array,
;; it can count on that. It doesn't have to check that
;; the dimension is within the array bounds. It can
;; count on that.
`(locally (declare (optimize (speed 3) (safety 0)))
(aref ,array ,dimension)))
(defun test (x)
(let ((array-1 (make-array 3 :initial-contents '(1 2 0)))
(array-2 (make-array 3 :initial-contents '(x y z))))
(dotimes (i x)
;; This is the simulated code for the
(let ((offset (aref* array-1 0)))
(if (null offset)
(aref* array-2 offset)))))))