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

feat: debug throw on too many rerenders #4349

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

rschristian
Copy link
Member

Rebase of @andrewiggins' work in #3965, and moves to /debug as mentioned.

Copy link

github-actions bot commented Apr 26, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +2% (-5.71ms - +16.68ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +1% (-0.16ms - +0.12ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -4% - +1% (-3.22ms - +1.00ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +2% (-0.04ms - +0.34ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +2% (-1.25ms - +1.35ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +3% (-0.05ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -2% - +2% (-0.54ms - +0.59ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -1% - +4% (-0.22ms - +1.11ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +3% (-0.28ms - +0.47ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.02ms - +0.03ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +6% (-0.01ms - +0.07ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local882.25ms - 901.44ms-unsure 🔍
-1% - +2%
-5.71ms - +16.68ms
preact-main880.59ms - 892.13msunsure 🔍
-2% - +1%
-16.68ms - +5.71ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local26.75ms - 26.75ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main26.75ms - 26.75msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.76ms - 16.94ms-unsure 🔍
-1% - +1%
-0.16ms - +0.12ms
preact-main16.76ms - 16.97msunsure 🔍
-1% - +1%
-0.12ms - +0.16ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.75ms - 1.76ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main1.75ms - 1.75msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local73.35ms - 74.93ms-unsure 🔍
-4% - +1%
-3.22ms - +1.00ms
preact-main73.29ms - 77.20msunsure 🔍
-1% - +4%
-1.00ms - +3.22ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local14.18ms - 14.73ms-unsure 🔍
-2% - +3%
-0.28ms - +0.47ms
preact-main14.11ms - 14.61msunsure 🔍
-3% - +2%
-0.47ms - +0.28ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.48ms - 16.82ms-unsure 🔍
-0% - +2%
-0.04ms - +0.34ms
preact-main16.41ms - 16.59msunsure 🔍
-2% - +0%
-0.34ms - +0.04ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.86ms - 4.86ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main4.86ms - 4.86msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local73.13ms - 74.89ms-unsure 🔍
-2% - +2%
-1.25ms - +1.35ms
preact-main73.00ms - 74.92msunsure 🔍
-2% - +2%
-1.35ms - +1.25ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.68ms - 3.72ms-unsure 🔍
-1% - +1%
-0.02ms - +0.03ms
preact-main3.68ms - 3.72msunsure 🔍
-1% - +1%
-0.03ms - +0.02ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local28.66ms - 29.56ms-unsure 🔍
-2% - +2%
-0.65ms - +0.60ms
preact-main28.70ms - 29.57msunsure 🔍
-2% - +2%
-0.60ms - +0.65ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local36.44ms - 38.23ms-unsure 🔍
-3% - +4%
-1.05ms - +1.51ms
preact-main36.19ms - 38.02msunsure 🔍
-4% - +3%
-1.51ms - +1.05ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local26.45ms - 27.33ms-unsure 🔍
-2% - +2%
-0.56ms - +0.65ms
preact-main26.43ms - 27.26msunsure 🔍
-2% - +2%
-0.65ms - +0.56ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local24.97ms - 25.84ms-unsure 🔍
-1% - +4%
-0.31ms - +0.92ms
preact-main24.66ms - 25.53msunsure 🔍
-4% - +1%
-0.92ms - +0.31ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local28.04ms - 29.86ms-unsure 🔍
-7% - +2%
-2.04ms - +0.72ms
preact-main28.56ms - 30.65msunsure 🔍
-3% - +7%
-0.72ms - +2.04ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local23.98ms - 25.09ms-unsure 🔍
-3% - +4%
-0.65ms - +0.95ms
preact-main23.80ms - 24.95msunsure 🔍
-4% - +3%
-0.95ms - +0.65ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.76ms - 1.83ms-unsure 🔍
-3% - +3%
-0.05ms - +0.05ms
preact-main1.76ms - 1.83msunsure 🔍
-3% - +3%
-0.05ms - +0.05ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.12ms - 1.18ms-unsure 🔍
-1% - +6%
-0.01ms - +0.07ms
preact-main1.10ms - 1.15msunsure 🔍
-6% - +1%
-0.07ms - +0.01ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local27.41ms - 28.37ms-unsure 🔍
-2% - +2%
-0.54ms - +0.59ms
preact-main27.56ms - 28.17msunsure 🔍
-2% - +2%
-0.59ms - +0.54ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.25ms - 1.25ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.25ms - 1.25msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.76ms - 31.92ms-unsure 🔍
-1% - +4%
-0.22ms - +1.11ms
preact-main30.57ms - 31.22msunsure 🔍
-4% - +1%
-1.11ms - +0.22ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.69ms - 3.69ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main3.69ms - 3.69msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link

Size Change: +327 B (0%)

Total Size: 61 kB

Filename Size Change
debug/dist/debug.js 3.63 kB +114 B (3%)
debug/dist/debug.module.js 3.63 kB +106 B (2%)
debug/dist/debug.umd.js 3.71 kB +107 B (2%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 4.09 kB 0 B
compat/dist/compat.module.js 4.01 kB 0 B
compat/dist/compat.umd.js 4.14 kB 0 B
devtools/dist/devtools.js 230 B 0 B
devtools/dist/devtools.module.js 239 B 0 B
devtools/dist/devtools.umd.js 314 B 0 B
dist/preact.js 4.61 kB 0 B
dist/preact.min.js 4.64 kB 0 B
dist/preact.min.module.js 4.64 kB 0 B
dist/preact.min.umd.js 4.67 kB 0 B
dist/preact.module.js 4.62 kB 0 B
dist/preact.umd.js 4.68 kB 0 B
hooks/dist/hooks.js 1.55 kB 0 B
hooks/dist/hooks.module.js 1.59 kB 0 B
hooks/dist/hooks.umd.js 1.63 kB 0 B
jsx-runtime/dist/jsxRuntime.js 976 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 949 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 1.06 kB 0 B
test-utils/dist/testUtils.js 453 B 0 B
test-utils/dist/testUtils.module.js 454 B 0 B
test-utils/dist/testUtils.umd.js 536 B 0 B

compressed-size-action

if (renderCount >= 25) {
throw new Error(
`Too many re-renders. This is limited to prevent an infinite loop ` +
`which may lock up your browser. The component causing this is: ${getDisplayName(
Copy link
Member Author

Choose a reason for hiding this comment

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

I added the ...which may lock up your browser. bit just to emphasize this isn't something one could safely ignore, especially as we'll only address it in dev (for most users, anyhow. I doubt many are using /debug in prod).

@coveralls
Copy link

coveralls commented Apr 26, 2024

Coverage Status

coverage: 99.609% (+0.004%) from 99.605%
when pulling 1193ed9 on feat/debug-throw-on-too-many-rerenders
into aa95aa9 on main.

@tcoz
Copy link

tcoz commented May 31, 2024

Note that this PR appears to throw the rerender error somewhat arbitrarily, causing the app to crash for high render components like the MUI-X Datagrid. Setting preact debug to false in vite.config is a workaround for now.

It's possible that the MUI-X DataGrid could use some cleanup to prune renders, but the current performance is acceptable (pretty good actually), the top level component === currentComponent render ++ < 25 may not be robust enough.

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.

5 participants