www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18937] New: [REG 2.080.0] std.experimental.allocator:

https://issues.dlang.org/show_bug.cgi?id=18937

          Issue ID: 18937
           Summary: [REG 2.080.0] std.experimental.allocator: compiling
                    `make` needs an unreasonable amount of memory for
                    structs that contain static arrays
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

test.d:
----
import std.experimental.allocator: make;
 safe unittest
{
    static struct S
    {
        version (small) ubyte[1024] data;
        else version (large) ubyte[4 * 1024] data;
        else version (vlarg) ubyte[16 * 1024] data;
        else static assert(false);
    }

    static struct SomeAllocator
    {
        ubyte[] allocate(size_t) { return []; }
        void deallocate(void[]) {}
    }

    auto x = SomeAllocator().make!S();
}
----

With 2.079.1, all three versions compile quickly, and DMD needs about 40 MiB of
memory for all of them.

With 2.080.0, compilation needs an unreasonable amount of time and memory. The
vlarg version exceeds 4 GiB and 1 minute.

`for dmd in dmd2.079 dmd2.080; do for v in -version=small -version=large
-version=vlarg; do /usr/bin/time -f "$dmd $v: time: %E, memory: %M KiB" $dmd -c
-unittest $v test.d; done; done`:
----
dmd2.079 -version=small: time: 0:00.12, memory: 40272 KiB
dmd2.079 -version=large: time: 0:00.11, memory: 40368 KiB
dmd2.079 -version=vlarg: time: 0:00.12, memory: 40920 KiB
dmd2.080 -version=small: time: 0:00.43, memory: 133276 KiB
dmd2.080 -version=large: time: 0:04.52, memory: 1342532 KiB
Error: out of memory
Command exited with non-zero status 1
dmd2.080 -version=vlarg: time: 1:29.09, memory: 3713344 KiB
----

The culprit seems to be std.experimental.allocator.common.isAllZeroBits. I'm
looking into fixing this there.

--
Jun 03 2018