PROPOSAL: fold keyword
Joseph D. Darcy
Joe.Darcy at Sun.COM
Tue Mar 10 10:43:41 PDT 2009
Tim Peierls wrote:
> On Tue, Mar 10, 2009 at 11:51 AM, Gabriel Belingueres <belingueres at gmail.com
>
>> wrote:
>>
>
>
>> I'm not specially familiar with this library, but seems like it is the
>>
>>
> concurrent equivalent to what can be done with the Apache Commons
>
>> Collections.
>>
>
>
> It's a bit different from Apache Commons Collections. I think of it loosely
> as MapReduce for an in-memory array.
>
> The big reason to use ParallelArray is that is performs very well on
> multiprocessors without the user having to write special code to take
> advantage of parallelism. Interestingly, when I first experimented with it I
> saw a speedup of ParallelArray over equivalent sequential code on a machine
> with one hyper-threaded physical processor (2 logical processors). That
> really surprised me.
>
>
>
>
>> Though the method call is very readable (given the
>> appropriate naming of the predicates and mapping), this need the extra
>> objects and anonymous classes I wanted to avoid creating. Not that
>> there is anything wrong with that, it is just I wanted to find a more
>> straightforward way to do it (if there is any).
>>
>
>
> Simple sequential code is more straightforward, as Josh demonstrated.
>
> Why does creating the extra objects bother you? You're not creating those
> objects in the inner loop. One Predicate object can be used for gazillions
> of predicate tests and it takes up almost no memory.
>
... and even so generational garbage collectors and designed to
efficiently deal with short-lived objects; additionally current VMs can
quickly allocate objects first into thread-local storage areas.
-Joe
More information about the coin-dev
mailing list