Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-22 Thread bearophile
nobody, you can see how the GC interacts with your code also with the following small D1 program: import std.c.stdlib: malloc; struct S { int i; } void main() { const N = 20_000_000; static if (true) // change this to false S** sa = cast(S**)calloc(N, (S*).sizeof); else

why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread nobody
$ g++ alloc.cpp -o alloc $ time ./alloc real0m1.946s user0m1.688s sys 0m0.256s $ dmd -O -release allocd.d $ time ./allocd real0m22.734s user0m22.353s sys 0m0.360s $ cat alloc.cpp #include vector typedef std::vectorint intvec; typedef intvec* intvecp; int main() {

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread Leandro Lucarella
nobody, el 22 de mayo a las 00:08 me escribiste: $ g++ alloc.cpp -o alloc $ time ./alloc real0m1.946s user0m1.688s sys 0m0.256s $ dmd -O -release allocd.d $ time ./allocd real0m22.734s user0m22.353s sys 0m0.360s $ cat alloc.cpp #include vector

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread dsimcha
== Quote from nobody (n...@where.com)'s article $ g++ alloc.cpp -o alloc $ time ./alloc real0m1.946s user0m1.688s sys 0m0.256s $ dmd -O -release allocd.d $ time ./allocd real0m22.734s user0m22.353s sys 0m0.360s $ cat alloc.cpp #include vector typedef

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread nobody
You've probably hit a corner case for the garbage collector. When you allocate 20,000,000 Object instances and hold onto the references, the garbage collector probably runs about a zillion times and never finds anything to delete. If this is a bottleneck, you should temporarily disable

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread Robert Fraser
nobody wrote: $ g++ alloc.cpp -o alloc $ time ./alloc real0m1.946s user0m1.688s sys 0m0.256s $ dmd -O -release allocd.d $ time ./allocd real0m22.734s user0m22.353s sys 0m0.360s $ cat alloc.cpp #include vector typedef std::vectorint intvec; typedef intvec*

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread Robert Fraser
Robert Fraser wrote: nobody wrote: $ g++ alloc.cpp -o alloc $ time ./alloc real0m1.946s user0m1.688s sys 0m0.256s $ dmd -O -release allocd.d $ time ./allocd real0m22.734s user0m22.353s sys 0m0.360s $ cat alloc.cpp #include vector typedef std::vectorint intvec;

Re: why allocation of large amount of small objects so slow (x10) in D?

2009-05-21 Thread Sean Kelly
nobody wrote: You've probably hit a corner case for the garbage collector. When you allocate 20,000,000 Object instances and hold onto the references, the garbage collector probably runs about a zillion times and never finds anything to delete. If this is a bottleneck, you should temporarily