Shared keyword and the GC?
thedeemon
dlang at thedeemon.com
Tue Oct 23 23:12:48 PDT 2012
On Tuesday, 23 October 2012 at 22:33:13 UTC, Araq wrote:
>>
>> OCmal's GC is one of the fastest GC ever made. And it is the
>> case because it uses immutability to great benefice.
>>
>
> According to which benchmarks? And does the fact that an object
> is immutable really need to be known at compile time for GC
> related optimizations?
I haven't seen proper benchmarks but some time ago I wrote in D
and OCaml basically the same simple program which read and
parsed some text and performed some calculations, allocating a
lot of temporary arrays or lists:
https://gist.github.com/2902247
https://gist.github.com/2922399
and OCaml version was 2 times faster than D (29 and 59 seconds on
input file of 1 million lines). After disabling GC on
reading/parsing stage and doing calculations without allocations
and using std.parallelism I made D version work in 4.4 seconds.
One place where immutability really helps is in a generational
GC: runtime needs to track all the pointers from old generation
to the young generation, if most of the data is immutable there
are not so many such pointers, this makes collection faster. When
all data is immutable there is no such pointers at all, each
object can only have pointers to older ones.
More information about the Digitalmars-d
mailing list