[Top][All Lists]

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

[Gcl-devel] Re: foo

From: Camm Maguire
Subject: [Gcl-devel] Re: foo
Date: 18 Nov 2005 20:07:10 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2


Robert Boyer <address@hidden> writes:

> I'm not quite sure I got the point with your timings of stuff like:
>    (dotimes (i 2000) (setf (aref a i) (random 2000)))
>    (time (dotimes (i 2000) (reduce '+ a)))
>    (defun foo (a) (reduce '+ a))
>    (compile 'foo)
>    (assert (= (foo a) (reduce '+ a)))
>    (time (dotimes (i 2000) (foo a)))
> So let me see if I can say what the point is.  You have figured out how
> function calls in dotimes, and presumably other, expressions now cost nothing
> at all?  What can you be doing besides straight inlining?  Amazing.

The function call to either foo or reduce from dotimes is negligible.
The real cost to many of the lisp builtins is the cost of a generic
function call to a functional argument inside the (in this case)
reduce loop, at least one per iteration, more if there are keys, etc.
The compiler macros inline any constant functional arguments
(including explicit lambda args) in lisp, allowing the optimizer to
eliminate many of the function calls from the C code entirely.  reduce
here basically gets transformed to a do loop across (funcall '+ ...)

I still at least have to finish map, substitute, remove, perhaps
search and stable-sort.  Feedback advice most appreciated,
particularly if you feel such work might be a waste of time as no one
uses these functions in the first place :-).

Take care,

> Bob

Camm Maguire                                            address@hidden
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]