Skip to content

perf: switch back to a tab up to 35% faster - #1301

Closed
lukecotter wants to merge 1 commit into
certinia:mainfrom
lukecotter:feat-tabs-keep-layout
Closed

lukecotter wants to merge 1 commit into
certinia:mainfrom
lukecotter:feat-tabs-keep-layout

Conversation

@lukecotter

Copy link
Copy Markdown
Collaborator

📝 PR Overview

A hidden tab used display: none. The browser threw away the tab's layout and laid it out again on each switch back. On a 100 MB log at 4× CPU throttle, a switch back to Analysis or Database took 57–68 ms.

A hidden tab now uses content-visibility: hidden. It keeps its layout and does no rendering work while it is hidden. A switch back is up to 35% faster, for about 6 MB more renderer memory.

Switch back, 4× CPU throttle 19.7 MB sample log 100 MB log
Analysis 66 → 45 ms 57 → 44 ms
Database 68 → 44 ms 68 → 45 ms
Timeline 57 → 46 ms 55 → 50 ms
Call Tree 43 → 46 ms (no change) 40 → 41 ms (no change)

Each value is a median of 4 runs (19.7 MB log) or 3 runs (100 MB log). Each run used a new headless Chromium, with main and this branch in turn.

🛠️ Changes made

  • vscode-tab-panel[hidden] keeps display: block with content-visibility: hidden, so the tab keeps its layout.
  • flex: none stops a hidden panel from taking a share of the tab area. Without it, each hidden panel took 131.5 px.
  • visibility: hidden takes a hidden panel out of the tab order and the accessibility tree. Each panel has tabindex="0".
  • A web e2e test checks that a hidden tab has 0 height and cannot take focus. It fails when either of the two lines above is removed.

🧩 Type of change (check all applicable)

  • 🐛 Bug fix - something not working as expected
  • ✨ New feature – adds new functionality
  • ♻️ Refactor - internal changes with no user impact
  • ⚡ Performance Improvement
  • 📝 Documentation - README or documentation site changes
  • 🔧 Chore - dev tooling, CI, config
  • 💥 Breaking change

📷 Screenshots / gifs / video [optional]

N/A. There is no visual change.

🔗 Related Issues

N/A

✅ Tests added?

  • 👍 yes
  • 🙅 no, not needed
  • 🙋 no, I need help

pnpm lint passes. pnpm exec jest --selectProjects log-viewer: 208 suites, 2,936 tests pass. pnpm exec playwright test --config=lana/test/playwright/playwright.config.web.ts: 3 tests pass.

Checked by hand in the docs live demo, in the light and dark themes:

  • Hidden tabs still build only when you first open them.
  • A grid keeps its scroll position.
  • A window resize while a tab is hidden is applied when the tab shows.

📚 Docs updated?

  • 🔖 README.md
  • 🔖 CHANGELOG.md
  • 📖 help site
  • 🧪 Marked any pre-release-only features (README 🧪 badge — see RELEASING.md)
  • 🙅 not needed

Anything else we need to know? [optional]

  • Memory: the Blink heap grows by 5.8 MB on the 19.7 MB log and by 5.9 MB on the 100 MB log, so the cost does not grow with log size. After a visit to every tab, the renderer holds 5,630 layout objects (1,472 on main). Total renderer memory on the 100 MB log goes from 413 MB to 419 MB (+1.4%).
  • If code reads a size inside a hidden tab, the browser lays the tab out again at 0 height, and the next switch back is no faster. That is the same as on main, not worse.
  • The e2e tsconfig has no DOM types, so the browser callback in the new test has no types. Adding "DOM" to lana/test/playwright/tsconfig.json would fix that.

A hidden tab used display: none, so the browser threw away its layout
and built it again on every switch back. content-visibility: hidden
keeps the layout and skips its rendering work while the tab is hidden.

At 4x CPU throttle on a 100 MB log, a switch back to Analysis takes
44 ms (was 57), Database 45 ms (was 68) and Timeline 50 ms (was 55).
The renderer holds about 6 MB more, the same on a 19.7 MB log.

A hidden tab still takes no space and no focus. A new web e2e test
checks both.
@lukecotter

Copy link
Copy Markdown
Collaborator Author

Closing. A hidden tab now keeps its size, and three parts of the viewer use size 0 to find a hidden tab:

  • Timeline: after a log-level change on another tab, the chart fails with INVALID_CONTAINER and does not come back.
  • Find: hidden tabs answer a search, so the count and Next use matches you cannot see.
  • Grid: a hidden grid paints when its data changes.

The gain is 13–23 ms per tab switch at 4x CPU throttle, for about 6 MB more memory. That does not justify changes in those three modules.

@lukecotter lukecotter closed this Nov 28, 2026
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