-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When does reduce() produce different outputs in parallel streaming? #549
Comments
I think its because it takes the same thread to do the same tasks every time |
@itsyme Hi, would you mind elaborating? Does this mean that I'm not initiating parallel streaming properly in my code? thanks! |
It has to do with the .parallel() you run. Since your reduce takes in a non associative function, you are not sure of the order of completion of the parallel tasks, so the order of input for the reductions is indeterministic. |
Have you tried running the function more than twice? If you've only ran it twice, it could be pure coincidence. |
It's just my thought but I have seen this in my jshell as well. I think it just happens such that the way it runs is in the same order giving the same result. |
I think can print out the thread name as well to check whether there is only one thread operating or multiple of them. |
Hi, having trouble understanding reduce for parallel streaming.... given that subtraction is non-associative as 3 - (2 - 1) != (3 - 2) - 1, why is reduce() producing the same output every time? When will reduce produce undeterministic results? thanks in advance :)
The text was updated successfully, but these errors were encountered: