On Mon, Dec 20, 2010 at 4:39 PM, Marijn Haverbeke <[email protected]> wrote:
> > 1. multi-threaded RC operations are going to be atomic -> expensive. > > In case this idea hasn't been floated before (I didn't read the list > archives) -- wouldn't it be a very good idea to have a task-local > refcount, and only atomically decrease the central refcount once the > task-local one reaches zero. This would require the references to be > (pointer, local-refcount) pairs, so it adds some indirection and > overhead, but seems vastly superior to an approach that would do > atomic central counting. > You might even be able to do pointer-tagging to store e.g. a 2-bit ref count in the lower bits of the pointer (corresponding to 1, 2, 3 references, or "unknown, consult global refcount", i.e. 0). This adds a bunch of extra instructions per refcount op, but at least doesn't require global synchronisation for many cases (only twice for objects with less than 4 local ref counts), you'd probably still want to only do this for shared objects, though. -- Sebastian Sylvan
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
