Thread-local GC?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 9 20:20:46 PDT 2014


> Sent: Wednesday, July 09, 2014 at 7:51 PM
> From: "logicchains via Digitalmars-d" <digitalmars-d at puremagic.com>
> To: digitalmars-d at puremagic.com
> Subject: Thread-local GC?
>
> I was wondering if thread-local GC had been considered an option
> for making D's GC work better in threaded code? Erlang has this
> (well, process-local GC, which is closer to fibre-local in D
> terms) and it seems to work okay, although I don't think Erlang
> allows shared memory between processes.
>
> If this were possible, it would be particularly useful if it
> could be combined with nogc to allow the spawning of nogc
> threads. These could be used for latency-sensitive work, with the
> guarantee that work done in a nogc thread would never be paused
> by garbage collection done in other threads.

It's a good idea in principle, but the fact that you can cast to and from
shared and immutable throws a major kink in it. Those casts would have to have
hooks of some kind to allow for that to work. I don't know how feasible that
is, but the fact that you can overload opCast with regards to shared and
immutable makes hooks like that rather problematic.

So, if we can figure out how to do it, great, but the fact that D's a systems
language has a tendancy to make some stuff like that not work as easily as
would be nice.

- Jonathan M Davis


More information about the Digitalmars-d mailing list