On Thu, 12 Nov 2026 09:02:24 GMT, Azad Abdulov <[email protected]> wrote:

>> Cuts shaping context to the actually needed by HarfBuzz to reduce 
>> unnecessary copying. See provided benchmark that grows faster than linear 
>> without the fix and shows linear growth with this change.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Azad Abdulov has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   8396893: revert useFFM default value initialization

Whilst this fix is probably fine, I'm not at all sure it relates to the bug 
that it is being fixed under. Both cases should be allocating native memory, 
not Java heap memory, and the memory usage would be similar. Perhaps FFM has 
reclamation delays.
And do you actually know that the reporters of this were using massively long 
strings ?
I mean the whole of War and Peace is only about 3 million letters, and no one 
lays that out at once. I hope.

src/java.desktop/share/classes/sun/font/SunLayoutEngine.java line 72:

> 70:     // See hb_buffer_t::CONTEXT_LENGTH in hb-buffer.hh
> 71:     // test/jdk/java/awt/font/TextLayout/ShapingContextTest.java checks 
> the value in case of a future change.
> 72:     private static final int HB_CONTEXT_LENGTH = 10;

FWIW this works as long as you are testing your bundled harfbuzz, but doesn't 
guarantee what will be right on some end-user system with a different harfbuzz.
So could we not be more conservative, rather than being exact ?
There seems to be minimal (no) benefit until the text gets very long anyway ..

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

PR Review: https://git.openjdk.org/jdk/pull/33853#pullrequestreview-5877569143
PR Review Comment: https://git.openjdk.org/jdk/pull/33853#discussion_r4552790075

Reply via email to