Re: The myth of fingerprints, er, no, garbage collectors

"Seyi Akadri (as seyiakadri at gmail dot com)" <[email protected]> Tue, 30 Jun 2026 06:50:23 +0100
Newsgroups gmane.lisp.lispworks.general
Message-ID <CAOa1hQSW2aNwKm_C2auwMab1WX7VaX5-H+P2XaRnRZOTwSxzYA@mail.gmail.com>
--00000000000064b536065572277f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I am so grateful to be here.

I borrow the nuggets of knowledge here and integrate them into my projects,
I deliberately chose Lisp for my AI stack and loving it.

Warm greetings from Nigeria

Seyi.

On Thu, Jun 25, 2026, 5:19=E2=80=AFPM Tim Bradshaw (as tfb at tfeb dot org)=
 <
[email protected]> wrote:

> Given this silly function:
>
> (defun smash (n m)
>   (declare (type fixnum n m))
>   (let ((c nil))
>     (dotimes (i n c)
>       (setf c (cons 1 (if (zerop (mod i m)) nil c))))))
>
> You can time it.  (smash (expt 10 9) 10)) allocates about 16GB, and takes
> 25 seconds.  GC time is about 0.3% of that time.
>
> You can also watch GC time grow as it has to copy more: (smash (expt 10 9=
)
> 1000) makes lists which can grow to 1000 elts: GC now is well over 0.5% o=
f
> the time. Keeping lists of a million elements results in the GC taking 10=
%
> of the runtime.
>
> The reason I have been playing with all these things is I keep finding
> myself writing functions which carefully allow you to, for instance pass =
in
> some object which they will then reuse instead of allocating one.  And
> after trying to measure if this was worthwhile, I realised that it almost
> never is: it's better to allocate the thing on the fly and throw it away,
> because the GC will then never see it at all, whereas if you hold onto it=
,
> it will.
>
> As someone who remembers when a GC meant 'you can go and make a cup of te=
a
> now', modern GCs are wonderful things: we forget how spoiled we are.
>
> --tim
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html
>

--00000000000064b536065572277f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">I am so grateful to be here.<div dir=3D"auto"><br></div><=
div dir=3D"auto">I borrow the nuggets of knowledge here and integrate them =
into my projects, I deliberately chose Lisp for my AI stack and loving it.<=
/div><div dir=3D"auto"><br></div><div dir=3D"auto">Warm greetings from Nige=
ria</div><div dir=3D"auto"><br></div><div dir=3D"auto">Seyi.</div></div><br=
><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D=
"gmail_attr">On Thu, Jun 25, 2026, 5:19=E2=80=AFPM Tim Bradshaw (as tfb at =
tfeb dot org) &lt;<a href=3D"mailto:[email protected]">lisp-hug@lispwo=
rks.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Given this s=
illy function:<br>
<br>
(defun smash (n m)<br>
=C2=A0 (declare (type fixnum n m))<br>
=C2=A0 (let ((c nil))<br>
=C2=A0 =C2=A0 (dotimes (i n c)<br>
=C2=A0 =C2=A0 =C2=A0 (setf c (cons 1 (if (zerop (mod i m)) nil c))))))<br>
<br>
You can time it.=C2=A0 (smash (expt 10 9) 10)) allocates about 16GB, and ta=
kes 25 seconds.=C2=A0 GC time is about 0.3% of that time.<br>
<br>
You can also watch GC time grow as it has to copy more: (smash (expt 10 9) =
1000) makes lists which can grow to 1000 elts: GC now is well over 0.5% of =
the time. Keeping lists of a million elements results in the GC taking 10% =
of the runtime.<br>
<br>
The reason I have been playing with all these things is I keep finding myse=
lf writing functions which carefully allow you to, for instance pass in som=
e object which they will then reuse instead of allocating one.=C2=A0 And af=
ter trying to measure if this was worthwhile, I realised that it almost nev=
er is: it&#39;s better to allocate the thing on the fly and throw it away, =
because the GC will then never see it at all, whereas if you hold onto it, =
it will.<br>
<br>
As someone who remembers when a GC meant &#39;you can go and make a cup of =
tea now&#39;, modern GCs are wonderful things: we forget how spoiled we are=
.<br>
<br>
--tim<br>
<br>
_______________________________________________<br>
Lisp Hug - the mailing list for LispWorks users<br>
<a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"noreferr=
er">[email protected]</a><br>
<a href=3D"http://www.lispworks.com/support/lisp-hug.html" rel=3D"noreferre=
r noreferrer" target=3D"_blank">http://www.lispworks.com/support/lisp-hug.h=
tml</a><br>
</blockquote></div>

--00000000000064b536065572277f--

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html