Skip to content

Suppress redundant served viewport requests#195

Draft
Alek99 wants to merge 1 commit into
mainfrom
agent/cache-served-view-requests
Draft

Suppress redundant served viewport requests#195
Alek99 wants to merge 1 commit into
mainfrom
agent/cache-served-view-requests

Conversation

@Alek99

@Alek99 Alek99 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Closes #168

Summary

Adds bounded, correctness-checked client no-op suppression for viewport work whose latest accepted reply is already represented by live GPU state:

  • exact tier and per-trace density/drill keys include payload generation, normalized view window, rounded plot pixels, axes, and trace identity
  • only complete, current-sequence, successfully applied replies become memo hits
  • one current accepted key per request slot prevents A→B→A from pretending an evicted/nonresident A reply is still live
  • a 64-entry LRU bounds trace/axis churn
  • full payload replacement, append, context loss, partial/unsolicited replies, failed applies, replaced textures/buffers, and dead drills invalidate or miss
  • drill and selection versions remain live-state checks; response bytes are never replayed

The independent review found and fixed a failure-atomicity gap: an invalid reply could mutate an in-place GPU buffer and then throw while the old accepted key remained live. The cache slot is now invalidated before the first fallible decode/upload, and a real-browser regression injects a partial mutation followed by an invalid buffer and proves that returning to the old view retries.

This deliberately covers exact accepted-request no-ops. Tile-keyed density reuse and edge-tile shipping remain explicitly documented as pending future work; this PR does not claim them.

Performance and wire evidence

Reproducible benchmark: 120,000 points, combined decimated line plus density/drill viewport, 21 repetitions.

avoided work for one accepted duplicate result
kernel round trips 2
reply payload bytes 151,704 B
complete XYBF frame bytes 152,432 B
unchanged tier bytes on y-only pan 7,704 B
kernel work, median 0.195375 ms
kernel work, minimum 0.191916 ms

The browser lifecycle suite also verifies exact hits cause no messages while changed views, pixels, generations, axes, traces, partial state, or invalidated GPU objects continue to request normally.

Verification

  • focused production-bundle Chromium lifecycle suite: 4 passed in 5.87 s
    • exact/stale/in-flight/partial replies
    • failed-apply retry after a forced partial GPU mutation
    • drill and selection versioning
    • y-only pan and resize
    • 64-entry LRU
    • density texture and payload/append/context-loss lifecycles
  • adjacent channel, LOD, density, drill, payload, wheel, animation, and static-client suites: 153 passed in 11.47 s
  • full suite: 2212 passed, 66 skipped, with exactly one known pre-existing failure: tests/reflex_adapter/test_assets.py::test_client_source_is_the_installed_bundle; the identical stale minified-bundle literal-marker assertion was reproduced on untouched main
  • node js/build.mjs --check: committed bundles fresh
  • tsc -p js/tsconfig.json --noEmit: passed
  • ruff check .: passed
  • ruff format --check .: all 343 files formatted
  • git diff --check: passed

The deterministic wire/kernel benchmark is committed as benchmarks/bench_served_view_memo.py.

@codspeed-hq

codspeed-hq Bot commented Jul 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 97 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing agent/cache-served-view-requests (e480857) with main (2a7d898)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR suppresses redundant viewport requests when the accepted result is still represented by live GPU state. The main changes are:

  • Exact request keys for tier and per-trace density work.
  • Bounded memo storage with request-slot and GPU-resource checks.
  • Invalidation across payload, append, context, and failed-apply lifecycles.
  • Browser lifecycle tests and deterministic wire benchmarks.
  • Updated generated clients and architecture documentation.

Confidence Score: 5/5

This looks safe to merge.

No blocking issues found in the changed code.

T-Rex T-Rex Logs

What T-Rex did

  • The build configuration was updated to exactDuplicateRequests=0, failedApplyThrew=true, and failedApplyRetryTypes=["view"], and the corresponding request-type handling adjustments for partial replies, density_view, and resize were documented.
  • A lifecycle probe sequence was executed that performed full payload replacement, append, context loss, and context restore, which invalidated memoized state and scheduled fresh work with generationSteps=2 and contextReady=true.
  • Baseline behavior was observed: the parent production bundle produced the expected missing-memo probe error while still rendering the real 480×360 chart.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
js/src/54_kernel.ts Adds viewport request keys, accepted-reply memoization, live-resource validation, selective scheduling, and failure-safe invalidation.
js/src/50_chartview.ts Initializes memo state and clears it when the WebGL context is lost or the chart is destroyed.
js/src/56_animation.ts Advances the data generation before replacing payload and GPU state.
tests/test_served_view_memo.py Covers exact hits, changed requests, stale and partial replies, failed applies, resource invalidation, context loss, and LRU behavior.
benchmarks/bench_served_view_memo.py Measures kernel work and response bytes avoided by an accepted duplicate viewport request.
python/xy/static/index.js Updates the generated production client with viewport memoization.
python/xy/static/standalone.js Updates the generated standalone client from the TypeScript source.

Reviews (1): Last reviewed commit: "Suppress redundant served viewport reque..." | Re-trigger Greptile

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.

Interactive traffic lacks no-op suppression: redundant view/density/sample re-ships

1 participant