Dynamic Closure + Lazy Arguments = Performance Killer?
Jason House
jason.james.house at gmail.com
Fri Oct 24 18:20:38 PDT 2008
Andrei Alexandrescu wrote:
> 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!
>
> std.random does not use dynamic memory allocation.
This is exactly why so many have complained about the dynamic closure
implementation. You did not intend to use dynamic memory allocation, but
it definitely does. A program with nothing but a loop that calls uniform
will show it plain as day in the profiler. (I'm using callgrind)
> Walter is almost done
> implementing static closures.
Ooh... Can you elaborate on that?
More information about the Digitalmars-d
mailing list