JDK-8186317 : Cache font layout tables for use by harfbuzz
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-08-16
  • Updated: 2019-03-06
  • Resolved: 2017-08-28
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 10
10 b23Fixed
Related Reports
Duplicate :  
Relates :  
Description
In the now obsolete ICU code path, we cache the layout tables in native
memory so that when requested by ICU we can just hand the pointer,
saving the overhead of copying the Java array for every call to layout.

In the harfbuzz path we aren't doing that which surely must slow down
repeated calls at least somewhat.

Note that harfbuzz still will likely copy and sanitise the table each time
we create a face object but fixing that needs a deeper understanding
(perhaps too deep) of how we can re-use harfbuzz objects across
calls to shape. Something to consider later.

The more isolated fix is to cache the tables on the font and just
hand a reference to HB.
We probably need to set HB_MEMORY_MODE_READONLY unless
we can establish that and WRITE HB will do doesn't invalidate
the initial state and is idempotent.

We also need to stop it calling free and manage the storage
as part of the lifecycle of the Font2D. That latter code already exists
so there should be no new code needed there.
Comments
Implementing this and calling layout in a tight loop 1000 times brings total time down from 450-550ms to about 300-350ms on 64 bit Linux. This also compares favourably with the 600-650ms for doing the same loop with ICU.
16-08-2017