Mark phase prefetching. by PeterSolMS · Pull Request #73375 · dotnet/runtime (original) (raw)

This adds prefetching to the mark phase.

The idea is that once we have established that an object is in one of the generations we want to collect, we prefetch its memory before we determine whether we have marked it already. This is because the mark bit is in the object itself, and thus requires accessing the object's memory.

As the prefetching will take some time to take effect, we park the object in a queue (see type mark_queue_t below). We then retrieve an older object from the queue, and test whether it has been marked. This should be faster, because we have issued a prefetch for this older object's memory a while back.

In quite a few places we now need to drain the queue to ensure correctness - see calls to drain_mark_queue().