On 08/25/2011 07:40 PM, bearophile wrote:
Timon Gehr:

http://pastebin.com/C6vf9DQQ

Very good.


It delivers correct results, but it takes 20min to run. (probably mainly
GC-related, I don't know)

DMD is not inlining those delegates, it is not merging streams as GHC does, etc. 
But such missing optimizations aren't the main cause of that so low performance. I 
think following those chains is a kind of worst-case for a mark&sweep GC. If I 
disable the GC using this code:


void main() {
     import core.memory, core.stdc.stdlib;
     auto h = hamming!BigInt();
     GC.disable();
     writeln(h()[1_000_000]);
     exit(0);
}


The code runs in less than 23 seconds, using about 1.5 GB RAM, on a slow 32 bit 
PC (timings on a 64 CPU are welcome). Later I'll profile the code.

Bye,
bearophile

I have already tried that, but my machine starts swapping and therefore I don't get the speedup.

What kind of GC would be fastest for that use case? Is the current GC repeatedly looping over all allocated memory blocks to find the next link to follow?



Reply via email to