Skip to content

perf(judge): warm the screenshot cache before the parallel samples - #143

Merged
dadachi merged 1 commit into
mainfrom
perf/judge-cache-warmup
Oct 15, 2026
Merged

dadachi merged 1 commit into
mainfrom
perf/judge-cache-warmup

Conversation

@dadachi

@dadachi dadachi commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Problem

#142 showed every judge call writing the screenshot cache and none reading it: a rubric's samples (2 criteria × 3) were sent in parallel, so all of them missed the cache. Caching made the judge ~25% more expensive than no caching.

Fix

firstThenTogether() runs the first sample alone (writes the cache), then the rest together (read it). Results keep rubric order; the per-criterion majority vote is unchanged.

Measured (real calls, same iOS home screenshot, DEFAULT_STAGE1_RUBRIC)

cache write cache read cost / platform
before (#142) 6 × 4,376 0 $0.152
after 1 × 4,376 5 × 4,376 $0.054

README: VISUAL=1 $0.32 → **$0.13**, VISUAL=2 $0.62 → **$0.24**, judge retry ~$0.15 → ~$0.05 per platform. Costs a few extra seconds per platform (one call before the batch).

Tests

New smoke test for firstThenTogether (first call finishes before the rest start; the rest run concurrently; order kept) — red when the helper runs everything in parallel, green after. npm run ci: 157 pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH

All judge samples of a screenshot share the cached prefix (system prompt +
image), but they were sent at the same time, so every call missed the cache
and wrote it (1.25x input) and none read it. runLayer3 now sends one sample
first, then the rest together (firstThenTogether), so they read the cache
(0.1x input).

Measured on the same iOS home screenshot with DEFAULT_STAGE1_RUBRIC
(2 criteria x 3 samples): 1 cache write + 5 cache reads, $0.054 per platform
instead of $0.152 (-65%). README cost table updated: VISUAL=1 ~$0.13
(was ~$0.32), VISUAL=2 ~$0.24 (was ~$0.62). Adds a few seconds per platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5hZEFqXhBsUQwSWsgR6eH
@dadachi
dadachi merged commit 25e6ce9 into main Oct 15, 2026
1 check passed
@dadachi
dadachi deleted the perf/judge-cache-warmup branch October 15, 2026 02:30
@dadachi dadachi mentioned this pull request Oct 15, 2026
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.

1 participant