Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unecessary dom re-calc in grid render #1632

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

dsmmcken
Copy link
Contributor

@dsmmcken dsmmcken commented Nov 9, 2023

While looking at some perf snapshots I noticed calls to updateCanvasScale on every grid render had a ~0.25-0.5ms perf cost (including table ticks). Mostly due to touching the dom with the set width/set height calls triggering a recalculate style call and the getScale call. While insignificant, it is also unnecessary unless size actually changes. Making it conditional improves perf on most re-renders. I used parseFloat in case grid somehow ends up with fractional pixel if set outside of our control (which shouldn't happen, but you never know with plugins).

Before:
image

After:
image
updateCanvasScale is now gone from the perf profile entirely on a normal grid render.

Tested re-sizeing panels, and window with table both shown and hidden still resizes grid correctly.

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (61d1a53) 46.71% compared to head (e4244e3) 46.70%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1632      +/-   ##
==========================================
- Coverage   46.71%   46.70%   -0.02%     
==========================================
  Files         583      589       +6     
  Lines       36308    36359      +51     
  Branches     9094     9103       +9     
==========================================
+ Hits        16961    16980      +19     
- Misses      19295    19327      +32     
  Partials       52       52              
Flag Coverage Δ
unit 46.70% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/grid/src/Grid.tsx 64.60% <100.00%> (+0.09%) ⬆️

... and 26 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dsmmcken dsmmcken requested a review from mofojed November 9, 2023 17:22
@dsmmcken dsmmcken merged commit ce7cc3e into main Nov 9, 2023
7 checks passed
@dsmmcken dsmmcken deleted the dmckenzie_updateScale branch November 9, 2023 17:31
@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants