fix:perf: slow startup due to blocking provider probes at startup#2728
fix:perf: slow startup due to blocking provider probes at startup#2728IdrisGit wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
ApprovabilityVerdict: Needs human review This PR changes startup behavior significantly - providers now load asynchronously with a new 'pending' state instead of blocking until ready. This is a runtime behavior change affecting what users observe during startup, not a simple bug fix. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Make the initial provider refresh purely background. Boot-time providersRef is now seeded from:
The background syncLiveSources is now forked, so regardless of probe latency the backend server is ready asap and renderer can start the window paint.
Why
Backend HTTP readiness was coupled to provider probing. If a provider took time to time to respond or maybe in future have many providers, until each provider is resolved, the backend server doesn't start causing renderer to not start painting, leading to slow startup time.
By decoupling the provider probing (with cache check initially) we eliminate the synchronous dependency and app starts pretty quickly.
Benchmarks
I benchmarked the wall clock time for start to window open and as you can see there is a good degree of improvement, and this doesn't encapsulate if any provider itself is buggy which can cause even longer startup time.
Ideally the startup time should be atleast sub 1 second, but I think this is step in that direction.
Checklist
Note
few of the line changes are not actually code changes,
but formatting fixes that were auto applied with
bun run fmtfixes #2726 and maybe #2442
Note
Medium Risk
Changes provider registry startup sequencing and snapshot hydration, which can affect initial UI/provider state and cache behavior. Also expands the
ServerProviderStatecontract with a newpendingvalue that downstream consumers must handle.Overview
Decouples backend readiness from provider probing by forking the initial
syncLiveSourcesrefresh to run fully in the background, instead of awaiting provider refreshes during layer startup.Boot-time provider state is now hydrated from on-disk cache with a bounded (100ms) best-effort snapshot fallback; instances without cache/fallback are surfaced immediately as a new
pendingprovider snapshot. Unavailable instances are also upserted eagerly at boot so the UI can render missing-driver/ghost providers before background refresh completes.Updates the contracts schema to include
"pending"inServerProviderState.Reviewed by Cursor Bugbot for commit f4d3212. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix slow startup caused by blocking provider probes in
ProviderRegistryLive'pending'snapshots so they appear immediately in the registry instead of being omitted.instanceRegistry.listUnavailableare eagerly added toprovidersRefwithout waiting for a refresh.'pending'as a valid literal to theServerProviderStateschema in server.ts.providersRefis now populated with pending/cached entries at boot rather than only confirmed-available providers, so consumers may briefly see providers in a'pending'state.Macroscope summarized f4d3212.