ParallelStream Vs Stream Digest, Vol 113, Issue 94

David Holmes david.holmes at oracle.com
Fri Sep 30 05:57:05 UTC 2016


On 30/09/2016 3:07 PM, Prakhar Makhija wrote:
> The application makes a hit to a core object over and over again. I have
> to copy this object, i.e. make a clone of it using the Cloneable
> interface, so that the original object cannot be modified. But since the
> references of the old object and clone object would be intact, inside
> the clone method I am explicitly copying the List Map and Set using
> parrallelStream/stream.
>
> The hardware is i3 processor with 8GB RAM and 1TB hard disk.

You only have two cores on an i3, with hyper-threading so you have very 
limited speedup potential to begin with

> So you mean to say, Parallel Stream is good for large data set?

What I mean is that if the data set is too small then the overhead of 
parallelizing the work will outweigh the work itself.

David
-----

> On Sep 30, 2016 10:08 AM, "David Holmes" <david.holmes at oracle.com
> <mailto:david.holmes at oracle.com>> wrote:
>
>     On 30/09/2016 2:24 PM, Prakhar Makhija wrote:
>
>         Hi everyone,
>
>         I have started using both Stream and ParallelStream, for Set
>         List and Entry
>         of Map.
>
>         What I can't understand is why Stream is taking lesser time than
>         ParallelStream.
>
>         Shouldnt ParallelStream be giving better performance than Stream
>         in terms
>         of Time Complexity?
>
>
>     Depends on the data set size and your hardware, and what exactly you
>     are trying to do in parallel.
>
>     David
>


More information about the core-libs-dev mailing list