Loose-ends wrapup
Howard Lovatt
howard.lovatt at gmail.com
Sun May 19 16:02:08 PDT 2013
In my own stream library I find this hint useful. In addition to MAX_VAL and 1 having the same meaning as in CHM I use 0 to mean use the default value of minimum split size, which for my library is 1024.
This concept works well in a stream library where the hint is a separate method call and the minimum split is the maximum of all the hints given. My mappers etc also carry a hint with them and again the maximum of the minimum split sizes is used. This lets you write a mapper that requires no splitting since its split size hint will be MAX_VAL and will therefore override all the other hints.
--Howard.
Sent from my iPad
On 20/05/2013, at 7:14 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> On 05/19/13 15:55, Brian Goetz wrote:
>> Our new mantra is "explicit but unobtrusive parallelism."
>>
>> As a low-level component, I think the xxx(minParSize...) is a perfectly
>> reasonable API. And xxx(minParSize...) could be argued to meets the mantra, but
>> only just barely, because of the Concurrent in the class name. If the bulk ops
>> on CHM were cordoned off via some naming convention to make it clear which
>> subset were possibly-parallel, that would help further.
>
> They will be the only ones that have a leading, non-optional
> argument, so it's about as explicit as you can get.
> An example below.
>
> I'm about to do this. People using CHM bulk tasks have already seen
> a few API changes, so one final one is not likely to cause them
> to get especially angry, and less angry than they'll someday be if
> they don't have this simple tuning mechanism.
>
>
> ... class-level doc ...
> * <p>These bulk operations accept a {@code parallelismThreshold}
> * argument. Methods proceed sequentially if the current map size is
> * estimated to be less than the given threshold. Using a value of
> * {@code Long.MAX_VALUE} suppresses all parallelism. Using a value
> * of {@code 1} results in maximal parallelism. In-between values can
> * be used to trade off overhead versus throughput.
> *
>
>
> /**
> * Returns the result of accumulating the given transformation
> * of all (key, value) pairs using the given reducer to
> * combine values, and the given basis as an identity value.
> *
> * @param parallelismThreshold the (estimated) number of elements
> * needed for this operation to be executed in parallel.
> * @param transformer a function returning the transformation
> * for an element
> * @param basis the identity (initial default value) for the reduction
> * @param reducer a commutative associative combining function
> * @return the result of accumulating the given transformation
> * of all (key, value) pairs
> */
> public long reduceToLong(long parallelismThreshold,
> ToLongBiFunction<? super K, ? super V> transformer,
> long basis,
> LongBinaryOperator reducer) {
>
>
More information about the lambda-libs-spec-observers
mailing list