On Fri, 20 Dec 2024 21:06:16 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> The change made in >> [JDK-8288723](https://bugs.openjdk.org/browse/JDK-8288723) seems innocuous, >> but it caused this performance regression. Partially reverting the change >> (ones that involve `computeIfAbsent()`) to the original. Provided a >> benchmark that iterates the call to `ZoneOffset.ofTotalSeconds(0)` 1,000 >> times, which improves the operation time from 3,946ns to 2,241ns. > > Naoto Sato has updated the pull request incrementally with one additional > commit since the last revision: > > Fixed compile error src/java.base/share/classes/java/time/ZoneOffset.java line 428: > 426: if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) { > 427: Integer totalSecs = totalSeconds; > 428: ZoneOffset result = SECONDS_CACHE.get(totalSecs); Here, each call may allocate an Integer object. The maximum number of ZoneOffsets that need to be cached here is only 148. Using AtomicReferenceArray is better than AtomicConcurrentHashMap. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22854#discussion_r1894486852