-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8372460: Use EnumMap instead of HashMap for DateTimeFormatter parsing to improve performance #28471
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
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back swen! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
1. ShellWe run the following Shell command 2. Raw Benchmark DataPerformance data running on a MacBook M1 Pro: 3. Performance ComparisonPerformance Comparison: b649557 vs d8742d7
|
src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
Show resolved
Hide resolved
The existing tests above can cover the cases where there are no non-ChronoFields, so no additional tests are needed. |
Webrevs
|
This PR optimizes the parsing performance of DateTimeFormatter by replacing HashMap with EnumMap in scenarios where the keys are exclusively ChronoField enum values.
When parsing date/time strings, DateTimeFormatter creates HashMaps to store intermediate parsed values. HashMap has more overhead for operations compared to specialized map implementations.
Since ChronoField is an enum and all keys in these maps are ChronoField instances, we can use EnumMap instead, which provides better performance for enum keys due to its optimized internal structure.
Parsing scenarios show improvements from 12% to 95%
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28471/head:pull/28471$ git checkout pull/28471Update a local copy of the PR:
$ git checkout pull/28471$ git pull https://git.openjdk.org/jdk.git pull/28471/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28471View PR using the GUI difftool:
$ git pr show -t 28471Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28471.diff
Using Webrev
Link to Webrev Comment