What's the go with the GC these days?

Neia Neutuladh neia at ikeran.org
Wed Jan 9 01:09:18 UTC 2019


On Wed, 09 Jan 2019 00:24:14 +0000, Ola Fosheim Grøstad wrote:
> On Tuesday, 8 January 2019 at 18:04:26 UTC, Neia Neutuladh wrote:
>> We can shorten the stop-the-world phase to the size of shared memory.
>> If you're only sharing a little data and have a decent number of
>> threads, this would be a big improvement.
> 
> Pointer storage isn't limited to shared memory?

1. Stop all the threads.
2. Scan shared memory: everything that's been allocated as shared, 
everything that's been explicitly casted to shared, and everything 
reachable from those objects. Use that to mark things in the current 
thread's local GC heap as reachable.
3. Resume every thread but this one.
4. Run mark/sweep on the current thread's heap.
5. Resume this thread.

If you have a small amount of shared memory, the stop-the-world phase would 
be pretty short.

As an alternative, this could hijack all the threads to run a parallel 
mark/sweep, where each individual thread can resume as soon as its own 
local mark/sweep finishes. If you have a worker thread that deals with 
very few pointers, it can resume very quickly after the shared mark/sweep 
phase.


More information about the Digitalmars-d mailing list