D future ...

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 21 19:57:10 PST 2016


On Wed, 21 Dec 2016 11:36:14 +0000, thedeemon wrote:
> Bad news: without complete redesign of the language and turning into one
> more C++/CLI (where you have different kinds of pointers in the language
> for GC and non-GC), having C performance and Go-style low-pause GC is
> not really possible. You have to choose one. Go chose GC with short
> pauses but paid with slow speed overall and slow C interop. D chose
> C-level performance but paid for it with a slow GC.

You can implement write barriers as runtime calls, but omit them in @nogc 
code. However, this would be costly -- it's an expensive technique in 
general; the current GC mallocs each object instead of mmaping a range of 
memory; and in D you can't move heap objects safely, so you can't 
distinguish generations based on pointers (you'd have to mark GC data 
structures, and it's O(log n) to find the right one).

You can implement write barriers with mprotect. However, this won't give 
you good granularity. You just know that someone wrote something to an 8 
kilobyte block of memory that has a pointer in it somewhere. This 
requires the GC to use mmap instead of malloc, and it is strongly 
encouraged not to put pointer-free objects in the same page as objects 
with pointers.


More information about the Digitalmars-d mailing list