Re: The myth of fingerprints, er, no, garbage collectors
"Syed Zaeem Hosain (as Syed dot Hosain at aeris dot net)" <[email protected]> Thu, 25 Jun 2026 18:50:05 +0000
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <SA9PR18MB377490095E320360B24BAA19F0EC2@SA9PR18MB3774.namprd18.prod.outlook.com> |
--_000_SA9PR18MB377490095E320360B24BAA19F0EC2SA9PR18MB3774namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Very cool! Q: How do you measure the GC time and percentage? Am I missing something ob= vious? Thanks, Z Syed Zaeem Hosain | Founder, Chief Evangelist Aeris Communications, Inc.<http://www.aeris.com/> [email protected] a: 1731 Technology Drive, Suite 800, San Jose, CA 95110-1360, USA. o: +1 408 557-1905 | f: +1 408 557-1925 | twitter: @AerisCTO 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 2= 5 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% of = 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 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. And after t= rying 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 t= he 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 tea = 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 This communication contains Aeris Confidential Information. If it has been = sent to you in error, please reply to advise the sender of the error and th= en immediately delete this message. --_000_SA9PR18MB377490095E320360B24BAA19F0EC2SA9PR18MB3774namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-= 1"> <style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo= ttom:0;} </style> </head> <body dir=3D"ltr"> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> Very cool!</div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> <br> </div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> Q: How do you measure the GC time and percentage? Am I missing something ob= vious?</div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> <br> </div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> Thanks,</div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> <br> </div> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> Z</div> <div id=3D"Signature" class=3D"elementToProof"> <div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo= nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 10pt; c= olor: rgb(0, 0, 0);"> <br> </div> <p class=3D"elementToProof" style=3D"text-align: left; margin: 0in; font-fa= mily: Calibri, sans-serif; font-size: 11pt;"> <span style=3D"font-size: 10.5pt; color: rgb(22, 114, 190);"><b>Syed Zaeem = Hosain</b></span><span style=3D"font-size: 10.5pt; color: black;"><b> = | Founder, Chief Evangelist</b></span></p> <p class=3D"elementToProof" style=3D"text-align: left; margin: 0in; font-fa= mily: Calibri, sans-serif; font-size: 11pt;"> <span style=3D"font-size: 10.5pt; color: rgb(5, 99, 193);"><a href=3D"http:= //www.aeris.com/" target=3D"_blank" id=3D"OWAd064a471-6373-3a92-61c9-f464f6= 0e55fb" class=3D"ContentPasted0 OWAAutoLink" title=3D"http://www.aeris.com/= " style=3D"color: rgb(5, 99, 193); margin-top: 0px; margin-bottom: 0px;"><u= >Aeris Communications, Inc.</u></a></span></p> <p class=3D"elementToProof" style=3D"text-align: left; margin: 0in; font-fa= mily: Calibri, sans-serif; font-size: 11pt;"> <span style=3D"font-size: 10pt; color: rgb(5, 99, 193);"><u>Syed.Hosain@aer= is.net</u></span></p> <p class=3D"elementToProof" style=3D"text-align: left; margin: 0in; font-fa= mily: Calibri, sans-serif; font-size: 11pt;"> <span style=3D"font-size: 10pt; color: rgb(33, 33, 33);"><b>a:</b> 173= 1 Technology Drive, Suite 800, San Jose, CA 95110-1360, USA.</span></p> <p class=3D"elementToProof" style=3D"text-align: left; margin: 0in; font-fa= mily: Calibri, sans-serif; font-size: 11pt;"> <span style=3D"font-size: 10.5pt; color: black;"><b>o:</b> +1 408 557-= 1905 | <b>f:</b> +1 408 557-1925 | <b>twitter:</b> </span><span style=3D"color: rgb(33, 33, 33);">@AerisC= TO</span><br> <br> 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 ta= kes 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 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. And af= ter trying to measure if this was worthwhile, I realised that it almost never is: it's better to allocate the thing on t= he fly and throw it away, because the GC will then never see it at all, whe= reas 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> [email protected]<br> <a href=3D"http://www.lispworks.com/support/lisp-hug.html" id=3D"OWAc751aea= 3-e2be-a6c5-282e-593da8649c96" class=3D"OWAAutoLink" data-auth=3D"NotApplic= able" style=3D"margin-top: 0px; margin-bottom: 0px;">http://www.lispworks.c= om/support/lisp-hug.html</a></p> </div> <p> </p> <p style=3D"font-size:11pt; font-style: italic; font-family: 'Calibri',sans= -serif;"> This communication contains Aeris Confidential Information. If it has been = sent to you in error, please reply to advise the sender of the error and th= en immediately delete this message.</p> </body> </html> --_000_SA9PR18MB377490095E320360B24BAA19F0EC2SA9PR18MB3774namp_-- _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html