Skip to content

Conversation

@wenshao
Copy link
Contributor

@wenshao wenshao commented Dec 12, 2025

This PR demonstrates the potential for performance optimizations in java.time.format.DateTimeFormatter parse and format.

It will be submitted as multiple smaller PRs. includes #28471


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

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28790

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2025

👋 Welcome back swen! 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 Dec 12, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Dec 12, 2025

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

@wenshao
Copy link
Contributor Author

wenshao commented Dec 12, 2025

1. Shell

We run the following Shell command on MacBook M1 Pro

# Base
git checkout 946170a65f6013716abd27ea0ca8f99e291eb204
make test TEST="micro:java.time.format.DateTimeFormatterParse"

# datetime_unroll_2512
git checkout 0025fedf8b5569fecc602708cf20b9da23fd6d5d
make test TEST="micro:java.time.format.DateTimeFormatterParse"

2. Raw Benchmark Data

# Base 946170a65f6013716abd27ea0ca8f99e291eb204
Benchmark                                                                      (pattern)   Mode  Cnt      Score      Error   Units
DateTimeFormatterBench.formatInstants                                           HH:mm:ss  thrpt   15     16.697 ±    0.223  ops/ms
DateTimeFormatterBench.formatInstants                                       HH:mm:ss.SSS  thrpt   15     12.337 ±    0.395  ops/ms
DateTimeFormatterBench.formatInstants                              yyyy-MM-dd'T'HH:mm:ss  thrpt   15      9.098 ±    0.187  ops/ms
DateTimeFormatterBench.formatInstants                          yyyy-MM-dd'T'HH:mm:ss.SSS  thrpt   15      6.728 ±    0.797  ops/ms
DateTimeFormatterBench.formatZonedDateTime                                      HH:mm:ss  thrpt   15     24.259 ±    0.227  ops/ms
DateTimeFormatterBench.formatZonedDateTime                                  HH:mm:ss.SSS  thrpt   15     16.708 ±    0.166  ops/ms
DateTimeFormatterBench.formatZonedDateTime                         yyyy-MM-dd'T'HH:mm:ss  thrpt   15     13.785 ±    0.253  ops/ms
DateTimeFormatterBench.formatZonedDateTime                     yyyy-MM-dd'T'HH:mm:ss.SSS  thrpt   15     10.341 ±    0.074  ops/ms
DateTimeFormatterParse.parseInstant                                                  N/A  thrpt   15   1833.285 ±  140.327  ops/ms
DateTimeFormatterParse.parseLocalDate                                                N/A  thrpt   15   6322.469 ± 2593.102  ops/ms
DateTimeFormatterParse.parseLocalDateTime                                            N/A  thrpt   15   3692.447 ±  440.779  ops/ms
DateTimeFormatterParse.parseLocalDateTimeWithNano                                    N/A  thrpt   15   3226.637 ±  248.742  ops/ms
DateTimeFormatterParse.parseLocalTime                                                N/A  thrpt   15   4149.405 ±  385.494  ops/ms
DateTimeFormatterParse.parseLocalTimeWithNano                                        N/A  thrpt   15   4896.185 ±  210.698  ops/ms
DateTimeFormatterParse.parseOffsetDateTime                                           N/A  thrpt   15   2392.000 ±  234.319  ops/ms
DateTimeFormatterParse.parseZonedDateTime                                            N/A  thrpt   15   1837.443 ±  114.926  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPadding                                  N/A  thrpt   15   5324.789 ± 1519.808  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPaddingLengthOne                         N/A  thrpt   15   8531.355 ± 2230.549  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPaddingLengthZero                        N/A  thrpt   15  13897.611 ±  984.134  ops/ms

# current 0025fedf8b5569fecc602708cf20b9da23fd6d5d
Benchmark                                                                      (pattern)   Mode  Cnt      Score       Error   Units
DateTimeFormatterBench.formatInstants                                           HH:mm:ss  thrpt   15     41.991 ±     0.468  ops/ms
DateTimeFormatterBench.formatInstants                                       HH:mm:ss.SSS  thrpt   15     35.482 ±     0.265  ops/ms
DateTimeFormatterBench.formatInstants                              yyyy-MM-dd'T'HH:mm:ss  thrpt   15     25.947 ±     6.970  ops/ms
DateTimeFormatterBench.formatInstants                          yyyy-MM-dd'T'HH:mm:ss.SSS  thrpt   15      8.012 ±     5.579  ops/ms
DateTimeFormatterBench.formatZonedDateTime                                      HH:mm:ss  thrpt   15     77.120 ±     0.255  ops/ms
DateTimeFormatterBench.formatZonedDateTime                                  HH:mm:ss.SSS  thrpt   15     55.883 ±     0.220  ops/ms
DateTimeFormatterBench.formatZonedDateTime                         yyyy-MM-dd'T'HH:mm:ss  thrpt   15     42.089 ±     0.191  ops/ms
DateTimeFormatterBench.formatZonedDateTime                     yyyy-MM-dd'T'HH:mm:ss.SSS  thrpt   15     34.700 ±     0.244  ops/ms
DateTimeFormatterParse.parseInstant                                                  N/A  thrpt   15   3531.050 ±    27.074  ops/ms
DateTimeFormatterParse.parseLocalDate                                                N/A  thrpt   15  21192.781 ±   283.869  ops/ms
DateTimeFormatterParse.parseLocalDateTime                                            N/A  thrpt   15   9939.675 ±    69.487  ops/ms
DateTimeFormatterParse.parseLocalDateTimeWithNano                                    N/A  thrpt   15  10451.504 ±    90.085  ops/ms
DateTimeFormatterParse.parseLocalTime                                                N/A  thrpt   15  18998.245 ±   116.317  ops/ms
DateTimeFormatterParse.parseLocalTimeWithNano                                        N/A  thrpt   15  21965.414 ±   200.032  ops/ms
DateTimeFormatterParse.parseOffsetDateTime                                           N/A  thrpt   15   5925.110 ±    75.741  ops/ms
DateTimeFormatterParse.parseZonedDateTime                                            N/A  thrpt   15   3199.381 ±    31.043  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPadding                                  N/A  thrpt   15   6167.399 ±  1364.336  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPaddingLengthOne                         N/A  thrpt   15  20993.486 ± 15187.952  ops/ms
DateTimeFormatterWithPaddingBench.formatWithPaddingLengthZero                        N/A  thrpt   15  28000.773 ± 19238.712  ops/ms

3. Compare

Benchmark Base datetime_unroll_2512 Improvement
formatInstants HH:mm:ss 16.697 41.991 151.48%
formatInstants HH:mm:ss.SSS 12.337 35.482 187.53%
formatInstants yyyy-MM-dd'T'HH:mm:ss 9.098 25.947 185.19%
formatInstants yyyy-MM-dd'T'HH:mm:ss.SSS 6.728 8.012 19.08%
formatZonedDateTime HH:mm:ss 24.259 77.120 217.90%
formatZonedDateTime HH:mm:ss.SSS 16.708 55.883 234.47%
formatZonedDateTime yyyy-MM-dd'T'HH:mm:ss 13.785 42.089 205.33%
formatZonedDateTime yyyy-MM-dd'T'HH:mm:ss.SSS 10.341 34.700 235.56%
parseInstant 1833.285 3531.050 92.61%
parseLocalDate 6322.469 21192.781 235.20%
parseLocalDateTime 3692.447 9939.675 169.19%
parseLocalDateTimeWithNano 3226.637 10451.504 223.91%
parseLocalTime 4149.405 18998.245 357.86%
parseLocalTimeWithNano 4896.185 21965.414 348.63%
parseOffsetDateTime 2392.000 5925.110 147.70%
parseZonedDateTime 1837.443 3199.381 74.12%
formatWithPadding 5324.789 6167.399 15.82%
formatWithPaddingLengthOne 8531.355 20993.486 146.08%
formatWithPaddingLengthZero 13897.611 28000.773 101.50%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants