A separate GC idea - multiple D GCs

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 21 22:56:46 UTC 2022


On Fri, Jan 21, 2022 at 02:43:31PM -0800, Walter Bright via Digitalmars-d wrote:
> On 1/21/2022 5:56 AM, Chris Katko wrote:
> > So a related question: Has anyone ever thought about "thread-local
> > garbage collection" or some sort of "multiple pool [same
> > process/thread] garbage collection"? The idea here is, each thread
> > [or thread collection] would have its own garbage collector, and, be
> > the only thread that pauses during a collection event.
> 
> Yes. The trouble is what happens when a pointer in one pool is cast to
> a pointer in another pool.

It almost makes one want to tag pointer types at compile-time as
thread-local or global. Casting from thread-local to global would emit a
call to some druntime hook to note the transfer (which, presumably,
should only occur rarely). Stuff with only global references will be
collected by the global GC, which can be scheduled to run less
frequently (or disabled if you never do such casts).

But yeah, this is a slippery slope on the slide down towards Rust... :-P
It seems we just can't get any farther from where we are without
starting to need managed pointer types.


T

-- 
Who told you to swim in Crocodile Lake without life insurance??


More information about the Digitalmars-d mailing list