On Mon, 12 Feb 2001 14:50:44 -0300, "Branden" <branden_p6@hotmail.com> wrote: >Actually I was thinking something like PMCs ($@%) being copy-GCed and >referred objects (new SomeClass) being refcounted. In this case above, every >operation would use refcount's, since they're storing objects in PMCs. What >wouldn't use refcount is > > foreach $i (@a) { > $i++; > } > >Normally $i would be an alias to an element of @a, that means it would >reference the same PMC that one element of @a is referring to. If in this >case copy-GC is used, probably the GC wouldn't even be called inside of the >loop, and the whole operation would be done without overhead, even of >refcounting, even of copy-GC. I would help if we kept in mind when reference counts are actually being accessed. Your loop above doesn't use reference counts even in the current implementation. Reference counts come into play when you introduce a lexical variable, create a reference to another variable or when you do end-of scope cleanup (provided the scope contained lexicals). Also note that incrementing/decrementing the refcount is really cheap: The refcount is in the SV itself (no indirection) and you only execute a single inc/dec machine instruction for it. Going to partial refcounts does increase the runtime overhead for *all* variable: inc(sv->refcount) becomes if (sv->flags && REFCOUNTED) inc(sv->refcount) This is definitely slower for refcounted variables and probably at least not faster for non-refcounted ones: I think the bitmask test and conditional jump instruction will most likely take as much time as inc() takes longer than just a memory fetch. Let me restate the "facts" as I believe them to be true: * Full reference counts - deterministic destruction behaviour * Mark-and-sweep - faster - destroys cyclic datastructures * Partial reference counts - slower than either of the above - doesn't handle cyclical datastructures - most complex to implement This makes it kind of obvious to me that the combined approach is a non-starter. But maybe there are smarter people out there that can prove me wrong. I would love that, really! -JanThread Previous | Thread Next