8 Commits
Author SHA1 Message Date
Claude 67cd0c945a Docker: standalone server, bundled worker, no caches in the image
Release / release (push) Failing after 10s
The runtime stage copied the whole production node_modules (495 MB, with
shadcn's CLI tree, the SWC compiler and sharp) and all of .next (163 MB, 119 MB
of it Turbopack's build cache). The image is now 427 MB instead of 1.04 GB:

- Next.js standalone output (NEXT_OUTPUT=standalone, set by the Dockerfile; a
  local `next build`/`next start` is unchanged): server.js with only the traced
  node_modules (39 MB). images.unoptimized (nothing uses next/image) keeps sharp
  and libvips out of the server's trace; /_next/image answers 404.
- build:worker bundles drizzle-orm, zod and ulid into dist/*.mjs and keeps only
  @libsql/client and libsql external; the standalone node_modules has both.
- npm's cache and .next/cache are BuildKit cache mounts: reused by the next
  build on the same machine (Next build 30 s -> 12 s after a code change), never
  in a layer.
- Release archives (BetterBench, both L80 tarballs) are fetched in their own
  stage; only the L80 binary is copied, BetterBench is installed from a bind
  mount.
- shadcn and tw-animate-css (CSS imports, build time only) move to
  devDependencies; package-lock.json regenerated with npm 11 (the image's npm).

Verified by building the image and running web, worker and sandbox from it:
pages and /api/live answer, the worker migrates, takes the lease and finds hf,
BetterBench and L80, all three healthchecks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 21:23:51 +00:00
Claude 6b779debf7 DB: indexes for the polling queries
- jobs(finished_at): the live view's "open or finished in the last 5 minutes"
  query, run once a second per visible tab, was a full scan of the job
  history; it is now a multi-index lookup (0.23 -> 0.04 ms at 2,000 jobs).
- benchmark_runs(state, created_at): the worker's look for the next queued run
  every 2 s scanned every run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 21:04:45 +00:00
Claude 6f4932e04d Hub: reuse commit trees, ask for SHAs only, stream the model card
- listFiles() keeps the last trees it fetched by repo@SHA (a commit's files
  never change; capped at 50,000 files): adding a model right after the lookup
  no longer downloads the whole tree again. Callers get copies.
- addModel() fetches the author's avatar in parallel with the file list.
- The Hub check resolves revisions with resolveRevision(): /revision/<rev> with
  expand=sha, as huggingface_hub's model_info(expand=...) does, instead of the
  full model info (file list, card data, the Spaces using the model). Falls
  back to the full request if an answer comes without a SHA.
- The Model card tab renders inside <Suspense>: the page no longer waits for
  the README to arrive from the Hub (up to the 20 s timeout when it's slow).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 21:04:05 +00:00
Claude d58bff3437 Worker: write only what changed, sample downloads less
- The models folder scan compared nothing and rewrote local_folders on every
  run (delete all, insert all, each folder's file list included), every 2
  minutes by default: ~1 MB of SQLite writes per scan with three large import
  folders. It now inserts new folders, updates changed ones and deletes gone
  ones; unchanged rows (compared by counts, commit and the stored JSON text)
  aren't written.
- Download progress and the speed limit share one ProgressSampler. A file found
  complete isn't stat'ed or its hf metadata re-read again during the run, and
  with every file complete the partial files aren't listed. Before, every
  sample looked at every file, 5 times a second with a speed limit set. The
  check after hf exits still looks at every file.
- A benchmark's phase is written when its step changes, not for every
  progress line BetterBench prints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 21:01:11 +00:00
Claude d10a491042 Client bundles: no drizzle in the browser, lazy palette, one copy of the painting
- The enum arrays move from schema.ts to src/lib/db/enums.ts (no imports),
  which schema.ts re-exports. The endpoint form and benchmark start imported
  ENDPOINT_ENGINES/QUALITY_SECTIONS from the schema, which put drizzle-orm,
  every table definition and ulid (18 KB gzipped) on the endpoint pages. An
  ESLint rule now refuses value imports from the schema in client code.
- The ⌘K palette dialog is its own chunk, loaded on first open and preloaded
  when you hover or focus Search or press ⌘/Ctrl.
- The dot painting's brightness grid was copied into 10 page chunks (~10 KB
  gzipped each); it is now one async chunk, parsed once per tab. The canvas
  skips redraws when size, pixel ratio and theme are unchanged (the
  ResizeObserver's first callback drew everything a second time) and draws at
  most once per frame while resizing.

First-load JS per route drops by 10-29 KB gzipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 20:57:53 +00:00
Claude 2e56351e96 Benchmarks: lean list queries
listBenchmarks() selected every column of every run, including the raw A/B
series, all quality eval items, hardware facts and descriptions, while lists
show only the snapshot, settings, headline numbers and the quality score. With
200 runs /api/benchmarks returned 732 KB, re-fetched every 3 s while a run was
active; the table used about 55 KB of it.

- listBenchmarks() returns lean rows: the headline numbers are computed on the
  server from the summary, the quality score comes from json_extract().
- The model page asks for 5 runs (it shows 5), the ⌘K index for 300.
- getBenchmark()/getBenchmarks() keep the full rows for detail and compare;
  cancel and delete only read the state.
- ListRow (lists) and RunRow (detail) are separate types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 20:52:12 +00:00
Claude 7239ba2692 Library: load import folder files on demand, memoize search
The library page passed every importable folder's full file list (up to 5,000
entries each, from the worker's scan) into a client component, though it is
only used after clicking Import. With three such folders that was 84% of a
1.3 MB page, re-sent on every refresh after a job finished.

- listLocalFolders() returns path, commit and counts only; the Import button
  fetches one folder's files from GET /api/local-folders?path=…
- addModel() checks that an import folder exists without loading its files.
- LibraryView builds each model's search text once and memoizes the visible
  rows and facet counts; the facet sort uses one Intl.Collator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 20:49:18 +00:00
Claude 76d851896e Live updates: one poller per tab instead of SSE streams
Every useLive() call opened its own EventSource, and the library page and a
model's Jobs tab call it twice. Over plain HTTP a browser allows 6 connections
per host, so with three library tabs open the third took ~10 s to load and its
requests never got an answer; a fourth tab didn't load.

- /api/live answers one short request with the job snapshot (left out when the
  client already has that version) and, for job pages, new log lines.
- src/lib/live-store.ts runs one poller per query per tab, shared by every
  component showing it, paused while the tab is hidden, with backoff on errors.
  One router.refresh() per finished job instead of one per component.
- The worker dot reads the status from that poll; it only asks /api/status
  (every 10 s) when nothing else is polled.
- The worker status no longer carries the heartbeat time (it changed every 5 s,
  so every idle stream re-sent its snapshot) and rounds free space to MiB.
- Removes /api/stream: its sleep() added an abort listener per second to the
  request signal and never removed it.
- Job actions poll right away after starting or cancelling a job; drops
  approveJob/rejectJob, whose routes went away in 0.15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 20:46:54 +00:00