Conversation
The lifetime-free morx cache still reconstructs each read-fonts subtable view after screening on every shape. Resolve those borrowed views once when preparing the AAT tables and reuse them during shaping. Keep contextual subtables covariant by storing their state table and lookup-array data separately. This avoids making hb_font_t invariant and does not copy any font-table arrays. The cache costs 112 bytes per morx subtable on x86_64 (about 4.4 KiB for Devanagari Sangam MN). It reduces measured shaping time by roughly 2--4.5% across Devanagari Sangam MN, Geeza Pro, Lucida Grande, and Menlo. Assisted-by: OpenAI Codex <noreply@openai.com>
Collaborator
|
Would be nice if this was viable but any cache that holds a lifetime won’t persist across shaping calls for any real users. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read-fontsmorxsubtable views once while preparing AAT tableshb_font_tlifetimesNo font-table arrays are decoded or copied. On x86_64, the cache is 112 bytes per
morxsubtable: about 4.4 KiB for Devanagari Sangam MN. The stripped library grows by about 11 KiB.This is substantially smaller than the previously reverted compiled-state-machine cache, which used 88--152 KiB for the tested fonts.
Performance
Measured shaping-time changes against current
main, with the same optimized Fontations dependency:For Devanagari Sangam MN, hardware counters also showed about 3.9% fewer instructions, 5.5% fewer branches, and 6.4% fewer branch misses.
Testing
cargo fmt --all -- --checkcargo build --no-default-features --features=libmcargo clippy --all-features --all-targets -- -D warningscargo test --workspace