Skip to content

[crater] Skip comparison when fontc output unchanged - #2114

Merged
cmyr merged 1 commit into
mainfrom
crater-hash-fontc-output
Sep 3, 2026
Merged

cmyr merged 1 commit into
mainfrom
crater-hash-fontc-output

Conversation

@cmyr

@cmyr cmyr commented Sep 3, 2026

Copy link
Copy Markdown
Member

On average compiling a target with fontc accounts for 8% of the the runtime of crater (with a cached fontmake output), with the majority of the rest of the time spent in the ttx_diff python code itself: dumping the ttx and doing various bits of xml normalization and cleanup.

This points us to an easy and significant win: avoid doing any of that ttx/xml work if fontc's output is unchanged.

ttx_diff now writes the sha256 of the font it built to fontc.sha256, and takes an --expected_fontc_ttf_hash; on a match it exits 3 without comparing anything. Crater records that hash alongside the result and passes it back on the next run. A hit costs a fontc build and a hash instead of the whole comparison.

Only results that describe a specific pair of fonts are cached: a runtime failure could have any cause, and if fontc did not produce a font there is no hash to key on. The cached result is only trusted when fontmake's output came from the cache in the same run, and the existing invalidation still applies (the whole cache is dropped when ttx_diff or the pinned python deps change.)

On average compiling a target with fontc accounts for 8% of the the
runtime of crater, with the majority of the rest of the time spent in
the ttx_diff python code itself: dumping the ttx and doing varoius bits
of xml normalization and cleanup.

This points us to an easy and significant win: avoid doing any of that
ttx/xml work if fontc's output is unchanged.

ttx_diff now writes the sha256 of the font it built to fontc.sha256, and
takes an --expected_fontc_ttf_hash; on a match it exits 3 without
comparing anything. Crater records that hash alongside the result and
passes it back on the next run. A hit costs a fontc build and a hash
instead of the whole comparison.

Only results that describe a specific pair of fonts are cached: a runtime
failure could have any cause, and if fontc did not produce a font there is
no hash to key on. The cached result is only trusted when fontmake's
output came from the cache in the same run, and the existing invalidation
still applies (the whole cache is dropped when ttx_diff or the pinned
python deps change.)

@dfrg dfrg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a nice win for crater runs!

@cmyr
cmyr added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit be24f31 Sep 3, 2026
25 checks passed
@cmyr
cmyr deleted the crater-hash-fontc-output branch September 3, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants