perf: speed up client startup - #4009
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: spicetify/cli/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Summary
Cold startup does much less waiting before modules run.
push, so the capture now returns as soon as it succeeds.version[1] >= 2 && version[2] >= 57) let it run on 1.3.0 to 1.3.56. On every DOM mutation it calledgetComputedStyleon every element, about 400 ms of main-thread time per boot on 1.3.3, and it kept forcing compositor layers on scrollable elements. A component-wiseisVersionBeforehelper now limits it to the versions it was written for./modules/<id>/color.inibefore itsload, one module at a time (about 35 ms each). Only themes ship acolor.ini, so extensions no longer look for one. That removes about 450 ms of serial requests with 12 styled extensions.modulepreloadfor each staged module's JS and starts fetching its CSS, using the same skip rules asrunLoads. Apply now records every other script of a multi-file module in the manifest (preload, skipping tests, specs and tool configs), so a tree like stdlib's 119 files arrives in one batch instead of five or six dependent import waves. Nothing is evaluated early. Unused prefetched CSS is dropped after boot, and a failed CSS prefetch is logged before the loader fetches again.waitForClientpolls every 25 ms instead of 200 ms.Results
Spotify 1.3.3.264, macOS arm64, 19 installed modules with the Text theme. These are 12 interleaved cold renderer boots per setup, measured over CDP with the machine under heavy unrelated load (load average about 8). Median, with the 10th to 90th percentile in brackets:
First home content arrives about 130 ms later because the home page now renders with the theme already applied. Before, it rendered unthemed and then restyled when the theme arrived about 2.2 s in, so the themed home now appears more than a second earlier. An A/B with and without the
preloadlist, 12 boots each, showed the list is not the cause: home content came at 931 ms with it and 985 ms without, and all modules loaded at 1458 ms against 1511 ms.Validation
src/jsHelpertests and all 166spicetifylibrary tests pass (4 ignored, as onv3-beta).cargo clippy -p spicetify --release -- -D warningsis clean.adoptedStyleSheetscolor.ini.Not verified: Windows and Linux, and the Go CLI's use of the shared wrapper on Spotify versions before 1.2.57.
A related bug is left for a separate change. The
CosmosAsyncproxy inplatform.jsuses the same broken check (version[1] >= 2 && version[2] < 31), so on 1.3.0 to 1.3.30 it returns Spotify's unwrapped fetch. Fixing it changes request handling for every module on 1.3, so it needs its own testing.