-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
None
When a limit or skip is performed on an parallel stream pipeline a wrapping spliterator is employed that uses a permit-based mechanism. N elements are optimistically copied into a buffer of fixed size (128) and then N permits are requested, of which <= N permits are granted. This works well for larger limits and stream pipelines where 128 is small in comparison. For smaller limits and stream pipelines this does not work so well especially if the cost per-element upstream is high.
The buffer size should be adjusted based on the limit and know pipeline size so that the upper bound is 128 but can be less if the limit or stream pipeline size is less.
The buffer size should be adjusted based on the limit and know pipeline size so that the upper bound is 128 but can be less if the limit or stream pipeline size is less.
- duplicates
-
JDK-8154387 Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less
-
- Closed
-