low-latency GC

IGotD- nise at nise.com
Sun Dec 6 17:35:19 UTC 2020


On Sunday, 6 December 2020 at 15:44:32 UTC, Ola Fosheim Grøstad 
wrote:
>
> It was more a hypothetical, as read barriers are too expensive. 
> But write barriers should be ok, so a single-threaded 
> incremental collector could work well if D takes a principled 
> stance on objects not being 'shared' not being handed over to 
> other threads without pinning them in the GC.
>
> Maybe a better option for D than ARC, as it is closer to what 
> people are used to.

In kernel programming there are plenty of atomic reference 
counted objects. The reason is that is you have kernel that 
supports SMP you must have it because you don't really know which 
CPU is working with a structure at any given time. These are 
often manually reference counted objects, which can lead to 
memory leaking bugs but they are not that hard to find.

Is automatic atomic reference counting a contender for kernels? 
In kernels you want to reduce the increase/decrease of the 
counts. Therefore the Rust approach using 'clone' is better 
unless there is some optimizer that can figure it out. 
Performance is important in kernels, you don't want the kernel to 
steal useful CPU time that otherwise should go to programs.

In general I think that reference counting should be supported in 
D, not only implicitly but also under the hood with fat pointers. 
This will make D more attractive to performance applications. 
Another advantage is the reference counting can use malloc/free 
directly if needed without any complicated GC layer with 
associated meta data.

Also tracing GC in a kernel is my opinion not desirable. For the 
reason I previously mentioned, you want to reduce meta data, you 
want reduce CPU time, you want to reduce fragmentation. Special 
allocators for structures are often used.



More information about the Digitalmars-d-learn mailing list