Skip to content

Cold start performance improvements - #20427

Open
smnbbrv wants to merge 1 commit into
tailwindlabs:mainfrom
smnbbrv:main
Open

Cold start performance improvements#20427
smnbbrv wants to merge 1 commit into
tailwindlabs:mainfrom
smnbbrv:main

Conversation

@smnbbrv

@smnbbrv smnbbrv commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Hi guys, thanks for you great work!

I work on performance improvements on https://github.com/schoero/eslint-plugin-better-tailwindcss project. Part of issues can be fixed on the tailwind side only.

This is a first fix, I have a bigger one in mind, it would require a small additional public API method - out of scope of this PR.

Please let me know what you think.

Finding

getVariantOrder() re-sorts all parsed variants with the (expensive) variant comparator on every call, and it is called by every compileCandidates() invocation — per build pass, per @apply substitution, and hundreds of times during candidate canonicalization via the variant signature caches. Since parsedVariants is append-only, the computed order only changes when a new variant is parsed, so we can cache the result and invalidate on parsedVariants.size. This makes cold canonicalization (IntelliSense, lint plugins) faster and removes repeated sorting from @apply substitution and incremental rebuilds.

Test plan

Tested at https://github.com/smnbbrv/better-tailwindcss-bench . The relevant part is the epbt-now / tw-patched

plugin cost (ms, cold run net of parse baseline)

codebase epbt-now / tw-now epbt-patched / tw-now epbt-now / tw-patched epbt-patched / tw-patched
mixed 6292 3965 (-37%) 5395 (-14%) 3595 (-43%)
repetitive 5279 2425 (-54%) 4819 (-9%) 2124 (-60%)
unique 6096 5458 (-10%) 5507 (-10%) 5295 (-13%)

@smnbbrv
smnbbrv requested a review from a team as a code owner August 21, 2026 05:00
@smnbbrv smnbbrv changed the title Performance improvements Cold start performance improvements Aug 21, 2026
@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance and include this reference: e3634fa1-d526-4f12-99d8-395e4850b10b.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c2656b59-43ed-42ba-9889-e0299f53ebad

📥 Commits

Reviewing files that changed from the base of the PR and between 90f8ff4 and 21a35c1.

📒 Files selected for processing (1)
  • packages/tailwindcss/src/design-system.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Added cached state for variant ordering in the design system. getVariantOrder() returns the cached order when the parsed variant count is unchanged. The method recomputes and stores the order when new variants are parsed.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main purpose of the change: improving cold-start performance through variant-order caching.
Description check ✅ Passed The description explains the repeated variant sorting problem, the caching solution, and benchmarked performance improvements.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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