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

8261418: Reduce decoder creation overheads for sun.nio.cs.ext Charsets #2480

Closed
wants to merge 4 commits into from

Conversation

cl4es
Copy link
Member

@cl4es cl4es commented Feb 9, 2021

This refactor some sun.nio.cs.ext charsets, such as ISO-2022-CN-GB, ISO-2022-CN-CNS, ISO-2022-KR and a few others to use static rather than per-instance auxiliary decoders. Doing so reduce overheads of calling charset.newDecoder(). This reduce or eliminate regressions on new String(byte[], String) operations due the removal of thread-local decoder caching in JDK-8259842

Most ISO-2022 Charsets define a specialized decoder already. The ISO2022.Decoder class was only used by ISO2022_KR, so folding it into that implementation and simplifying the code brings a rather significant speed-up, both to decoder creation and on actual decoding.

Testing: tier1-3, manual runs of sun.nio.cs tests


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8261418: Reduce decoder creation overheads for sun.nio.cs.ext Charsets

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2480/head:pull/2480
$ git checkout pull/2480

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 9, 2021

👋 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 openjdk bot commented Feb 9, 2021

@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 i18n labels Feb 9, 2021
@cl4es
Copy link
Member Author

@cl4es cl4es commented Feb 9, 2021

StringDecode.WithCharset.decodeCharsetName microbenchmark runs

pre-JDK-8259842:

Benchmark                                           (charsetName)     Mode  Cnt     Score     Error   Units
decodeCharsetName                                   x-ISO-2022-CN-GB  avgt    5   756.293 ±  56.082   ns/op
decodeCharsetName:·gc.alloc.rate.norm               x-ISO-2022-CN-GB  avgt    5   488.040 ±   0.013    B/op
decodeCharsetName                                   ISO-2022-KR       avgt    5  1076.745 ± 299.789   ns/op
decodeCharsetName:·gc.alloc.rate.norm               ISO-2022-KR       avgt    5   808.068 ±   0.022    B/op

Current:

Benchmark                                           (charsetName)     Mode  Cnt     Score     Error   Units
decodeCharsetName                                   x-ISO-2022-CN-GB  avgt    5   906.281 ± 109.035   ns/op
decodeCharsetName:·gc.alloc.rate.norm               x-ISO-2022-CN-GB  avgt    5   920.077 ±   0.025    B/op
decodeCharsetName                                   ISO-2022-KR       avgt    5  1175.228 ± 144.509   ns/op
decodeCharsetName:·gc.alloc.rate.norm               ISO-2022-KR       avgt    5  1256.105 ±   0.043    B/op

Patched:

Benchmark                                           (charsetName)     Mode  Cnt    Score     Error   Units
decodeCharsetName                                   x-ISO-2022-CN-GB  avgt    5  783.385 ± 255.048   ns/op
decodeCharsetName:·gc.alloc.rate.norm               x-ISO-2022-CN-GB  avgt    5  584.050 ±   0.016    B/op
decodeCharsetName                                   ISO-2022-KR       avgt    5  814.654 ± 196.860   ns/op
decodeCharsetName:·gc.alloc.rate.norm               ISO-2022-KR       avgt    5  584.050 ±   0.024    B/op

@cl4es cl4es marked this pull request as ready for review Feb 9, 2021
@openjdk openjdk bot added the rfr label Feb 9, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 9, 2021

Webrevs

Copy link
Member

@naotoj naotoj left a comment

Thanks, Claes, for making the performance improvement. I have a few comments/questions.

naotoj
naotoj approved these changes Feb 10, 2021
Copy link
Member

@naotoj naotoj left a comment

Thanks. The newly added comment to ISO2022 is helpful.

@openjdk
Copy link

@openjdk openjdk bot commented Feb 10, 2021

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

8261418: Reduce decoder creation overheads for sun.nio.cs.ext Charsets

Reviewed-by: naoto

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

  • cc5691c: 8248162: serviceability/attach/RemovingUnixDomainSocketTest.java failed
  • 40754f1: 4841153: java.awt.geom.Rectangle2D.add(double,double) documented incorrectly
  • 4caeb39: 8260380: Upgrade to LittleCMS 2.12
  • a772639: 8261298: LinuxPackage.c, getJvmLauncherLibPath RPM->DEB typo
  • 52fc01b: 8261268: LOAD_INSTANCE placeholders unneeded for parallelCapable class loaders
  • a3d6e37: 8261302: NMT: Improve malloc site table hashing
  • ad54d8d: 8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings
  • 752f92b: 6211242: AreaAveragingScaleFilter(int, int): IAE is not specified
  • 3af334a: 6211257: BasicStroke.createStrokedShape(Shape): NPE is not specified
  • 4619f37: 8261472: BasicConstraintsExtension::toString shows "PathLen:2147483647" if there is no pathLenConstraint
  • ... and 15 more: https://git.openjdk.java.net/jdk/compare/8ebed28403afa1fae2505a1937694c90d27c6d6b...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.

➡️ 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 label Feb 10, 2021
@cl4es
Copy link
Member Author

@cl4es cl4es commented Feb 11, 2021

Thanks Naoto!

/integrate

@openjdk openjdk bot closed this Feb 11, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Feb 11, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 11, 2021

@cl4es Since your change was applied there have been 33 commits pushed to the master branch:

  • 5e1b809: 8261444: Remove unused fields in Lower
  • a9c3680: 8261250: Dependencies: Remove unused dependency types
  • 3ede231: 8259430: C2: assert(in_vt->length() == out_vt->length()) failed: mismatch on number of elements
  • 1662373: 8235139: Deprecate the socket impl factory mechanism
  • 49cf13d: 8261449: Micro-optimize JVM_LatestUserDefinedLoader
  • 837bd89: 8261548: ProblemList runtime/NMT/CheckForProperDetailStackTrace.java
  • adca84c: 8260341: CDS dump VM init code does not check exceptions
  • 447db62: 6211198: ICC_Profile.getInstance(byte[]): IAE is not specified
  • cc5691c: 8248162: serviceability/attach/RemovingUnixDomainSocketTest.java failed
  • 40754f1: 4841153: java.awt.geom.Rectangle2D.add(double,double) documented incorrectly
  • ... and 23 more: https://git.openjdk.java.net/jdk/compare/8ebed28403afa1fae2505a1937694c90d27c6d6b...master

Your commit was automatically rebased without conflicts.

Pushed as commit 8b6ab31.

💡 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 i18n integrated
2 participants