Port a benchmark to D?
Daniel Gibson
metalcaedes at gmail.com
Sat Jun 4 09:29:26 PDT 2011
Am 04.06.2011 18:25, schrieb Timon Gehr:
>> 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
What was your time for D without disabling the GC? Probably 40-50s?
This certainly is a big improvement, I didn't think the GC slows it down
that much.
What'd be really interesting is the benchmark with a D-style
implementation of the code (if I understood correctly the current
versions are more or less direct translations of the C++ code to D).
Cheers,
- Daniel
More information about the Digitalmars-d
mailing list