Speed up the canonical diff on large stylesheets - #217
Open
samoht wants to merge 2 commits into
Open
Conversation
The per-overlap-key bucket index was a generic [Hashtbl] keyed by whole declarations, so building a graph compared declaration subtrees structurally on every probe. Polymorphic compare was a quarter of the optimizer's time on a large stylesheet.
The canonical comparison retries at a lower strictness when a side fails to parse, and it was canonicalising the side that did parse before finding out, throwing away a whole pipeline run. Parsing first costs nothing and the retry then starts from scratch only when it has to.
samoht
force-pushed
the
speed-canonical-diff
branch
from
July 30, 2026 01:02
d4ca5a5 to
2f39985
Compare
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.
Two output-preserving changes, measured on a 660KB Tailwind stylesheet compared against its Lightning-minified reference. Best of three runs, and the rendered diff is byte-identical before and after.
The graph's per-overlap-key bucket index was a generic
Hashtblkeyed by whole declarations, so building a graph compared declaration subtrees structurally on every probe; polymorphic compare was about a quarter of the optimizer's samples. It now keys on the cachedDeclaration.hash, with the structural check only on a collision. Separately, the canonical comparison retries at a lower strictness when one side fails to parse, and it was canonicalising the side that did parse before discovering that, throwing away a full pipeline run.