A separate GC idea - multiple D GCs

Adam Ruppe destructionator at gmail.com
Fri Jan 21 14:37:04 UTC 2022

On Friday, 21 January 2022 at 13:56:09 UTC, Chris Katko wrote:
> So a related question: Has anyone ever thought about 
> "thread-local garbage collection"

The big problem is that data isn't thread local (including TLS); 
nothing stops one thread from pointing into another thread. So 
any GC that depends on a barrier there is liable to look buggy.

So your point #3 is easier said than done in the general case. 
You can do it for special cases with fork like you said, or with 
unregistering threads like Guillaume does

> I think the simple, easiest way to try this would be to just 
> spawn multiple processes [each having their own D GC collector] 
> and somehow share memory between them. But I have no idea if 
> it's easy to work around the inherent "multiple process = 
> context switch" overhead making it actually slower.

I actually do exactly this with my web server, but it is easy 
there since web requests are supposed to be independent anyway.

re context switches btw, processes and threads both have them. 
they aren't that different on the low level, it is just a matter 
of how much of the memory space is shared. default shared = 
thread, default unshared = process.

More information about the Digitalmars-d mailing list