feat: performance budget and telemetry for time-to-first-proof (#432) - #490
feat: performance budget and telemetry for time-to-first-proof (#432)#490iyanumajekodunmi756 wants to merge 3 commits into
Conversation
…roof (ToluLabs#432) Adds local measurement of witness/prove/submit stage timings and total time-to-first-proof for every proof, explicit performance budgets with over-budget flags, a lazily-loaded debug view on the holder page, and an opt-in endpoint that aggregates only anonymized, device-class-bucketed numbers. No identity data is collected or transmitted. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@iyanumajekodunmi756 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
The time-to-first-proof telemetry (#432) is good work. It now conflicts with main though: #489 (preflight simulation) just merged and also edits frontend/app/holder/page.tsx. Please rebase onto latest main and fold the perf panel into the current holder page. Two things to confirm after rebasing: the telemetry stays opt-in with no PII (anonymized aggregates only), and if you bumped .size-limit.json, note that the shared-chunk budget is now 740 kB on main, so rebase that value rather than overwriting it. |
|
Still conflicting with main (holder/page.tsx moved again with #489). Please rebase. Same notes as before: keep the telemetry opt-in and PII-free, and if you touch .size-limit.json the shared-chunk budget on main is now 740 kB, so rebase that value rather than overwrite it. |
Summary
Closes #432.
Proving time is the core UX metric for StellarCred but was never tracked. This PR establishes explicit performance budgets, measures time-to-first-proof and per-stage timings (witness, prove, submit) locally for every proof, surfaces them in a debug view, and adds an opt-in channel for reporting only anonymized, device-class-bucketed aggregates so regressions can be spotted.
The implementation is deliberately privacy-safe: no wallet address, no commitment, no credential values — only the circuit kind, a coarse device class (core/memory counts), and raw timing numbers.
Problem
What was added
1.
lib/proof-perf.ts— slim measurement core (statically imported by the holder page)ProofRunTracker+createProofRun(): times stages viameasure("witness" | "prove" | "submit", fn, warm?)(durations recorded infinally, so failed stages still produce timings), computestimeToFirstProofMs(witness + prove) andtotalMs(incl. submission), and records a bounded history (last 50) inlocalStorage.PROOF_PERF_TARGETS(witness 20s, prove 60s, submit 15s, total 90s — derived from the existing "~10–20s" UX estimate and the 120s proof timeout). Any stage/total over target setsexceededBudgetfor flagging.recordSubmit(ms)attaches the on-chain submission stage to the same run afterwards.hardwareConcurrency/deviceMemory; no identity data anywhere.2.
lib/telemetry-reporter.ts+lib/proof-telemetry.ts— aggregates & opt-in reporting (dynamically imported only)summarizeProofs()→ per-stage avg/p50/min/max + over-budget counts.isTelemetryOptIn/setTelemetryOptIn(localStorage flag) andreportOptedInRuns()→ POSTs only not-yet-reported runs to the server; never throws, so reporting can never break proving.3.
POST /api/proof-telemetry(app/api/proof-telemetry/route.ts)4. Holder page instrumentation (
app/holder/page.tsx,lib/proof.ts)ProofFlow(single) andBatchProofFlow(batch) now wrap witness/prove/submit with the tracker; errored runs are recorded with the failing stage attributed.lib/proof.tsgainedisProverWarm(type)so runs can distinguish cold vs. warm proving.components/ProofPerfPanel.tsx,next/dynamic,ssr: false) showing per-run and aggregate timings, over-budget flags, the opt-in toggle, a Report button, and Clear.5. Bundle budget
.size-limit.json(same approach the repo took in Add issuer reputation stats, delegated verification, and selective disclosure presets #483 when it raised the shared budget for feature growth).Verification
All CI-equivalent checks pass locally:
pnpm tsc --noEmit✅pnpm lint✅pnpm test— all 320 tests pass (incl. newlib/proof-perf.test.tsandapp/api/proof-telemetryroute tests; the proof-perf suite uses faked clocks for deterministic stage timings) ✅pnpm build(production, with CI env vars) ✅pnpm size— Holder 17.02 kB / 18 kB, Shared 720.48 kB / 740 kB, all other routes under budget ✅pnpm test:theme✅ andpnpm --filter @stellarcred/issuer test✅Notes
/holderis unaffected.closes #432