[Openmcl-devel] Understanding the impact of consing

Gary Byers gbyersnm at gmail.com
Sat Aug 6 10:05:21 PDT 2016


I read and enjoyed the blog post.


I think that it's important to note that a lot of consing

is "imcidental" and involves very short-lived objects. All

other things being equal, the cost of this incidental consing

is often very low, as are the the benefits of reducing it


two similar functions can have very different effects on GC

time.  Both functions will create N conses; in DROP, each cons

will become garbage almost immediately, but in KEEP each.   cons

will be kept alive by the reference to it in the L argument.  It may

I read anbe interesting to compare the execution times of calls to these 
functions.



(defun keep (n l)
   (unless (zerop n)
     (keep (1- n) (cons l nil))))

(defun drop (n l)
   (unless (zerop n)
     (drop (1- n) (cdr (cons l nil)))))

At one point, the post speculates that "compaction [by the GC) might

be helping"; I don't think that t was that long ago when Lisp programmers

recognized that memory reorganization performed by a GC could be a

very good thing.  I'm not sure if that's been forgotten, but it 
sometimes seems

that way


On 08/06/2016 07:21 AM, Max Rottenkolber wrote:
> Hi everyone,
>
> I have written a blog post about the challenges I encountered during the
> development of MaxPC,¹ a combinatory parsing library. In one section I talk
> about how consing affects performance on CCL (or not), and I don't have answers
> to some of my observations. I would be extremely grateful to someone with a
> better understanding of CCL internals than me to fact/sanity check the section
> “To Cons, or Not to Cons?” specifically:
>
>    http://mr.gy/blog/maxpc.html#section-3-2
>
> (I would include a text version, but without the diagram it makes little
> sense.) Understanding what’s going on might require reading the source (links
> to the relevant sections are in the benchmark diagram description), which is
> probably too much to ask, but who knows, maybe someone finds this as
> interesting as I do.
>
> Thanks in advance to anyone who donates their attention.
>
> Cheers,
> max
>
> [1]: https://github.com/eugeneia/maxpc
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list