Skip to content

8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream#21820

Closed
kabutz wants to merge 3 commits into
openjdk:masterfrom
kabutz:8343426-cslm-spliterator-bug
Closed

8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream#21820
kabutz wants to merge 3 commits into
openjdk:masterfrom
kabutz:8343426-cslm-spliterator-bug

Conversation

@kabutz

@kabutz kabutz commented Nov 1, 2024

Copy link
Copy Markdown
Contributor

Since Java 10, spliterators for the ConcurrentSkipListMap were pointing to the head, which has item == null, rather than to the first element. The trySplit() method no longer worked, and always returned null. Therefore, parallel streams have not worked for ConcurrentSkipListMap and ConcurrentSkipListSet since Java 10. It worked correctly in Java 8 and 9.

The problem lies in the constructor calls for the various spliterators. In Java 9, we pass in head.node.next as "origin" into the constructor. In Java 10, this was changed to just head.node as "origin". Since the "item" field is always null on head.node, we never enter the first if() statement in the trySplit() method and thus it always returns null.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream (Bug - P3)

Reviewers

Contributors

  • Doug Lea <dl@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21820/head:pull/21820
$ git checkout pull/21820

Update a local copy of the PR:
$ git checkout pull/21820
$ git pull https://git.openjdk.org/jdk.git pull/21820/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21820

View PR using the GUI difftool:
$ git pr show -t 21820

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21820.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Nov 1, 2024

Copy link
Copy Markdown

👋 Welcome back kabutz! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Nov 1, 2024

Copy link
Copy Markdown

@kabutz This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream

Co-authored-by: Doug Lea <dl@openjdk.org>
Reviewed-by: vklang

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 22 new commits pushed to the master branch:

  • 7be7772: 8344112: Remove code to support security manager execution mode from DatagramChannel implementation
  • bd3fec3: 8344086: Remove security manager dependency in FFM
  • 916694f: 8343317: Extend test generation tool to handle APX NDD/NF flavor of instructions
  • eb240a7: 8344051: Problemlist jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java with ZGC until JDK-8343893 is fixed
  • c00e20c: 8343285: java.lang.Process is unresponsive and CPU usage spikes to 100%
  • cc2acd1: 8343286: Missing unchecked cast warning in polymorphic method call
  • b80ca49: 8344124: JDK-8341411 Broke the build
  • a08d67c: 8344080: Return type mismatch for jfr_unregister_stack_filter
  • 4c5bc5f: 8343923: GHA: Switch to Xcode 15 on MacOS AArch64 runners
  • 8af304c: 8341411: C2: remove slice parameter from GraphKit::make_load() and GraphKit::store_to_memory()
  • ... and 12 more: https://git.openjdk.org/jdk/compare/c12b386d1916af9a04b4c6698838c2b40c6cdd86...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@viktorklang-ora) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot added the rfr Pull request is ready for review label Nov 1, 2024
@openjdk

openjdk Bot commented Nov 1, 2024

Copy link
Copy Markdown

@kabutz The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk Bot added the core-libs core-libs-dev@openjdk.org label Nov 1, 2024
@mlbridge

mlbridge Bot commented Nov 1, 2024

Copy link
Copy Markdown

Webrevs

@viktorklang-ora

Copy link
Copy Markdown
Contributor

Hi @kabutz,
Interesting catch!
A regression test (splitability) and a test which verifies correct operation under parallel evaluation would be appropriate here.

@kabutz

kabutz commented Nov 1, 2024

Copy link
Copy Markdown
Contributor Author

Sure, where should I add that test?

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz I'd say either under its own directory test/jdk/java/util/concurrent/ConcurrentSkipListMap/ or possibly in test/jdk/java/util/concurrent/tck/ConcurrentSkipListMapTest.java.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz I think @DougLea identified some potential edge-cases with the proposed solution, so I added his suggested diff to the JBS Issue for reference.

@kabutz

kabutz commented Nov 4, 2024

Copy link
Copy Markdown
Contributor Author

@kabutz I think @DougLea identified some potential edge-cases with the proposed solution, so I added his suggested diff to the JBS Issue for reference.

Indeed, I didn't check what happens when we create a spliterator on an empty collection.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz Let me know how you want to proceed. 👍

@kabutz

kabutz commented Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

@kabutz Let me know how you want to proceed. 👍

've made the changes and sent another PR to the branch holding the changes. Hope that's the right way of doing it...

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz Ah, so then you can close this PR? I'll have a look at the other PR.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz Might actually be easier to drop the other PR and add the commits to your branch 8343426-cslm-spliterator-bug so this PR is updated.

@kabutz

kabutz commented Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk

openjdk Bot commented Nov 12, 2024

Copy link
Copy Markdown

@kabutz This pull request has not yet been marked as ready for integration.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz The update for CSLM is based on @DougLea's proposal on the JBS issue, right? (Assuming that's the case I will add him as a co-contributor)

@kabutz

kabutz commented Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

@kabutz The update for CSLM is based on @DougLea's proposal on the JBS issue, right? (Assuming that's the case I will add him as a co-contributor)

Yes, correct.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

/contributor add @DougLea

@openjdk

openjdk Bot commented Nov 12, 2024

Copy link
Copy Markdown

@viktorklang-ora Only the author (@kabutz) is allowed to issue the contributor command.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

@kabutz The OpenJDK bot doesn't trust me :-) would you mind adding Doug as a contributor? :)

@kabutz

kabutz commented Nov 12, 2024

Copy link
Copy Markdown
Contributor Author

/contributor add @DougLea

@openjdk

openjdk Bot commented Nov 12, 2024

Copy link
Copy Markdown

@kabutz
Contributor Doug Lea <dl@openjdk.org> successfully added.

@viktorklang-ora viktorklang-ora left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch, @kabutz !

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Nov 13, 2024
@kabutz

kabutz commented Nov 13, 2024

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Nov 13, 2024
@openjdk

openjdk Bot commented Nov 13, 2024

Copy link
Copy Markdown

@kabutz
Your change (at version d167b88) is now ready to be sponsored by a Committer.

@viktorklang-ora

Copy link
Copy Markdown
Contributor

/sponsor

@viktorklang-ora

Copy link
Copy Markdown
Contributor

Thanks @kabutz & @DougLea!

@openjdk

openjdk Bot commented Nov 14, 2024

Copy link
Copy Markdown

Going to push as commit 2b57f40.
Since your change was applied there have been 43 commits pushed to the master branch:

  • a8152bd: 8343941: IGV: dump graph at different register allocation steps
  • bd6152f: 8343855: HTTP/2 ConnectionWindowUpdateSender may miss some unprocessed DataFrames from closed streams
  • c3776db: 8342936: Enhance java.io.IO with parameter-less println() and readln()
  • b54bd82: 8344025: Remove unused ISO2022.Encoder.maximumDesignatorLength
  • abacece: 8344011: Remove usage of security manager from Class and reflective APIs
  • c977ef7: 8342047: Create Template Assertion Predicates with Halt nodes only instead of uncommon traps
  • 23a8c71: 8341790: Fix ExceptionOccurred in java.desktop
  • 1e97c1c: 8335989: Implement JEP 494: Module Import Declarations (Second Preview)
  • e7d90b9: 8343460: ZGC: Crash in ZRemembered::scan_page_and_clear_remset
  • 95a00f8: 8343875: Minor improvements of jpackage test library
  • ... and 33 more: https://git.openjdk.org/jdk/compare/c12b386d1916af9a04b4c6698838c2b40c6cdd86...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Nov 14, 2024
@openjdk openjdk Bot closed this Nov 14, 2024
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 14, 2024
@openjdk

openjdk Bot commented Nov 14, 2024

Copy link
Copy Markdown

@viktorklang-ora @kabutz Pushed as commit 2b57f40.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants