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

8330802: Desugar switch in Locale::createLocale #18882

Closed
wants to merge 3 commits into from

Conversation

cl4es
Copy link
Member

@cl4es cl4es commented Apr 22, 2024

This switch expression in Locale::createLocale is causing a somewhat large startup regression on my local system. Desugaring to if statements seem like the right thing to do while we investigate ways to further reduce overheads in SwitchBootstraps.

These numbers are against a baseline which include #18865 and #18845, which already improved the situation:

Name             Cnt          Base         Error           Test         Error         Unit  Change
Perfstartup-Noop  20        40,500 ±       1,942         31,000 ±       2,673        ms/op   1,31x (p = 0,000*)
  :.cycles           143254849,000 ± 3398321,355  102205427,650 ± 2192784,853       cycles   0,71x (p = 0,000*)
  :.instructions     307138448,850 ± 2095834,550  219415574,800 ±  376992,067 instructions   0,71x (p = 0,000*)
  :.taskclock               39,500 ±       1,942         22,500 ±       3,858           ms   0,57x (p = 0,000*)
  * = significant

Comparing to a baseline without those recent improvements the overhead was almost the double:

Name             Cnt          Base         Error           Test         Error         Unit  Change
Perfstartup-Noop  20        50,000 ±       0,000         31,000 ±       2,673        ms/op   1,61x (p = 0,000*)
  :.cycles           187047932,000 ± 3330400,381  102205427,650 ± 2192784,853       cycles   0,55x (p = 0,000*)
  :.instructions     408219060,350 ± 4031173,140  219415574,800 ±  376992,067 instructions   0,54x (p = 0,000*)
  :.taskclock               53,500 ±       4,249         22,500 ±       3,858           ms   0,42x (p = 0,000*)
  * = significant

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-8330802: Desugar switch in Locale::createLocale (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18882

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 22, 2024

👋 Welcome back redestad! 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 Apr 22, 2024

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

8330802: Desugar switch in Locale::createLocale

Reviewed-by: alanb, liach, rriggs, naoto, mchung

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

  • 0b9350e: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks
  • 20be5e0: 8314846: Do not store Klass::_secondary_super_cache in CDS archive
  • 7e421ce: 8330585: Refactor/rename forwardee handling
  • 3e65d90: 8330820: Remove remnants of operator_new.cpp in build system
  • 936a47d: 8330607: Deprecate -XX:+UseEmptySlotsInSupers
  • ee7b2e9: 8330051: Small ObjectMonitor spinning code cleanups
  • 3e185c7: 8330154: Serial: Remove TenuredSpace::update_for_block
  • f889797: 8330463: Rename invalidate() to write_region() in ModRefBarrierSet
  • c4f5c51: 8330576: ZYoungCompactionLimit should have range check

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 rfr Pull request is ready for review label Apr 22, 2024
@openjdk
Copy link

openjdk bot commented Apr 22, 2024

@cl4es 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 Apr 22, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 22, 2024

Webrevs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 22, 2024
} else if (key instanceof LocaleKey lk) {
return new Locale(lk.base, lk.exts);
} else {
throw new InternalError("should not happen");
Copy link
Member

Choose a reason for hiding this comment

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

The default branch was required in the switch. Can we simply drop this branch and have a ClassCastException to LocalKey instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean like so:

    private static Locale createLocale(Object key) {
        if (key instanceof BaseLocale base) {
            return new Locale(base, null);
        }
        LocaleKey lk = (LocaleKey)key;
        return new Locale(lk.base, lk.exts);
    }

?

I think this should be alright. The type of the "impossibly" thrown exception would differ.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, just like how jli handles the Class/MethodType union type arguments.

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.

LGTM, the CCE is the equivalent of should-not-reach-here.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, Claes!

Copy link
Member

@mlchung mlchung 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.

@cl4es
Copy link
Member Author

cl4es commented Apr 23, 2024

Thanks for reviewing, everyone!

/integrate

@openjdk
Copy link

openjdk bot commented Apr 23, 2024

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

  • 8961077: 8309259: Reduce calls to MethodHandles.lookup() in jdk.internal.net.http.Stream
  • 574ba14: 8330862: GCBarrierIRExample fails when a different GC is selected via the command line
  • 550a138: 8306928: Duplicate variable assignement in jdk.internal.net.http.AuthenticationFilter#getCredentials
  • 57ebd04: 8330153: C2: dump barrier information for all Mach nodes
  • 58ad399: 8330821: Rename UnsafeCopyMemory
  • 1d52234: 8330704: Clean up non-standard use of /** comments in some langtools tests
  • 83c74d7: 8329717: Missing @since tags in elements in DocumentationTool and Taglet
  • 0b9350e: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks
  • 20be5e0: 8314846: Do not store Klass::_secondary_super_cache in CDS archive
  • 7e421ce: 8330585: Refactor/rename forwardee handling
  • ... and 6 more: https://git.openjdk.org/jdk/compare/70acade9f1bd0c7bba25abad0f0d8199715d66d0...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 23, 2024

@cl4es Pushed as commit daa5a4b.

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

@cl4es cl4es deleted the deswitch branch April 23, 2024 08:06
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
Development

Successfully merging this pull request may close these issues.

6 participants