Subject: Re: How can "cons per call" be so different for these two very similar functions?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 02 Sep 2006 21:50:48 -0500
Newsgroups: comp.lang.lisp
Message-ID: <fsydnat4LKyV3mfZnZ2dnUVZ_tydnZ2d@speakeasy.net>
Stephen Compall  <stephen.compall@gmail.com> wrote:
+---------------
| Rob Warnock wrote:
| > The main advantage to the LOOP version is that it [probably]
| > uses an internal cached tail pointer to implement the COLLECTs,
...
| 
| On some implementations, PUSH/NREVERSE can be faster than chasing tails.
+---------------

And on some implementations, PUSH/REVERSE can be faster than
PUSH/NREVERSE -- it all depends on the size of the list being
reversed, the nature of the GC, and, for generational GCs, the size
of the nursery. Oh, and the cost of recording stores into older
generations ["remembered sets"]. Specifically, with generational
GCs and with very large argument lists, chasing tails is often the
fastest, since it leaves the oldest members of the result list(s)
unmodified, and thus the mutator doesn't have to record remembered
set information for stores into the part of the result list(s) that
was already promoted out of the nursery [since there aren't any such
stores, except for the one variable that holds the tail pointer].


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607