Skip to content

Run plot comms on the R thread#1100

Open
lionel- wants to merge 6 commits intotask/sync-ui-commfrom
task/sync-plot-comm
Open

Run plot comms on the R thread#1100
lionel- wants to merge 6 commits intotask/sync-ui-commfrom
task/sync-plot-comm

Conversation

@lionel-
Copy link
Contributor

@lionel- lionel- commented Mar 10, 2026

Progress towards #689
Branched from #1099

I did not foresee all the simplifications falling out of this one!

  • Plots no longer live in their own threads, they live on the R thread. That frees up memory since each background thread takes about 2mb of stack space (depending on platform), so 20 open plots would take 40mb of memory.

  • DeviceContext moves from a standalone thread_local! into a regular field of Console. All access goes through Console::get().device_context(). The CommHandlerContext provides access to Console via ctx.console(), so plot handlers reach the device context through a controlled context chain.

  • The old idle-time polling loop (process_rpc_requests with crossbeam::Select) is removed. Plot RPCs are now dispatched synchronously through the shell handler on the R thread. This improves plot latency when pre-renderings require adjustments because we no longer timeout-poll for plot updates (related to Performance for plotting positron#5184).

  • The GraphicsDeviceNotification async channel is removed. Since the UI comm now runs on the R thread (from Run UI comm on the R thread #1099), prerender settings are updated synchronously via Console::get().device_context().set_prerender_settings(). This removes quite a bit of plumbing.

  • Fixes a dev.hold() regression I introduced with pre-renderings (Send pre-renderings of new plots to the frontend #775). We were previously sending pre-renderings unconditionally, now they are held until dev.flush(). This is tested by new integration tests.

@lionel- lionel- force-pushed the task/sync-plot-comm branch from 137f0d9 to 34baa70 Compare March 10, 2026 18:15
@lionel- lionel- force-pushed the task/sync-plot-comm branch from 34baa70 to 845b4a7 Compare March 11, 2026 07:08
@lionel- lionel- requested a review from DavisVaughan March 11, 2026 13:47
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