perf: get every authenticated page under 500ms - #147
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults 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)
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 |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adversarial review — perf missionRead the migration, the new data layer, the auth changes, and the perf harness. The shape of this work is right: the expensive aggregate moves to a cron-refreshed private table, the request path reads a bounded snapshot, and The 1. The documented fallback never fires in the failure mode that matters
const snapshot = await snapshotQuery;
if (!snapshot.error) {
return (snapshot.data ?? []) as LeaderboardRow[];
}A query that returns zero rows is not an error, so the three realistic failure modes all return a successful empty answer and never reach the view:
The fix is cheap because the schema already carries the signal and the reader throws it away: Worth pairing with a 2. Two rank sources now disagree with each other
So the same user can see rank 5 in the CLI right after a push and rank 7 on Pick one: convert those readers to the snapshot too (consistent, uniformly ≤10 min stale), or scope snapshots to the leaderboard listing and keep every rank live. Either is defensible; having both is not. 3.
|
Summary
pg_cron, snapshot-first cached readers, a set-based streak function, and strict public/private cache boundariesPerformance result
Two consecutive clean-checkout
bun run perf:checkruns passed all 10 authenticated routes./feed/leaderboard/u/[username]/post/[id]/notifications/messages/prompts/recap/settings/searchRight-sidebar API median: 30 ms. Initial authenticated-route JavaScript fell by about 39 KiB gzip after removing the development-only Agentation toolbar from production entry bundles.
Database deployment
The two Supabase migrations in this PR are already applied to project
kanfzeovbmusnhmbnhit.refresh-leaderboard-snapshotscron job is active on*/10 * * * *get_profile_stats; service-role access succeedsVerification
bun run perf:checktwice: 12/12 Playwright checks and 10/10 route gates on both runsbun run typecheck: passedbun run build: passed repeatedly, including both final perf runsbun run analyze: passedgit diff --check: passedPost-deploy check
PostHog
$web_vitalsand custom TTFB reporting are implemented and documented, but production p75 validation remains the non-gating honesty check after deployment.