Repository navigation
Use exact float equality in text measurement cache keys - #60464
Merged
Merged
Conversation
ide
marked this pull request as ready for review
December 2, 2026 12:20
ide
force-pushed
the
@ide/text-cache-exact-floats
branch
from
December 2, 2026 15:13
3c84cbb to
4ca5e79
Compare
ide
marked this pull request as draft
December 2, 2026 15:42
ide
force-pushed
the
@ide/text-cache-exact-floats
branch
2 times, most recently
from
December 3, 2026 01:34
83bcb1d to
7830ed5
Compare
ide
marked this pull request as ready for review
December 3, 2026 03:07
ide
force-pushed
the
@ide/text-cache-exact-floats
branch
from
December 3, 2026 13:31
7830ed5 to
0ecb311
Compare
Abbondanzo
reviewed
Dec 4, 2026
Text measurement keys can compare equal and hash differently for neighboring floats or for two representations of an unset value. An infinite paragraph font limit can leave an entry in the LRU map after eviction because the key compares unequal to itself. Compare cache floats exactly and hash their canonical integer encodings, including both coordinates of a present shadow offset. Combine float pairs on 64-bit platforms with 32-bit floats and fold attribute optionals into one presence mask. On Apple M6, the four-fragment size, line and prepared hashes retire 1108.08 → 1075.08, 1083.09 → 1046.08 and 1731.12 → 1631.11 instructions, respectively. The ordinary attribute hash fixtures match upstream within the measured noise. The Fantom text layout and attributed string suites and Android text unit tests pass. The four float regressions fail on upstream and detect the corresponding mutations. Signed-off-by: James Ide <ide@expo.dev>
ide
force-pushed
the
@ide/text-cache-exact-floats
branch
from
December 4, 2026 20:14
0ecb311 to
3d228bf
Compare
Abbondanzo
approved these changes
Dec 4, 2026
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:
The Fabric text keys compare font sizes, paragraph font limits and pixel scales within an epsilon. The hash uses the original values. With libc++, neighboring values can compare equal and still occupy separate entries. An infinite font limit also exposes an eviction failure. The key compares unequal to itself, so the LRU drops its list entry while the map retains it.
Compare text attribute floats, paragraph font limits and point scale exactly in the cache keys. Keep neighboring finite inputs distinct, reuse identical infinities and treat NaNs as unset. Hash normalized integer encodings for those fields, including both coordinates of a present shadow offset.
Changelog:
[INTERNAL] [FIXED] - Make Fabric text measurement cache equality agree with hashing.
Test Plan:
The four float regressions fail on upstream and pass with the patch. They detect restoring epsilon equality, hashing raw NaNs or signed zeros, and comparing or hashing raw shadow coordinates. A fifth test checks that prepared keys compare
lineBreakMode, which upstream already does. The C++ probe records cache reuse and map erasure during eviction.Apple Clang 21
-O3on Apple M6. The table compares median retired instructions per equal-key comparison or hash onupstream/mainata174e2c726and this branch. Each median uses three warmed runs with five repetitions per run. The size and line fixtures use the Fantom C++ types.All key rows and all
TextAttributesHashBenchmark.cppfixtures match or improve on main within the observed per-fixture range. The optimized layout hash retires 171.03–249.04 instructions on main and 163.03–241.04 on this branch. The ordinary attribute hash uses the same implementation as main and retires 324.04–495.06 instructions on both.