Dynamic Closure + Lazy Arguments = Performance Killer?

Gregor Richards Richards at codu.org
Fri Oct 24 14:37:21 PDT 2008


Jason House wrote:
> I ported some monte carlo simulation code from Java to D2, and performance is horrible.
> 
> 34% of the execution time is used by std.random.uniform. To my great surprise, 25% of the execution  time is memory allocation (and collection) from that random call. The only candidate source I see is a call to ensure with lazy arguments. The memory allocation occurs at the start of the UniformDistribution call. I assume this is dynamic closure kicking in.
> 
> Can anyone verify that this is the case?
> 
> 600000 memory allocations per second really kills performance!

Java has a much better garbage collector than D, as it doesn't need to 
be conservative.

  - Gregor Richards



More information about the Digitalmars-d mailing list