perf(phase 1): parallelize server waterfalls (dashboard + defaulters)#44
Draft
veerpatta wants to merge 1 commit into
Draft
perf(phase 1): parallelize server waterfalls (dashboard + defaulters)#44veerpatta wants to merge 1 commit into
veerpatta wants to merge 1 commit into
Conversation
Phase 1 — collapse server-side request waterfalls into concurrent reads; behaviour identical, auth gating preserved. Dashboard (app/protected/dashboard/page.tsx): - Auth stays the gate (awaited first). Translations + searchParams + session cookie now load concurrently (independent of each other and of auth output). - aboveFold (the heavy summary RPC) and today's activity counts are independent reads — run them in one Promise.all instead of chaining. This is the main win. Defaulters (app/protected/defaulters/page.tsx): - The defaulters list (getDefaultersPageData) and the WhatsApp template list (listWhatsappTemplates) are independent — fetch concurrently rather than chaining templates after the heavier defaulters query. Transactions + Payments already parallelize their heavy reads via Promise.all, so they're left as-is (no churn). Streaming: below-the-fold dashboard panels and the payment desk already render inside Suspense boundaries with skeletons, so the shell + KPIs paint before the slow panels resolve. No new boundaries needed. Test: tests/ui/dashboard-waterfall.test.tsx renders the page with mocked, delayed loaders and asserts via an ordered event log that today's activity STARTS before aboveFold ENDS (proves concurrency, deterministic — no wall-clock flakiness), that the auth gate precedes the protected reads, and that the element builds end-to-end (data-flow correctness). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Phase 1 — Server waterfall + streaming
Goal is latency, not features; behaviour identical, auth gating preserved.
Changes
Dashboard (
app/protected/dashboard/page.tsx)getTranslations+searchParams+getViewSessionCookienow load concurrently.aboveFold(heavy summary RPC) and today's activity counts now run in onePromise.allinstead of in series — the main win.Defaulters (
app/protected/defaulters/page.tsx)getDefaultersPageDataandlistWhatsappTemplatesare independent → fetched concurrently instead of chained.Transactions + Payments already parallelize their heavy reads via
Promise.all— left untouched (no churn).Streaming — below-the-fold dashboard panels and the payment desk already render inside
Suspenseboundaries with skeletons, so the shell + KPIs paint before slow panels resolve. No new boundaries required.Measurement
Deterministic concurrency proof in
tests/ui/dashboard-waterfall.test.tsx: with mocked, delayed loaders, asserts (via an ordered event log) thatactivity:startprecedesaboveFold:end— i.e. the reads overlap. If they were still chained,aboveFold:endwould come first. No wall-clock → no flakiness. The Phase 0[perf]instrumentation will also showtotal ≈ max(aboveFold, activity)rather than the sum on the bom1 preview.Validation
typecheck+lintclean.npm run test: 784 passed. 2 failures are pre-existing onmainand unrelated (README drift intests/unit/migration-verification-scripts.test.ts— flagged separately)./code-review+/security-reviewto follow before marking ready.Safety
2026-27data. No schema/migration changes.TEST-2026-27.🤖 Generated with Claude Code