Richard Startin prompted me to have a look at a case where java.time 
underperforms relative to joda time 
(https://twitter.com/richardstartin/status/1506975932271190017). 

It seems the java.time test of his suffer from heavy allocations due 
ZoneOffset::getRules allocating a new ZoneRules object every time and escape 
analysis failing to do the thing in his test. The patch here adds a simple 
specialization so that when creating ZonedDateTimes using a ZoneOffset we don't 
query the rules at all. This removes the risk of extra allocations and slightly 
speeds up ZonedDateTime creation for both ZoneOffset (+14%) and ZoneRegion 
(+5%) even when EA works like it should (the case in the here provided 
microbenchmark).

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

Commit messages:
 - Fix names, typos
 - Avoid going through ZoneRules for ZoneOffsets

Changes: https://git.openjdk.java.net/jdk/pull/7957/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7957&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8283681
  Stats: 126 lines in 5 files changed: 123 ins; 2 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7957.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7957/head:pull/7957

PR: https://git.openjdk.java.net/jdk/pull/7957

Reply via email to