Port a benchmark to D?

Timon Gehr timon.gehr at gmx.ch
Sat Jun 4 09:25:55 PDT 2011


> Andrei:
>
>> Far as I can tell D comes in the second place after C++ at run time.
>> With optimizations and all it could get significantly closer.
>
> First version, with just classes, a bit better cleaned up:
> http://codepad.org/DggCx26d
>
> Second version, with all structs:
> http://codepad.org/etsLsZV5
>
> Tomorrow I'll de-optimize it a bit replacing some structs with classes. And >
then I'll create one or two more optimized versions (one using a memory pool for
the nodes, and one trying to apply some of the C++ improvement ideas > from the
original paper).
>
> The number of instances allocated:
> Class instances:
> SimpleLoop_counter            3_936_102
> LoopStructureGraph_counter       15_051
> UnionFindNode_counter        13_017_663
> HavlakLoopFinder_counter         15_051
> BasicBlockEdge_counter          378_036
> BasicBlock_counter              252_013
> MaoCFG_counter                        1
>
> UnionFindNode probably will give some gain if allocated from a pool.
>
> Later,
> bearophile

One simple but very powerful optimization is to minimize the runs of the GC. I
have added a call to GC.disable(); in the beginning of main and then added a
GC.collect(); after each 10 test runs.

Results on my machine (32bit executables):

C++ (-O2): 30.7s, ~170MB.
D (-release -O -inline): 29.5s, ~520MB

Ds GC needs to get faster. A concurrent GC would have hidden away most of the
overhead on a multi-core processor ;).

Timon


More information about the Digitalmars-d mailing list