Skip to content

perf(phase 1): parallelize server waterfalls (dashboard + defaulters)#44

Draft
veerpatta wants to merge 1 commit into
perf/phase-0-region-measurefrom
perf/phase-1-waterfall-streaming
Draft

perf(phase 1): parallelize server waterfalls (dashboard + defaulters)#44
veerpatta wants to merge 1 commit into
perf/phase-0-region-measurefrom
perf/phase-1-waterfall-streaming

Conversation

@veerpatta

Copy link
Copy Markdown
Owner

Phase 1 — Server waterfall + streaming

Stacked on #43 (Phase 0). Base will be retargeted to main once Phase 0 merges. Review the 2-commit diff vs Phase 0.

Goal is latency, not features; behaviour identical, auth gating preserved.

Changes

Dashboard (app/protected/dashboard/page.tsx)

  • Auth remains the gate (awaited first — no protected fetch before it resolves).
  • getTranslations + searchParams + getViewSessionCookie now load concurrently.
  • aboveFold (heavy summary RPC) and today's activity counts now run in one Promise.all instead of in series — the main win.

Defaulters (app/protected/defaulters/page.tsx)

  • getDefaultersPageData and listWhatsappTemplates are 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 Suspense boundaries 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) that activity:start precedes aboveFold:end — i.e. the reads overlap. If they were still chained, aboveFold:end would come first. No wall-clock → no flakiness. The Phase 0 [perf] instrumentation will also show total ≈ max(aboveFold, activity) rather than the sum on the bom1 preview.

Validation

  • typecheck + lint clean.
  • npm run test: 784 passed. 2 failures are pre-existing on main and unrelated (README drift in tests/unit/migration-verification-scripts.test.ts — flagged separately).
  • /code-review + /security-review to follow before marking ready.

Safety

  • Zero changes to live 2026-27 data. No schema/migration changes.
  • Tested on TEST-2026-27.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schoolfees Ready Ready Preview, Comment May 31, 2026 7:16am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant