Skip to content

Speed fixes from the integration branch: section key, controls test, parked cards - #503

Open
christophsax wants to merge 4 commits into
mainfrom
perf/speed-on-main
Open

christophsax wants to merge 4 commits into
mainfrom
perf/speed-on-main

Conversation

@christophsax

@christophsax christophsax commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

@nbenn, these come from the integration branch (integration/devmaster-latest), where we have been trying out speed fixes on a demo board with about 90 blocks and ten views. The integration board feels noticeably snappier, and these are the dock parts of that, rebased onto main. They do not depend on the design-system PRs. Take what is useful; the three commits are independent, so dropping or splitting any of them is fine.

  • Read the card's section key under isolate() (R/plugin-block.R). reported_sections() tested "collapse_blk_sections" %in% names(input). names() on a module's input depends on the session's whole input name set, so every new input anywhere on the board invalidated every block's visible, and freeze_hidden_inputs() re-read all of them per card mount: 21 to 43 runs over ~90 blocks on a first view visit, 1.2 to 6 s. After: 9 to 16 runs, 0.3 to 0.9 s. The unconditional read of input$collapse_blk_sections above it already takes the dependency that fires when the key first appears.
  • Test a block for controls without resolving their dependencies (R/block-ui.R). has_expr_ui() only needs to know whether the expression UI renders any markup. doRenderTags() gives the same markup as renderTags() without resolving the html dependencies, which cost more than the markup once every control carried its own set: resolveDependencies 1.4 to 0.8 s over a short session.
  • Stop styling and laying out parked cards (blockr-dock.css). The offcanvas pools that hold cards and extensions of views not on screen were only visibility: hidden, so the browser kept styling and laying out every parked card: half the document once all views have been visited. content-visibility: hidden on the closed pool skips that work. Unlike display: none, sizes stay readable, so Shiny does not suspend the outputs and charts get no resize to zero. One DOM insertion 106 to 11 ms, style per return view switch 2.1 to 0.8 s.

Not included:

Together with the blockr.ui change and two small ones in other packages, a scripted session on the demo board went from 37 to 30 s; the first visits to the larger views from 6.9 to 4.9 s and from 8.3 to 6.2 s. All numbers are from a shared container under load, so compare the arms of one measurement rather than across them.

The dock tests pass (8300) against blockr.core, blockr.ui and dockViewR main.

reported_sections() tested "collapse_blk_sections" %in% names(input).
names() on a module's input depends on the session's whole name set, so
every new input anywhere on the board invalidated every block's
`visible`, and freeze_hidden_inputs(), which reads all of them, redid
the whole board per card mount: 21 to 43 runs over ~90 blocks on a
first view visit.

The read of input$collapse_blk_sections above already fires when the
key first appears, even as NULL, so the key test needs no dependency of
its own.
has_expr_ui() runs twice per block and only needs to know whether the
expression UI renders any markup. renderTags() also resolves the UI's html
dependencies, which grew with the design-system controls (resolveDependencies
0.34 s -> 1.43 s over a short session). doRenderTags() gives the same
markup without that step.
The offcanvas pools that hold the cards and extensions of views not on
screen were only visibility: hidden, so the browser kept styling and laying
out every parked card. On a 90-block board, after visiting all ten views, that
is 10,304 of 19,996 elements. content-visibility: hidden on the closed pool
skips the work; sizes stay readable, so Shiny keeps the outputs unsuspended
and charts get no resize to zero (display: none would do both).

Same-page A/B on that board, loaded container, 8 switches per arm:
one DOM insertion 106 -> 11 ms, style per return switch 2.1 -> 0.8 s,
main-thread task 2.7 -> 1.8 s.
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
R/block-ui.R 98.44% <100.00%> (ø)
R/plugin-block.R 99.57% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbenn nbenn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks!

@nbenn
nbenn added this pull request to the merge queue Oct 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 1, 2026

This branch has not been deployed

No deployments
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.

2 participants