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

8295555: Primitive wrapper caches could be @Stable #14418

Closed
wants to merge 4 commits into from

Conversation

minborg
Copy link
Contributor

@minborg minborg commented Jun 12, 2023

This PR proposes adding @Stable to certain wrapper classes' cache arrays (e.g. Integer and Long).

Comments are welcome as to how to improve the VM's handling now that the backing cache array is @Stable. Are there simplifications to be made or are there other optimizations we might add?


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-8295555: Primitive wrapper caches could be @Stable (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14418

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 12, 2023

👋 Welcome back pminborg! 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
Copy link

openjdk bot commented Jun 12, 2023

@minborg The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

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

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Jun 12, 2023
@minborg
Copy link
Contributor Author

minborg commented Jun 12, 2023

The performance is similar with this PR compared to the base line:

Before:

Benchmark         (size)  Mode  Cnt  Score   Error  Units
Integers.valueOf     500  avgt   15  0.652 ± 0.003  ns/op

After

Benchmark         (size)  Mode  Cnt  Score   Error  Units
Integers.valueOf     500  avgt   15  0.649 ± 0.003  ns/op
    @State(Scope.Thread)
    public static class Data {
       int value = 42;
    }
    
    ...
    
    @Benchmark
    public void valueOf(Data data, Blackhole bh) {
        bh.consume(Integer.valueOf(data.value));
    }
    

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 12, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 12, 2023

Webrevs

@liach
Copy link
Member

liach commented Jun 12, 2023

Seems the valueOf APIs already have @IntrinsicCandidate and might have some custom logic in C2 or other jit compilers, so there's no performance difference.

Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

Looks good

@openjdk
Copy link

openjdk bot commented Jun 12, 2023

@minborg 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:

8295555: Primitive wrapper caches could be `@Stable`

Reviewed-by: rriggs

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 5 new commits pushed to the master branch:

  • a6ad42e: 8308645: Javadoc of FFM API needs to be refreshed
  • 0727507: 8272147: Consolidate preserved marks handling with other STW collectors
  • 6cd166a: 8309403: Serial: Remove the useless adaptive size policy in GenCollectedHeap
  • 5d5ae35: 8308966: Add intrinsic for float/double modulo for x86 AVX2 and AVX512
  • 8e4e6b0: 8309761: Leak class loader constraints

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 12, 2023
@minborg
Copy link
Contributor Author

minborg commented Jun 13, 2023

The benchmarks I provided above does not involve constant folding so here is another set of benchmarks (Thanks @cl4es):

Before

Benchmark                     (size)  Mode  Cnt  Score   Error  Units
Integers.constantFoldInteger     500  avgt   15  0.568 ± 0.013  ns/op
Integers.constantFoldInts        500  avgt   15  0.564 ± 0.005  ns/op

After

Benchmark                     (size)  Mode  Cnt  Score   Error  Units
Integers.constantFoldInteger     500  avgt   15  0.558 ± 0.001  ns/op
Integers.constantFoldInts        500  avgt   15  0.559 ± 0.001  ns/op
    @Benchmark
    public int constantFoldInteger() {
        return Integer.valueOf(64) * Integer.valueOf(32);
    }

    @Benchmark
    public int constantFoldInts() {
        return 64 * 32;
    }

@minborg
Copy link
Contributor Author

minborg commented Jun 13, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jun 13, 2023

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

  • 5d71612: 8309852: G1: Remove unnecessary assert_empty in G1ParScanThreadStateSet destructor
  • 23a54f3: 8309538: G1: Move total collection increment from Cleanup to Remark
  • 57fc9a3: 8309763: Move tests in test/jdk/sun/misc/URLClassPath directory to test/jdk/jdk/internal/loader
  • 2dca5ae: 8299052: ViewportOverlapping test fails intermittently on Win10 & Win11
  • 3028295: 8309065: Move the logic to determine archive heap location from CDS to G1 GC
  • 80a8144: 8309867: redundant class field RSAPadding.md
  • 3c15ad8: 8307144: namedParams in XECParameters and EdDSAParameters can be private final
  • 3ce1240: 8309870: Using -proc:full should be considered requesting explicit annotation processing
  • 1612b6d: 8309752: com/sun/jdi/SetLocalWhileThreadInNative.java fails with virtual test thread factory due to OpaqueFrameException
  • 45414fc: 8307858: [REDO] JDK-8307194 Add make target for optionally building a complete set of all JDK and hotspot libjvm static libraries
  • ... and 5 more: https://git.openjdk.org/jdk/compare/fdaa2c40835344a336696656285d8a9705f4a166...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 13, 2023
@openjdk openjdk bot closed this Jun 13, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 13, 2023
@openjdk
Copy link

openjdk bot commented Jun 13, 2023

@minborg Pushed as commit f7de726.

💡 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 i18n i18n-dev@openjdk.org integrated Pull request has been integrated
3 participants