Skip to content

perf(web): stop rebuilding a whole plan for three sample lines - #58

Merged
404SecNotFound merged 1 commit into
mainfrom
perf/sample-cache
Aug 3, 2026
Merged

perf(web): stop rebuilding a whole plan for three sample lines#58
404SecNotFound merged 1 commit into
mainfrom
perf/sample-cache

Conversation

@404SecNotFound

Copy link
Copy Markdown
Owner

Review finding #3. The sample endpoint fires whenever the operator selects a
technique in the catalog rail, and it built the entire plan to pick three lines
out of it. REP-004 at high intensity is 180,000 events and about 1.6 seconds of
pure CPU, discarded immediately, on every click.

The reviewer suggested a "build three and stop" path. That would change what the
sample shows: it is deliberately the FIRST, MIDDLE and LAST event, and the middle
of three is not the middle of the run. So the cost is cached rather than the
output truncated.

The cache is exact, not approximate. The request is built from a fixed seed and a
fixed intensity, so (technique, intensity, vendor) determines the lines
completely. Bounded because a server is long-lived, though the whole key space is
24 techniques x 3 intensities x 3 vendors.

Guarded by counting build_plan calls rather than timing, which passes or fails on
how busy the machine is, plus three tests that the cache did not change what a
sample contains or leak across intensity and vendor.

952 py. black, ruff, mypy clean.

Review finding #3. The sample endpoint fires whenever the operator selects a
technique in the catalog rail, and it built the entire plan to pick three lines
out of it. REP-004 at high intensity is 180,000 events and about 1.6 seconds of
pure CPU, discarded immediately, on every click.

The reviewer suggested a "build three and stop" path. That would change what the
sample shows: it is deliberately the FIRST, MIDDLE and LAST event, and the middle
of three is not the middle of the run. So the cost is cached rather than the
output truncated.

The cache is exact, not approximate. The request is built from a fixed seed and a
fixed intensity, so (technique, intensity, vendor) determines the lines
completely. Bounded because a server is long-lived, though the whole key space is
24 techniques x 3 intensities x 3 vendors.

Guarded by counting build_plan calls rather than timing, which passes or fails on
how busy the machine is, plus three tests that the cache did not change what a
sample contains or leak across intensity and vendor.

952 py. black, ruff, mypy clean.
@404SecNotFound
404SecNotFound merged commit 5d29d70 into main Aug 3, 2026
10 checks passed
@404SecNotFound
404SecNotFound deleted the perf/sample-cache branch August 3, 2026 19:35
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