DConf 2013 Day 1 Talk 6: Concurrent Garbage Collection for D by Leandro Lucarella

Vladimir Panteleev vladimir at thecybershadow.net
Fri May 24 00:55:24 PDT 2013


On Friday, 24 May 2013 at 06:52:19 UTC, Diggory wrote:
> On Tuesday, 21 May 2013 at 20:08:16 UTC, Leandro Lucarella 
> wrote:
>> I'm interested in what you're describing, but I don't know how 
>> can you
>> achieve this without fork()ing (or clone()ing in Linux). What 
>> does
>> "remap shared memory using COW" in a context where fork() 
>> doesn't
>> happen? Why do you even need shared memory if fork() doesn't 
>> happen? If
>> "remap shared memory using COW" means get a different address 
>> for the
>> same block of memory until a write happens in that block, then 
>> you can't
>> scan the roots anymore.
>>
>> I'm *very* interested in your suggestion.
>
> After doing some further investigation I think I've found a 
> fairly awesome way of doing garbage collection on windows, 
> hopefully linux has a similar mechanism. It doesn't require 
> memory mapped files or anything special, it can be done 
> retroactively, and it allows a kind of reverse copy on write 
> which is what's actually needed.
>
> When the GC is run:
> - Use VirtualProtect to mark all mutable memory pages as 
> read-only
> - Add a vectored exception handler to handle the access 
> violation exception
> - Resume the GC thread

I've tried writing a generational GC for D that used page 
protection for write barriers a while ago. IIRC, I ran into 
performance issues (the page faults were rather expensive).

This approach does have the benefit that it will not cause pages 
that have been moved to swap to be pulled out in order to be 
scanned every time, though.


More information about the Digitalmars-d-announce mailing list