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

8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree() #12612

Closed
wants to merge 9 commits into from

Conversation

stsypanov
Copy link
Contributor

@stsypanov stsypanov commented Feb 17, 2023

  1. When DateTimeFormatter is reused we don't need to copy availableZoneIds and allocate nonRegionIds as PrefixTree can be taken from cache. In the related benchmark allocation of HashSet takes ~93% of all time, so avoiding it should bring some improvement for cases when we reuse DateTimeFormatter to parse a string into ZoneDateTime
    image

  2. DateTimeFormatter is mostly used with one locale, so cachedTree and cachedTreeCI can have predefined size.

@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class DateTimeFormatterBenchmark {

    private static final DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern("yyyy:MM:dd:HH:mm:v").toFormatter();
    private static final String TEXT = "2015:03:10:12:13:ECT";

    @Setup
    public void setUp() {
        ZonedDateTime.parse(TEXT, df);
    }

    @Benchmark
    public ZonedDateTime parse() {
        return ZonedDateTime.parse(TEXT, df);
    }
}

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-8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree()

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12612

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 17, 2023

👋 Welcome back stsypanov! 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 Feb 17, 2023

@stsypanov 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 Feb 17, 2023
@stsypanov stsypanov changed the title Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTreee() Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree() Mar 24, 2023
@stsypanov
Copy link
Contributor Author

Benchmarking

make test TEST="micro:time.format.ZonedDateTimeFormatterBenchmark" MICRO="OPTIONS=-prof gc"

master

Benchmark                                                              Mode  Cnt      Score     Error   Units
ZonedDateTimeFormatterBenchmark.parse                                  avgt   20  13545.737 ± 451.164   ns/op
ZonedDateTimeFormatterBenchmark.parse:·gc.alloc.rate                   avgt   20   1713.579 ±  56.517  MB/sec
ZonedDateTimeFormatterBenchmark.parse:·gc.alloc.rate.norm              avgt   20  24320.006 ±   0.001    B/op
ZonedDateTimeFormatterBenchmark.parse:·gc.count                        avgt   20    110.000            counts
ZonedDateTimeFormatterBenchmark.parse:·gc.time                         avgt   20    514.000                ms


patch

Benchmark                                                              Mode  Cnt     Score    Error   Units
ZonedDateTimeFormatterBenchmark.parse                                  avgt   20  1276.063 ± 52.543   ns/op
ZonedDateTimeFormatterBenchmark.parse:·gc.alloc.rate                   avgt   20   622.223 ± 26.456  MB/sec
ZonedDateTimeFormatterBenchmark.parse:·gc.alloc.rate.norm              avgt   20   832.001 ±  0.001    B/op
ZonedDateTimeFormatterBenchmark.parse:·gc.count                        avgt   20    58.000           counts
ZonedDateTimeFormatterBenchmark.parse:·gc.time                         avgt   20   475.000               ms

@stsypanov stsypanov changed the title Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree() 8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree() Mar 27, 2023
@stsypanov stsypanov marked this pull request as ready for review March 27, 2023 16:20
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 27, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 27, 2023

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.

Looks like a nice fix to me.

@stsypanov stsypanov requested a review from naotoj March 29, 2023 08:12
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
Copy link

openjdk bot commented Mar 29, 2023

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

8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree()

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 64 new commits pushed to 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.

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) 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 ready Pull request is ready to be integrated label Mar 29, 2023
@stsypanov
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 29, 2023
@openjdk
Copy link

openjdk bot commented Mar 29, 2023

@stsypanov
Your change (at version 623a773) is now ready to be sponsored by a Committer.

@naotoj
Copy link
Member

naotoj commented Mar 29, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented Mar 29, 2023

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 29, 2023

@naotoj @stsypanov Pushed as commit 438c969.

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

@stsypanov stsypanov deleted the date-time-formatter-build branch March 29, 2023 18:57
@olivergillespie
Copy link
Contributor

/backport jdk17u-dev

@openjdk
Copy link

openjdk bot commented May 31, 2023

@olivergillespie the backport was successfully created on the branch olivergillespie-backport-438c969b in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 438c969b from the openjdk/jdk repository.

The commit being backported was authored by Sergey Tsypanov on 29 Mar 2023 and was reviewed by Naoto Sato.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git olivergillespie-backport-438c969b:olivergillespie-backport-438c969b
$ git checkout olivergillespie-backport-438c969b
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git olivergillespie-backport-438c969b

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