Truly lock-free multi-processor card marking
Jason Evans <[email protected]> Mon, 02 Jul 2007 15:19:41 -0700
| Newsgroups | gmane.comp.programming.garbage-collection.general |
|---|---|
| Message-ID | <[email protected]> |
I am implementing a multi-threaded programming language that uses card marking to implement the write barrier for generational GC. Since multiple threads can simultaneously write to objects within the same card, it is necessary to assure that the card state "bits" are not corrupted due to their proximity with each other. My question is, how small can these "bits" be, before we have to use some sort of synchronization, such as atomic operations? During normal operation, the write barrier simply writes the value of a card state "bit". If we actually use a bit vector, we have to load a byte, modify the byte, then write the byte. However, if we use a byte per card state "bit", we can in concept simply write the byte (write, versus read-modify-write). Unfortunately, I suspect that the actual write quantum may be larger, depending on addressing modes (byte-addressable versus word-addressable) and the cache coherency implementation. As long as writing the card state "bit" is purely a write (and assuming we use the appropriate memory barriers during mutator suspension to assure that the garbage collector sees all such writes), we can get away without doing any locking whatsoever. My default solution is to use size_t bytes per card state "bit", but it would be nice to be able to reduce the memory overhead. I have searched in vain for several hours now, trying to find any information for amd64/x86_64 about the minimum quantum that can be written to without danger of the write being converted to read-modify-write. Any information, whether specific or general, is much appreciated. Thanks, Jason Evans