JDK-8046707 : Performance of java.time could be better
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-06-12
  • Updated: 2016-06-13
  • Resolved: 2014-06-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u20Fixed 9 b20Fixed
Description
In the java.time library three performance improvements can be noted:

1) In the Parsed class crossCheck() method, an exception is used for control flow. A typical parse containing an offset will trigger the exception throw/catch three times, slowing the parse.

2) In the from() method of ZonedDateTime and OffsetDateTime, exception throwing is used for control flow where an if statement would be more performant.

3) In the query() method of Instant and ZonedDateTime, the seven query types are not all handled, causing the slower default implementations to be called.

These are essentially bugs in the implementation. There is no externally observable change other than better performance.
Comments
See http://java-performance.info/jsr-310-java-8-datetime-library-performance-well-joda-time-2-3-j-u-calendar/ My own tests saw improvements in performance, but I don't have that test code now. Changes I made are described above.
16-06-2014

Is there any information about the cases that are improved and how much improvement is made?
16-06-2014

Patch attached that optimises performance of java.time.
12-06-2014