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

8333462: Performance regression of new DecimalFormat() when compare to jdk11 #19534

Closed
wants to merge 2 commits into from

Conversation

lingjun-cg
Copy link
Contributor

@lingjun-cg lingjun-cg commented Jun 4, 2024

Run the below benchmark test ,it show the average time of new DecimalFormat() increase 18% when compare to jdk 11.

the result with jdk 11:

Benchmark                          Mode  Cnt    Score   Error  Units
JmhDecimalFormat.testNewOnly       avgt   50  248.300 ? 5.158  ns/op

the result with current jdk:

Benchmark                          Mode  Cnt    Score   Error  Units
JmhDecimalFormat.testNewOnly       avgt   50  303.381 ? 5.252  ns/op
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@State(Scope.Thread)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class JmhDecimalFormat {

    @Setup(Level.Trial)
    public void setup() {
    }

    @Benchmark
    public void testNewOnly() throws InterruptedException {
        new DecimalFormat("#0.00000");
    }
}

Compare the flame graph it shows the java.text.DecimalFormatSymbols#findNonFormatChar takes a significant time.
After replacing the lambda implementation with a simple loop , it shows nearly the same performance as jdk 11.

Benchmark                          Mode  Cnt    Score   Error  Units
JmhDecimalFormat.testNewOnly       avgt   50  209.874 ? 9.951  ns/op

flame-graph-jdk11-jdk21.zip


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-8333462: Performance regression of new DecimalFormat() when compare to jdk11 (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19534

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 4, 2024

👋 Welcome back lingjun-cg! 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 4, 2024

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

8333462: Performance regression of new DecimalFormat() when compare to jdk11

Reviewed-by: liach, naoto, jlu

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

  • 67b9a08: 8333586: Improve syntax of @see tags in javax.lang.model
  • 244f6ac: 8307824: Clean up Finalizable.java and finalize terminology in vmTestbase/nsk/share
  • a706e35: 8332039: Cannot invoke "com.sun.source.util.DocTreePath.getTreePath()" because "path" is null
  • 612b689: 8043226: Better diagnostics for non-applicable type annotations
  • dce9703: 8333226: Regressions 2-3% in Compress ZGC after 8331253
  • b101dcb: 8333312: Incorrect since tags on new ClassReader and ConstantPool methods
  • e0bab78: 8326951: since-checker - missing @ since tags
  • 31f7039: 8316131: runtime/cds/appcds/TestParallelGCWithCDS.java fails with JNI error
  • 4a1cdd5: 8333486: Parallel: Remove unused methods in psParallelCompact
  • 664c993: 8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zero offset to null pointer
  • ... and 10 more: https://git.openjdk.org/jdk/compare/d230b30353f59135287436b09949b80e9fd73a93...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 (@naotoj, @justin-curtis-lu) 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 Jun 4, 2024
@openjdk
Copy link

openjdk bot commented Jun 4, 2024

@lingjun-cg 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 4, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 4, 2024

Webrevs

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.

LGTM

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 4, 2024
Copy link
Member

@justin-curtis-lu justin-curtis-lu left a comment

Choose a reason for hiding this comment

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

LGTM. Also needs copyright year update

@bchristi-git
Copy link
Member

Would it be better if the benchmark returned the created DecimalFormat ?
Just thinking about dead code elimination:
https://github.com/openjdk/jmh/blob/master/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java

@lingjun-cg
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jun 5, 2024
@openjdk
Copy link

openjdk bot commented Jun 5, 2024

@lingjun-cg
Your change (at version d5b9ccf) is now ready to be sponsored by a Committer.

@D-D-H
Copy link
Contributor

D-D-H commented Jun 5, 2024

/sponsor

@openjdk
Copy link

openjdk bot commented Jun 5, 2024

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

  • 67b9a08: 8333586: Improve syntax of @see tags in javax.lang.model
  • 244f6ac: 8307824: Clean up Finalizable.java and finalize terminology in vmTestbase/nsk/share
  • a706e35: 8332039: Cannot invoke "com.sun.source.util.DocTreePath.getTreePath()" because "path" is null
  • 612b689: 8043226: Better diagnostics for non-applicable type annotations
  • dce9703: 8333226: Regressions 2-3% in Compress ZGC after 8331253
  • b101dcb: 8333312: Incorrect since tags on new ClassReader and ConstantPool methods
  • e0bab78: 8326951: since-checker - missing @ since tags
  • 31f7039: 8316131: runtime/cds/appcds/TestParallelGCWithCDS.java fails with JNI error
  • 4a1cdd5: 8333486: Parallel: Remove unused methods in psParallelCompact
  • 664c993: 8331731: ubsan: relocInfo.cpp:155:30: runtime error: applying non-zero offset to null pointer
  • ... and 10 more: https://git.openjdk.org/jdk/compare/d230b30353f59135287436b09949b80e9fd73a93...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 5, 2024
@openjdk openjdk bot closed this Jun 5, 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 Jun 5, 2024
@openjdk
Copy link

openjdk bot commented Jun 5, 2024

@D-D-H @lingjun-cg Pushed as commit d826127.

💡 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
Development

Successfully merging this pull request may close these issues.

6 participants