Skip to content

Epic: Page-load performance — close the cold-load auth-handshake gap #2386

Closed

Description

@yannickmonney

Problem

General page loading takes noticeably long. Measured live 2026-07-02 on a warm local stack via the built-in [cold-load] markers: module-load: 478ms → convex-authenticated: 1308ms → member-context: 1337ms → account-bootstrap: 1341ms. The ~830ms between module-load and convex-authenticated is pure auth handshake (Better Auth session → Convex token → WS authenticate) during which every auth-gated query — including the prefetched getAccountBootstrap — is blocked. Production cold loads (CDN + real network + backend cold start) are correspondingly worse.

Current architecture (already in place)

  • app/router.tsx — warmSession() kicks the session fetch at module load; markColdLoad tracing (app/lib/perf/cold-load-trace.ts).
  • routes/dashboard.tsx — loader prefetches api.bootstrap.queries.getAccountBootstrap to overlap the WS handshake; one-shot stuck-handshake recovery reload.
  • app/hooks/use-convex-query.ts:19 — auth-gated queries can't fire during the auth gap (the known bottleneck).
  • session-query.ts comments identify the serial HTTP auth hops as the main lever.

Proposed direction (sub-items to split out as work starts)

  • Collapse/parallelize the serial auth hops (session → token → WS auth) — e.g. token endpoint returning everything in one round trip, or token piggybacked on the session response.
  • Serve the first authenticated queries over HTTP while the WS authenticates (or pre-authenticate the WS with a cached token from the previous session).
  • Cache last-known bootstrap data (org name, member context) for instant shell hydration with revalidate.
  • Track the [cold-load] markers in CI/perf dashboards so regressions are visible.

Acceptance criteria

  • convex-authenticated lands ≤ ~500ms after module-load on the local reference setup (today ~830ms).
  • No skeleton longer than one perceptible beat on warm reloads of dashboard routes.
  • Cold-load markers recorded/tracked so the numbers can't silently regress.

Activity

  1. added
    perf
    service: platform
    epic
    on Jul 2, 2026
  2. yannickmonney commented on Jul 11, 2026

    @yannickmonney
    ContributorAuthor

    Deferred from the umbrella-epic sweep (PR #2674): architectural perf epic (auth-handshake collapse, HTTP-first queries, bootstrap caching) — too large and design-heavy to bolt onto a sweep PR; needs its own effort with live perf measurement.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicperfservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions