Skip to content
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

1.x: fix GroupBy delaying group completion till all groups were emitted #3787

Merged
merged 1 commit into from
Mar 23, 2016

Conversation

akarnokd
Copy link
Member

In 1.1.1, groupBy was fixed to properly honor backpressure on the outer Observable. The change included a drain loop that emitted onCompleted() to the groups only when all GroupedObservables were drained from the main queue. This delayed the group's completion unnecessarily causing the concat operator to hang in some source-consumer cases such as #3775.

This PR fixes the behavior by signalling onCompleted() to the groups the moment the main completes.

Note, however, that concatenating groups is eventually prone to hangs due to the groups not completing until the source completes, thus concat can't switch to the next source. One should use flatMap or concatMapEager instead.

List<GroupedUnicast<K, V>> list = new ArrayList<GroupedUnicast<K, V>>(groups.values());
groups.clear();

for (GroupedUnicast<K, V> e : list) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just iterate over groups.values() here and avoid list allocation?

Or you want array structure for better performance? If so, not sure you're winning something big because you're iterating over values() in the constructor of ArrayList and then here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to reduce the window when terminating groups remove themselves from the map; but I don't think such case is likely anymore. I'll update the PR accordingly.

@akarnokd akarnokd force-pushed the GroupByComplete1x branch from 2d13986 to c8a2cfa Compare March 21, 2016 19:10
@artem-zinnatullin
Copy link
Contributor

👍

1 similar comment
@stevegury
Copy link
Member

👍

@akarnokd akarnokd merged commit 213f8a8 into ReactiveX:1.x Mar 23, 2016
@akarnokd akarnokd deleted the GroupByComplete1x branch March 23, 2016 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants