Dynamic Closure + Lazy Arguments = Performance Killer?

Bill Baxter wbaxter at gmail.com
Fri Oct 24 15:50:56 PDT 2008


On Sat, Oct 25, 2008 at 7:23 AM, Frank Benoit
<keinfarbton at googlemail.com> wrote:
> Jason House schrieb:
>> 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!
>
> It was written in this NG over and over. The D2 full closure feature is
> a BIG!!!! problem.
>
> The nested functions passed as callback are an important and performance
> technique in D. The D2 full closure "feature" effectively removes it and
> makes D2 less attractive IMHO.

Not to mention that, among the top problems plaguing D2 currently, it
should be one of the easier things to fix.  Far easier than figuring
out overhauls for operator overloading, or construction syntax, or how
ranges should work, or forward reference, or figuring out how 'shared'
should work, or merging Tango and Phobos.   Compared to those it's
pretty easy to solve this one!

Personally I think no alloc should be the default, with different
syntax to get a full closure.  Using the "new" keyword somehow makes
sense to me.

--bb



More information about the Digitalmars-d mailing list