perf(web): stop rebuilding a whole plan for three sample lines - #58
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.