RFR: 8315999: Improve Date toString performance [v2]

温绍锦 duke at openjdk.org
Mon Sep 11 15:02:47 UTC 2023


On Mon, 11 Sep 2023 14:54:57 GMT, 温绍锦 <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/time/Instant.java line 1355:
>> 
>>> 1353:     @Override
>>> 1354:     public String toString() {
>>> 1355:         return DateTimeFormatter.ISO_INSTANT.format(this);
>> 
>> Have you considered potentially more generalizable optimizations to `DateTimeFormatter.ISO_INSTANT.format(this)` here? 
>> 
>> Hand-rolling a fixed-length buffer, skipping the `StringBuilder` .. understandably this can have a performance edge, but perhaps a `DateTimeFormatter` like `ISO_INSTANT` can be optimized to get closer to whatever speed-up this gets you - with broader implications.
>
> The performance of optimizing DateTimeFormatter cannot be as fast as using ixed-length buffer directly.

Of course, the optimization of DateTimeFormatter is more general, and we can spend time doing it later. The format of toString is fixed, we can not use DateTimeFormatter.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1321686942


More information about the security-dev mailing list