Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8072841

Adjust the buffering size for limit/slice operations on unordered parallel stream pipelines

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 9
    • None
    • core-libs
    • 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.

            psandoz Paul Sandoz
            psandoz Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: