Skip to content

test(perf): first_prompts is not the /api/day bottleneck (harness only)#154

Merged
Arylmera merged 1 commit into
developfrom
perf/first-prompts
May 31, 2026
Merged

test(perf): first_prompts is not the /api/day bottleneck (harness only)#154
Arylmera merged 1 commit into
developfrom
perf/first-prompts

Conversation

@Arylmera

Copy link
Copy Markdown
Owner

Finding

Follow-up to #153. The chip suspected first_prompts was the dominant /api/day cost (~95ms of a ~108ms end-to-end). Measured directly, that was a measurement artifact:

Probe Time
6 day aggregation queries ~14 ms
first_prompts (188 session ids) ~6 ms
/api/day server-side, raw HTTP (no parse) ~31 ms
HttpClient localhost floor (/api/health) ~0.2 ms
Invoke-RestMethod parse overhead (PowerShell) +~75 ms

The earlier ~108ms came from PowerShell's Invoke-RestMethod deserializing the response into objects — a client-side cost absent in the app (the JS frontend parses the 4.6 KB payload natively in <1 ms). True server-side /api/day is ~31 ms warm, already under the 50 ms target.

Decision: no query change

first_prompts at 6 ms isn't worth rewriting. A GROUP BY MIN(timestamp) + join would risk the identical-timestamp tie case for a ~4 ms gain on an endpoint already fast.

What this PR does

Adds a first_prompts timing + EXPLAIN to the perf_probe example so the finding stays measurable. No production code touched.

Verification

cargo fmt --check + cargo clippy --examples -D warnings clean. Lesson recorded in the spec: measure server endpoints with a raw byte fetch, not Invoke-RestMethod.

🤖 Generated with Claude Code

…bottleneck

Follow-up to PR #153 suspected first_prompts dominated /api/day (~95ms
of ~108ms end-to-end). Measured directly: first_prompts is ~6ms for
~188 sessions and the endpoint is ~31ms server-side (raw HTTP). The
earlier ~108ms was PowerShell Invoke-RestMethod deserializing the 4.6KB
response into objects — a client-side artifact absent in the app, whose
JS frontend parses the payload natively in <1ms.

No query change warranted: rewriting the windowed query to GROUP BY
MIN(timestamp) would risk the identical-timestamp tie case for ~4ms on
an endpoint already under the 50ms target. Add the first_prompts timing
+ EXPLAIN to perf_probe so the finding stays measurable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Arylmera Arylmera merged commit e6dadfc into develop May 31, 2026
7 checks passed
@Arylmera Arylmera deleted the perf/first-prompts branch May 31, 2026 10:16
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