Skip to content

Speed up the canonical diff on large stylesheets - #217

Open
samoht wants to merge 2 commits into
canonical-skip-factoringfrom
speed-canonical-diff
Open

Speed up the canonical diff on large stylesheets#217
samoht wants to merge 2 commits into
canonical-skip-factoringfrom
speed-canonical-diff

Conversation

@samoht

@samoht samoht commented Jul 29, 2026

Copy link
Copy Markdown
Owner

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.

origin/main  35.9s
this branch  28.8s

The graph's 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 about a quarter of the optimizer's samples. It now keys on the cached Declaration.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.

samoht added 2 commits July 29, 2026 18:00
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
samoht force-pushed the speed-canonical-diff branch from d4ca5a5 to 2f39985 Compare July 30, 2026 01:02
@samoht
samoht changed the base branch from main to canonical-skip-factoring July 30, 2026 01:02
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.

1 participant