chore(devx): reduce docs dev cold-load latency#144
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
superwall-docs-staging | 86716eb | Commit Preview URL Branch Preview URL |
Mar 16 2026, 10:58 PM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
e43eeca to
3134570
Compare
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.

Summary
This PR reduces the cold
bun run dev-> first/docs/load path for the docs site.The main root cause was not Vite startup itself. It was eager whole-corpus work happening during the initial app graph load:
src/routes/api/search.tswas callingcreateFromSource(source)at module import time.fumadocs-corestarts building the local Orama search index immediately when that API is created.This PR moves that search-index work behind a lazy getter so it only runs when
/api/searchis actually hit.It also keeps a few dev-only MDX reductions that improve the first docs load without changing production builds:
asyncmode in developmentChanges
src/routes/api/search.tsasyncdocs loading in dev insource.config.tssource.config.tssrc/lib/source.tssrc/routes/llms[.]mdx.docs.$.tssource.config.tsscripts/dev-benchmark.tsBenchmark
Command:
Current run on this branch:
Before this work, the user was seeing roughly
28sfor the equivalent cold path.In repeated local runs after the fix,
Start -> first /docs/was generally in the~5-6srange.Approximate contribution breakdown
These changes interact, so the safest numbers are ablations: remove one change from the faster version and see how much the benchmark regresses.
~5.7s -> ~11.4s~5.7s -> ~17.6s~5.7s -> ~5.7-5.9s~5.7s -> ~5.1-5.9sdepending on run varianceRoughly speaking, the biggest wins are:
Tradeoffs
/api/searchrequest is slower, because it now pays the index build on first use instead of during startup.Validation
bun test✅bun run build/docs/web-checkout/web-checkout-overview(pre-existing, unrelated to this perf work)Note
Medium Risk
Moderate risk because it changes initialization timing for the
/api/searchserver (now lazy), which can shift work to first request and affect concurrency/edge-case behavior; other changes are dev-only MDX output differences.Overview
Speeds up local docs cold loads by deferring expensive work off the initial dev startup path:
/api/searchnow lazily creates the Orama-backed search server on first request instead of at module import.Adjusts docs/MDX processing in development to reduce first-request cost: disables processed markdown generation and Shiki highlighting in dev, and updates LLM markdown endpoints (
getLLMTextand/llms.mdx/docs/$) to serverawtext in dev while keepingprocessedfor non-dev.Adds
scripts/dev-benchmark.tsto automate measuringbun run devreadiness and a couple of/docsrequest latencies.Written by Cursor Bugbot for commit 86716eb. This will update automatically on new commits. Configure here.