perf(scripts): cache registry responses so --check runs in 0.05s instead of 29s - #3062
Merged
Conversation
…ead of 29s `--check` makes one HTTPS request per tracked component — 46 round trips for a run that is almost entirely I/O wait: 28.6s wall against 0.13s of user time. That is enough friction that nobody runs the status command, which rather defeats having one. Responses are now cached under `node_modules/.cache/shadcn-sync/`, keyed by source URL, with a 60-minute TTL: cold (empty cache) 26.86s 0 cached, 46 fetched warm 0.05s 46 cached, 0 fetched --no-cache 28.74s 0 cached, 46 fetched `node_modules/.cache/` is the conventional home: already gitignored (verified via git check-ignore), and a clean install discards it, which is the right lifetime for a cache. The load-bearing detail is that `allowCache` gates READS only, and only read-only commands pass it. `--check` and `--diff` may answer from cache; `--update` and `--update-all` never do. A stale `--check` is a slightly out-of-date status line, but a stale `--update` would put hour-old code on disk under a message saying it is current. Writes still refresh the entry, so an update leaves the cache warm for the next check. Proved that split by poisoning the cached `button` entry: `--check` reported button as 51-line modified — it reads the cache — while `--update button` ignored the poison entirely, wrote the real upstream content (clean tree, zero POISONED lines), and write-refreshed the entry. Degradation is quiet by design: a missing, unreadable or corrupt entry falls through to the network (garbage file → 45 cached, 1 fetched, exit 0), and a cache directory that cannot be written never fails the run. Expiry verified by ageing every entry to 61 minutes — 0 cached, 46 fetched. The summary always reports where the data came from. A run that returns in 50ms is otherwise indistinguishable from one that silently fetched nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
--checkmakes one HTTPS request per tracked component — 46 round trips for a run that is almost entirely I/O wait: 28.6s wall against 0.13s of user time. That's enough friction that nobody runs the status command, which rather defeats having one.Result
--no-cacheResponses are cached under
node_modules/.cache/shadcn-sync/, keyed by source URL, 60-minute TTL. That's the conventional home: already gitignored (verified withgit check-ignore), and a clean install discards it — the right lifetime for a cache.The load-bearing detail: reads only
allowCachegates reading, and only read-only commands pass it.--check,--diff--update,--update-allA stale
--checkis a slightly out-of-date status line. A stale--updatewould put hour-old code on disk under a message saying it's current. Writes still refresh the entry, so an update leaves the cache warm for the next check.Proved it by poisoning the cache. Overwrote the cached
buttonentry with// POISONED CACHE — this must never reach disk:--check→ reportedbuttonas51 local line(s) … --update would refuse. It reads the cache, so it saw the poison. ✅--update button→ ignored the poison entirely, fetched live, wrote the real upstream content. Clean git tree, zeroPOISONEDlines on disk, and the cache entry was write-refreshed (poison gone,fetchedAt17s old). ✅Failure modes are quiet by design
not json at all {{{into one file:45 cached, 1 fetched, exit 0, 0 errors.0 cached, 46 fetched. ✅Always says where the data came from
A run that returns in 50ms is otherwise indistinguishable from one that silently fetched nothing.
Verification
--no-cache/ expired / corrupt paths all measured above--update resizablestill refuses (fix(components): resizable is a diverged file, not a synced one — stop the sync from breaking the build, and finish the v4 migration in it #3029 reclassification intact);--update commandstill refuses (fix(scripts): shadcn-sync refuses to silently delete local edits, and compiles the package after it writes #3035 local-edit guard intact);--diffunaffectedeslintclean; script-only change — no manifest or component editsNo changeset — tooling only.
🤖 Generated with Claude Code