Encounter order

Paul Sandoz paul.sandoz at oracle.com
Tue Oct 23 04:53:49 PDT 2012


Hi Brian,

My first inclination is we need to be sensitive to encounter order, by default, because of the rather loosely defined "least surprise" principle:

Developer starts with:

  List serial = list.stream().filter(e -> e > 5).into(new ArrayList<>());

then later on changes to:

  List parallel = list.parallel().filter(e -> e > 5).into(new ArrayList<>());

Would most developers expect those two lists, serial and parallel, to be equal? Is their expectation that going parallel gives a performance boost without affecting the result?

Mathematica's Parallelize [1] states:

  Parallelize[expr] normally gives the same result as evaluating expr, except for side effects during the computation

  http://reference.wolfram.com/mathematica/ref/Parallelize.html


Whatever the default position is on encounter order i suspect we will require some way to either explicitly disable or enable order preservation (like what Joe highlighted in PLINQ).

Paul.

[1] http://reference.wolfram.com/mathematica/ref/Parallelize.html
     http://reference.wolfram.com/mathematica/ref/ParallelCombine.html


More information about the lambda-libs-spec-observers mailing list