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

Parallel unordered Stream.limit() tries to collect 128 elements even if limit is less

    Details

      Backports

        Description

        Current implementation of parallel unordered Stream.limit() (backed by UnorderedSliceSpliterator) has fixed CHUNK_SIZE 128 (1 << 7) which is the number of elements every parallel task tries to traverse before checking whether enough elements is collected. This is wasteful if limit is less than 128. As limit is known for every parallel task from the very beginning, it's quite easy to lower chunk size in such cases.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tvaleev Tagir Valeev
                  Reporter:
                  tvaleev Tagir Valeev
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: