perf(stdlib): shorten the capture wait before modules load - #48
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe stdlib adds cached source stringification, updates XPUI component matching, and changes when webpack entry chunks are released. Tests cover source matching and registry quiet-period behavior. Package metadata advances the stdlib version to 1.13.2. ChangesStdlib runtime updates
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant ScriptLoader
participant RegistryQuietWatcher
participant ModuleRegistry
participant EntryChunkResolver
ScriptLoader->>RegistryQuietWatcher: Report in-flight chunk count
RegistryQuietWatcher->>ModuleRegistry: Check module count every 25 ms
RegistryQuietWatcher->>EntryChunkResolver: Call onQuiet after 300 ms quiet or 10-second cap
Merge Risk: ⚪ Minimal · up to This change shortens the stdlib preload wait and caches source text for component matching. No actionable merge-blocking risk was found. The stated limitations predate this change. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The inspected changes do not introduce an identified expansion of access or authority. Startup coordination becomes more aware of active loads, but unusual completion paths and incomplete runtime coverage leave limited uncertainty. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 6 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. A rabbit checks the source by moonlit light, Comment |
Summary
stdlib's
preloadholds every later module until its webpack analysis is ready. Two parts of that wait got shorter, and nothing it resolves changed.ComponentLibraryre-stringified every exported function once per component name: 4,064 functions × 155 names, about 204 ms on Spotify 1.3.3. Function source text is now computed once per function for the session (sourceOf, shared bysrcandfindBy). Functions without"data-encore-id"are skipped before the name regexes run, which brings the scan to about 5 ms with an identical result.findBynow stops at its first failing test instead of running every test.wpr.lholds the release, which the old poll could not see. The 10 s cap is unchanged.The quiet wait itself is still needed. In a live boot, 112 modules register about 140 ms after capture, from lazy chunks Spotify requests right after first render.
GenericModal,Cards.Playlist,UI.AccordionandUI.ChipGroupcome from that batch, so releasing on the first quiet tick would leave them undefined.Two existing bugs are fixed along the way:
\wand\$cook towand$. The identifier class only matched one-letter member names. It is nowString.raw. Today's client still uses one-letter names, and both versions find the same 61 components.resolveChunkthrew inside the wrappedwpr.lcallback, webpack'sdonenever ran and the lazy chunk hung. The error is now logged anddonealways runs. A synchronous throw fromloadalso undoes the in-flight count.Bumps stdlib to 1.13.2 and the stdlib version the kit tracks.
Results
Spotify 1.3.3.264, macOS arm64, 19 modules, with the startup CLI from spicetify/cli#4009 applied for both. These are 8 interleaved cold boots per stdlib, with the machine under heavy unrelated load (load average about 8).
After every boot on this branch,
GenericModal,Cards.Playlist,UI.AccordionandUI.ChipGroupresolved, the UI library held 62 entries, and the boot report had no failed modules.Validation
findByshort-circuiting with a single stringify, andsourceOfcaching.pnpm run checkpasses.~/.config/spicetify/modules/stdlibwith a full apply and checked over 4 boots plus 2 surface checks.Not covered: a chunk that started loading before capture is not counted as in flight. That was already the case before, and in traced boots those chunks finished about 180 ms before capture. The analysis still snapshots
wpr.monce, so a chunk requested after the quiet window is never analyzed; that also predates this change.Summary by CodeRabbit