Change the DateTimeFormatterBuilder::FIELD_MAP type from Map to Array
Chen Liang
liangchenblue at gmail.com
Sun Sep 28 15:14:02 UTC 2025
Hi wenshao, I think this proposed minor cleanup is reasonable.
Looking at the overall context, I think that piece of code needs a more
general rewrite to ensure better performance.
On Sat, Sep 27, 2025 at 7:24 PM wenshao <shaojin.wensj at alibaba-inc.com>
wrote:
> The DateTimeFormatterBuilder::FIELD_MAP is of type Map<Character,
> TemporalField>, with key values in the range 'A-Z' and 'a-z'.
>
> We can change the type of FIELD_MAP to an array of length 128 and then use
> char as an index to access the array.
>
> This will reduce the memory usage of DateTimeFormatterBuilder::FIELD_MAP
> and improve performance slightly.
>
> By analyzing the jmap dump memory, we can see that the memory size used by
> DateTimeFormatterBuilder::FIELD_MAP has dropped from 1.12kb to 528b, the
> number of objects has decreased and the memory has become more flat. as
> shown below:
>
> before:
> [image: image]
>
> after:
> [image: image]
>
>
> In order to make it easier for reviewers to see my ideas, I submitted a
> draft Pull Request ( https://github.com/openjdk/jdk/pull/26634 ). Please
> give me feedback.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250928/563b8a38/attachment-0001.htm>
More information about the core-libs-dev
mailing list