Skip to content

Stop re-fetching every thumbnail on each new plot - #262

Open
r2evans wants to merge 1 commit into
nx10:masterfrom
r2evans:fix/260-incremental-lag
Open

Stop re-fetching every thumbnail on each new plot#262
r2evans wants to merge 1 commit into
nx10:masterfrom
r2evans:fix/260-incremental-lag

Conversation

@r2evans

@r2evans r2evans commented Jul 10, 2026

Copy link
Copy Markdown

Each sidebar thumbnail URL embedded the device-global update counter (upid) as a cache-busting query parameter. Since upid increments on every device update, drawing one new plot changed the URLs of all N thumbnails at once, causing the browser to re-download and the server to re-render the entire plot history on every plot (O(N^2) over a session). This made the client progressively slower as plots accumulated, regardless of plot complexity.

Only the newest plot can still change under an unchanged plot id (incremental drawing on the active page), so only its thumbnail now carries the upid cache-buster; older plots are immutable and keep stable URLs that the browser caches. Thumbnails additionally load lazily so off-screen history is not fetched on page load.

Measured with ~50 plots in history: drawing one plot previously issued 50+ /plot requests (~16 MB re-rendered and re-downloaded); it now issues a constant 3 regardless of history size.

Closes #260


As mentioned in #260, this reduces the rendering time back to O(1) regardless of the number of plots in the history.

Test First UI stall 50th UI stall Worst UI stall observed
Safari, base 82ms 169ms 192ms
Firefox, base 87ms 74ms 87ms
Safari, ggplot2 256ms 297ms 445ms
Firefox, ggplot2 98ms 105ms 132ms

Each sidebar thumbnail URL embedded the device-global update counter
(upid) as a cache-busting query parameter. Since upid increments on
every device update, drawing one new plot changed the URLs of all N
thumbnails at once, causing the browser to re-download and the server
to re-render the entire plot history on every plot (O(N^2) over a
session). This made the client progressively slower as plots
accumulated, regardless of plot complexity.

Only the newest plot can still change under an unchanged plot id
(incremental drawing on the active page), so only its thumbnail now
carries the upid cache-buster; older plots are immutable and keep
stable URLs that the browser caches. Thumbnails additionally load
lazily so off-screen history is not fetched on page load.

Measured with ~50 plots in history: drawing one plot previously issued
50+ /plot requests (~16 MB re-rendered and re-downloaded); it now
issues a constant 3 regardless of history size.

Closes nx10#260

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

incremental lag as number of plots increases

1 participant