perf: bundle analyzer + Server-Timing measurement rail (perf round 2, phase 0)#458
Conversation
Phase 0 of the round-2 performance initiative: measurement before change. - @next/bundle-analyzer (devDep) behind ANALYZE=true via an async config wrapper that lazy-imports it, so pruned production runtimes never load it; npm run build:analyze wraps the normal build cross-platform. - Server-Timing headers on /api/answer and /api/search/universal built from the latency fields the pipeline already computes (rag latencyTimings, per-domain universal-search latencyMs). Durations and short metric names only - no query text or user data crosses the trust boundary. The SSE stream route already carries latencyTimings in its final event. - Baseline captured (webpack prod build): 4795.4 KB raw / 1133.9 KB gzip client JS across 178 chunks; chunk 2419 (337.1 KB raw) holds the DocumentManagerPanel suite + SettingsDialog targeted by the next phase. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughAdds reusable ChangesServer timing instrumentation
Bundle analysis build tooling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant AnswerRoute
participant ServerTiming
participant NextResponse
Client->>AnswerRoute: POST /api/answer
AnswerRoute->>ServerTiming: latency timings and elapsed duration
ServerTiming-->>AnswerRoute: sanitized Server-Timing header
AnswerRoute->>NextResponse: answer JSON with optional header
NextResponse-->>Client: response
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (8 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Summary
Phase 0 (measurement/enablement) of the round-2 site-performance initiative — no behavior change, just the rails every later phase is measured against.
@next/bundle-analyzer(devDependency) behindANALYZE=true, lazy-imported via an async config wrapper so pruned production runtimes never load it.npm run build:analyzewraps the normal webpack build cross-platform./api/answerand/api/search/universal, built from latency fields the pipeline already computes (answer.latencyTimings, per-domainlatencyMs). Only short metric names and millisecond durations are emitted — no query text or user data crosses the trust boundary (sanitizer + unit tests included). The SSE stream route already shipslatencyTimingsinside itsfinalevent, so it needs no header.Baseline (webpack prod build, this branch)
2419(337.1 KB raw / 88.2 KB gzip) contains theDocumentManagerPanelsuite +SettingsDialog— the phase-1 split targetVerification
npm run verify:cheap: runtime/actions/sitemap/lint/typecheck green; vitest 1416 passed with 2 machine-load timeout flakes (public-access-deep,rag-classifier-memo) that fail identically on clean HEAD (5 tests fail there) — pre-existing, not introduced heretests/server-timing.test.tspasses (header sanitization + mapping)ANALYZE=true(report written to.next/analyze/)🤖 Generated with Claude Code