Skip to content

perf(data-pages): replace O(N) linear-scan with direct /v1/<kind>/:slug lookup#14

Open
chrisjmendez wants to merge 1 commit into
mainfrom
feat/perf-direct-slug-lookups
Open

perf(data-pages): replace O(N) linear-scan with direct /v1/<kind>/:slug lookup#14
chrisjmendez wants to merge 1 commit into
mainfrom
feat/perf-direct-slug-lookups

Conversation

@chrisjmendez
Copy link
Copy Markdown
Contributor

Closes #9 (partially — see scope note).

What changed

Two data profile pages were fetching 500 records and then .find()-ing the slug we actually needed. The REST API already exposes GET /v1/<kind>/:slug (mounted by buildDomainRouter), which does the lookup in O(1). Switching cuts per-page bytes-over-the-wire by ~100× and removes a latent CF-throttle risk during ISR revalidation.

Page Before After
apps/web/src/app/data/compatibility/[slug]/page.tsx fetch(/v1/compatibility-edges?limit=500) + .find() fetch(/v1/compatibility-edges/${slug})
apps/web/src/app/data/deploys/[slug]/page.tsx new FestivusClient().searchDeployNotes({ limit: 500 }) + .find() fetch(/v1/deploy-notes/${slug})

Both now mirror the pattern already used by apps/web/src/app/data/benchmarks/[slug]/page.tsx.

Scope note: papers excluded

Issue #9 lists three pages. This PR refactors two. The third — apps/web/src/app/data/papers/[slug]/page.tsx — needs separate API work first: GET /v1/papers/paper16 returns 404 not_found today even though the Prisma papers table has a slug column. The seeded slug values do not match the in-JSON id field that the URL passes through. Fixing that is a schema/seed alignment, not a page refactor; it gets its own PR.

Verify

  • pnpm check (typecheck + lint): ✅ green
  • pnpm test: 605/606 — the one failure is the local-api canary that needs a running localhost:8000. Re-run against the production API: FESTIVUS_DATASET_API_URL=https://api.festivus.hapticlabs.ai npx vitest run tests/seed-validation/festivus-api-canary.test.ts → 1/1 passes
  • Live API spot-check before publish:
    • curl -o /dev/null -w "%{http_code}" https://api.festivus.hapticlabs.ai/v1/compatibility-edges/franka-research-3__openvla-openvla-7b200
    • curl -o /dev/null -w "%{http_code}" https://api.festivus.hapticlabs.ai/v1/deploy-notes/deploy-arm-1200

DCO

Signed-off-by trailer on the commit.

Test plan after merge

  1. Hit any compat-edge profile page in prod (e.g. /data/compatibility/franka-research-3__openvla-openvla-7b) → still renders.
  2. Hit any deploy-note profile page → still renders.
  3. Network tab confirms each page fires one request, not a limit=500 list.

Refs: #9

…ug lookup

Two data profile pages were fetching 500 records and then .find()-ing
the slug we actually needed. The REST API already exposes
GET /v1/<kind>/:slug (mounted by buildDomainRouter), which does the
lookup in O(1). Switching cuts per-page bytes-over-the-wire by ~100x
and removes a latent CF-throttle risk during ISR revalidation.

Files changed:
- apps/web/src/app/data/compatibility/[slug]/page.tsx
- apps/web/src/app/data/deploys/[slug]/page.tsx

Both now mirror the pattern already used by benchmarks/[slug]/page.tsx.

Scope note: the papers/[slug] page (also cited in #9) needs separate
API work first: /v1/papers/paper16 returns 404 today because the seeded
slug column does not match the in-JSON id. That gets its own PR after a
schema/seed alignment.

Refs: #9
Signed-off-by: chrisjmendez <65565+chrisjmendez@users.noreply.github.com>
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.

perf: replace findPaper / findEdge / findDeploy linear-scan with direct /v1/<kind>/:slug calls

1 participant