Re: The myth of fingerprints, er, no, garbage collectors
"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Thu, 25 Jun 2026 10:34:23 -0700
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_33276AC0-C92A-481F-91D6-03228E698ADE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 =F0=9F=91=8E > On Jun 25, 2026, at 09:22, Marco Antoniotti (as marco dot antoniotti = at unimib dot it) <[email protected]> wrote: >=20 > Rewrite it in Rust =F0=9F=99=84 >=20 > On Thu, Jun 25, 2026 at 6:19=E2=80=AFPM Tim Bradshaw (as tfb at tfeb = dot org) <[email protected] <mailto:[email protected]>> wrote: >> Given this silly function: >>=20 >> (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)))))) >>=20 >> 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. >>=20 >> 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. >>=20 >> 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. >>=20 >> As someone who remembers when a GC meant 'you can go and make a cup = of tea now', modern GCs are wonderful things: we forget how spoiled we = are. >>=20 >> --tim >>=20 >> _______________________________________________ >> Lisp Hug - the mailing list for LispWorks users >> [email protected] <mailto:[email protected]> >> http://www.lispworks.com/support/lisp-hug.html >=20 >=20 >=20 > -- > Marco Antoniotti, Professor, Director tel. +39 - 02 64 48 79 = 01 > DISCo, University of Milan-Bicocca U14 2043 = http://dcb.disco.unimib.it <http://dcb.disco.unimib.it/> > Viale Sarca 336 > I-20126 Milan (MI) ITALY >=20 > REGAINS: https://regains.disco.unimib.it/ --Apple-Mail=_33276AC0-C92A-481F-91D6-03228E698ADE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" = content=3D"text/html; charset=3Dutf-8"></head><body = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;"><span = style=3D"font-size:-webkit-xxx-large">=F0=9F=91=8E</span><br = id=3D"lineBreakAtBeginningOfMessage"><div><br><blockquote = type=3D"cite"><div>On Jun 25, 2026, at 09:22, Marco Antoniotti (as marco = dot antoniotti at unimib dot it) <[email protected]> = wrote:</div><br class=3D"Apple-interchange-newline"><div><div = dir=3D"ltr">Rewrite it in Rust =F0=9F=99=84</div><br><div = class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" = class=3D"gmail_attr">On Thu, Jun 25, 2026 at 6:19=E2=80=AFPM Tim = Bradshaw (as tfb at tfeb dot org) <<a = href=3D"mailto:[email protected]">[email protected]</a>> = wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px = 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex">Given this silly function:<br> <br> (defun smash (n m)<br> (declare (type fixnum n m))<br> (let ((c nil))<br> (dotimes (i n c)<br> (setf c (cons 1 (if (zerop (mod i m)) nil = c))))))<br> <br> 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.<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 = 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.<br> <br> As someone who remembers when a GC meant 'you can go and make a cup of = tea now', 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">[email protected]</a><br> <a href=3D"http://www.lispworks.com/support/lisp-hug.html" = rel=3D"noreferrer" = target=3D"_blank">http://www.lispworks.com/support/lisp-hug.html</a><br> </blockquote></div><div><br clear=3D"all"></div><br><span = class=3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" = class=3D"gmail_signature"><div dir=3D"ltr"><div><span = style=3D"font-family:monospace">Marco Antoniotti, Professor, Director = tel. +39 - 02 64 48 79 = 01<br>DISCo, University of Milan-Bicocca U14 2043 <a = href=3D"http://dcb.disco.unimib.it/" = target=3D"_blank">http://dcb.disco.unimib.it</a><br>Viale Sarca = 336<br>I-20126 Milan (MI) ITALY<br><br></span></div><span = style=3D"font-family:monospace">REGAINS: <a = href=3D"https://regains.disco.unimib.it/" = target=3D"_blank">https://regains.disco.unimib.it/</a><br></span></div></d= iv> </div></blockquote></div><br></body></html>= --Apple-Mail=_33276AC0-C92A-481F-91D6-03228E698ADE-- _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html