[font] Tweak Cmap cache#258
Merged
benoitkugler merged 7 commits intomainfrom Apr 22, 2026
Merged
Conversation
|
|
||
| // cache21_0_13 is a cache for integer keys, | ||
| // with 0 <= key < 2097152 | ||
| type cache21_0_13 [1 << 13]uint8 |
Member
There was a problem hiding this comment.
Can we document that this cache performs best on sparse keys? It generates collisions for keys less than 256 values apart. That could be useful for implementing an LRU policy when using the cache (as I think we do), but it's not immediately obvious when looking at the implementation (I had to sit here for a while and work out how this cache could manage such a large keyspace with such small storage).
Contributor
Author
There was a problem hiding this comment.
Thank you, I have clarified the documentation and mentioned sparse keys.
whereswaldon
approved these changes
Apr 20, 2026
Member
whereswaldon
left a comment
There was a problem hiding this comment.
Thanks for tackling this! I have one non-blocking request for implementation docs, but the rest looks great.
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.
Thanks to @redawl investigation, I realized our current implementation is not optimal because it passes the Cmap cache array by value, forcing a copy, while passing a pointer is more performant (see pointer.txt column).
The new benchmark results are now also better when adding a cache for not supported runes (see not-found-cache.txt column).
There is a small cost to pay when the "not supported" cache is not hit, but it is small enough.
Closes #252