On Tuesday, 18 September 2018 at 15:55:38 UTC, Nordlöw wrote:
On Tuesday, 18 September 2018 at 14:23:44 UTC, 9il wrote:
I just remember that D's GC has NO_SCAN [1] attribute!

This will be added by default when for Mir allocations if type representation tuple has not references. For example, are Slice!(double*, 2) should never be scanned by GC, but it will be in GC heap until something refers it.

Let me know if you have ideas how to further improve memory management and required API in Mir and Lubeck.

[1] https://dlang.org/phobos/core_memory.html#.GC.BlkAttr.NO_SCAN

Best,
Ilya

 Can you elaborate on why this is the case?

Mir users work with time-series, matrixes, tensors. A lot of numeric and scientific data. Almost all structures are plain. mir.series is used instead of associative arrays. Associative arrays are used only to define data set, and then AA converted to Series of immutable (represented as two arrays). In practice 99% of data are plain arrays, and ~80% of this arrays are arrays composed of doubles, ints, or POD structs. Such types does not contains references to other GC allocated memory. So, we can reduce GC latency 5 times for production code.

If a user allocates new double[], GC will scan whole array memory, because it is assumed that user may reuse this memory for types that have references.

So, the main idea, is that if one allocates a Matrix of doubles, then just turn off scanning of its internal data. Casting from array of doubles to say strings is not @safe, so we have the language instrument to prevent memory leaks for user code.

As side effect this will reduce false pointers too.

Reply via email to