Dynamic Closure + Lazy Arguments = Performance Killer?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Oct 24 18:20:25 PDT 2008
Bill Baxter wrote:
> On Sat, Oct 25, 2008 at 9:59 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> 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.
>
> Well the suggestion is that it may be using dynamic memory allocation
> without intending to because of the dynamic closures. Are you saying
> that is definitely not the case?
I don't think there's any delegate in use in std.random.
>> Walter is almost done implementing static closures.
>
> Excellent! So what strategy is being used? I hope it's static by
> default, dynamic on request, but your wording suggests otherwise.
I forgot.
Andrei
More information about the Digitalmars-d
mailing list