Skip to content

perf: draw each frame of a fast table scroll 15% faster - #1302

Open
lukecotter wants to merge 4 commits into
certinia:mainfrom
lukecotter:feat-grid-bar-cells
Open

lukecotter wants to merge 4 commits into
certinia:mainfrom
lukecotter:feat-grid-bar-cells

Conversation

@lukecotter

Copy link
Copy Markdown
Collaborator

📝 PR Overview

A bar cell in the tables was five elements: a wrapper, the bar, a text wrapper, the value and the percent. A fast scroll (scrollbar drag, Page Down, find) draws every row again, so the browser restyled, laid out and painted all of them on each frame. On 40 full-window jumps in the Analysis grid at 4× CPU throttle, the median frame took 35.3 ms, against a 16.7 ms budget.

The bar is now the wrapper's background, sized by an inline background-size. A bar cell is three elements, and the median frame takes 30.1 ms (−15%). There is no visible change.

Per frame, Analysis grid, 4× CPU throttle main This branch
Frame 35.3 ms 30.1 ms
Style 10.2 ms 8.7 ms
Layout 7.5 ms 6.3 ms
Paint 12.1 ms 11.0 ms
Elements restyled 1,620 1,359
Elements per row (average) 36.3 27.1

Each value is a median of 5 runs. Each run used a new headless Chromium on the 19.7 MB sample log, with main and this branch in turn. Normal wheel scrolling was already inside the frame budget.

🛠️ Changes made

  • bar() renders the wrapper, the value and the percent. The bar width is the inline background-size, so a change restyles only the wrapper.
  • A new --lana-grid-bar-fill token holds the bar colour: the same charts.orange at 30%, as a color-mix. The old bar used opacity: 0.3 on its own element.
  • A custom property for the width was slower (1,620 → 2,712 elements restyled per frame): it inherits, so each change restyled the value and the percent too.
  • A new cells.test.ts checks the value and share text, the hairline for a share that rounds to 0, no bar for a zero value or total, and that find marks only the value.

🧩 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. In the docs live demo, each value, percent and bar box has the same position as on main (1 px of rounding at most). Screenshots match in the dark theme and in the light theme with a selected row.

🔗 Related Issues

N/A

✅ Tests added?

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

pnpm lint passes. pnpm exec jest --selectProjects log-viewer: 209 suites, 2,940 tests pass. pnpm exec playwright test --config=lana/test/playwright/playwright.config.web.ts: 2 tests pass. The new tests fail when the hairline minimum is removed, and when the find marker moves to the wrapper.

📚 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]

  • pnpm bench:grid does not cover this change: its contender renders plain text cells, not bar cells.
  • perf: switch back to a tab up to 35% faster #1301 also adds a ## [Unreleased] section to CHANGELOG.md. The PR that merges second needs a rebase that keeps both lines.

A bar cell was five elements: a wrapper, the bar, a text wrapper, the
value and the percent. A fast scroll draws every row again, so the
browser restyled, laid out and painted all of them on each frame.

The bar is now the wrapper's background, sized by an inline
background-size. A bar cell is the wrapper, the value and the percent,
and an Analysis row drops from 36 to 27 elements on average.

On 40 full-window jumps in the Analysis grid at 4x CPU throttle, the
median frame takes 30.1 ms (was 35.3): style 8.7 ms (was 10.2), layout
6.3 ms (was 7.5), paint 11.0 ms (was 12.1).

A custom property for the width was slower: it inherits, so each change
restyled the value and the percent too.
`share > 0` gives the same result as `value > 0 && total > 0`. The
class names now match the markup, because the progress-bar element is
gone. The tests cover a value above its total and a negative value, and
count the elements per cell. They no longer check the find text,
because the Call Tree column tests do that.
The share was rounded to a whole number and then shown with two
decimals, so it always ended in .00: 12.5% showed as 13.00%. Other
views show the same share as 12.50%.
Forced colours drop every background image, so the bars disappeared.
The bar now keeps its image and takes the system highlight colour, and
its text takes the system text colour.

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.

1 participant