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

Cleanup _parent, _dom and __hooks after unmount #3709

Merged
merged 10 commits into from Sep 11, 2022
Merged

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Sep 2, 2022

Possible fix for #3668

The only thing we can’t cleanup during unmount are the _children due to this https://github.com/preactjs/preact/blob/master/compat/src/suspense.js#L148 and the _dom._listeners due to

FAILED TESTS:
    ✖ should allow component to re-suspend using normal suspension mechanics after initial suspended hydration resumes
      Chrome Headless 105.0.5195.52 (Mac OS 10.15.7)

    Error: Uncaught TypeError: Cannot read properties of undefined (reading 'clickfalse') (compat/test/browser/suspense-hydration.test.js:426)
        at  (compat/test/browser/suspense-hydration.test.js:654:23)

@coveralls
Copy link

coveralls commented Sep 2, 2022

Coverage Status

Coverage remained the same at 99.527% when pulling b636502 on cleanup-unmount into a5258a9 on master.

@github-actions
Copy link

github-actions bot commented Sep 2, 2022

Size Change: +50 B (0%)

Total Size: 52.8 kB

Filename Size Change
dist/preact.js 4.02 kB +6 B (0%)
dist/preact.min.js 4.04 kB +7 B (0%)
dist/preact.min.module.js 4.04 kB +6 B (0%)
dist/preact.min.umd.js 4.07 kB +6 B (0%)
dist/preact.module.js 4.03 kB +7 B (0%)
dist/preact.umd.js 4.09 kB +8 B (0%)
hooks/dist/hooks.js 1.55 kB +3 B (0%)
hooks/dist/hooks.module.js 1.58 kB +4 B (0%)
hooks/dist/hooks.umd.js 1.63 kB +3 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.78 kB 0 B
compat/dist/compat.module.js 3.72 kB 0 B
compat/dist/compat.umd.js 3.85 kB 0 B
debug/dist/debug.js 3.01 kB 0 B
debug/dist/debug.module.js 3.01 kB 0 B
debug/dist/debug.umd.js 3.09 kB 0 B
devtools/dist/devtools.js 231 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 315 B 0 B
jsx-runtime/dist/jsxRuntime.js 358 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 324 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 439 B 0 B
test-utils/dist/testUtils.js 442 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 526 B 0 B

compressed-size-action

@preactjs preactjs deleted a comment from github-actions bot Sep 3, 2022
@github-actions
Copy link

github-actions bot commented Sep 3, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -10% - +3% (-12.14ms - +3.85ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -2% - +4% (-0.86ms - +1.82ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -1% - +0% (-12.52ms - +3.61ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -3% - +2% (-0.87ms - +0.61ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -1% - +2% (-1.35ms - +2.36ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -5% - +0% (-1.52ms - +0.14ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -1% - +4% (-0.04ms - +0.11ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -2% - +1% (-1.73ms - +0.68ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -2% - +9% (-0.08ms - +0.34ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -1% - +0% (-0.02ms - +0.01ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -5% - +1% (-0.32ms - +0.06ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • todo: slower ❌ 5% - 9% (0.07ms - 0.11ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master105.13ms - 115.39ms-unsure 🔍
-8% - +4%
-8.69ms - +4.43ms
unsure 🔍
-6% - +9%
-6.94ms - +9.43ms
preact-local108.30ms - 116.48msunsure 🔍
-4% - +8%
-4.43ms - +8.69ms
-unsure 🔍
-4% - +10%
-4.20ms - +10.95ms
preact-hooks102.64ms - 115.39msunsure 🔍
-9% - +6%
-9.43ms - +6.94ms
unsure 🔍
-10% - +4%
-10.95ms - +4.20ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.73ms - 4.03ms-unsure 🔍
-3% - +7%
-0.13ms - +0.25ms
faster ✔
6% - 17%
0.26ms - 0.74ms
preact-local3.71ms - 3.94msunsure 🔍
-6% - +3%
-0.25ms - +0.13ms
-faster ✔
8% - 17%
0.34ms - 0.78ms
preact-hooks4.19ms - 4.57msslower ❌
6% - 19%
0.26ms - 0.74ms
slower ❌
9% - 21%
0.34ms - 0.78ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.95ms - 1.01ms-unsure 🔍
-2% - +5%
-0.02ms - +0.04ms
unsure 🔍
-4% - +3%
-0.04ms - +0.03ms
preact-local0.95ms - 0.99msunsure 🔍
-5% - +2%
-0.04ms - +0.02ms
-unsure 🔍
-4% - +1%
-0.04ms - +0.01ms
preact-hooks0.96ms - 1.01msunsure 🔍
-3% - +4%
-0.03ms - +0.04ms
unsure 🔍
-1% - +5%
-0.01ms - +0.04ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.55ms - 0.65ms-unsure 🔍
-32% - +1%
-0.24ms - +0.03ms
unsure 🔍
-24% - +20%
-0.15ms - +0.13ms
preact-local0.58ms - 0.83msunsure 🔍
-5% - +41%
-0.03ms - +0.24ms
-unsure 🔍
-16% - +48%
-0.08ms - +0.27ms
preact-hooks0.48ms - 0.74msunsure 🔍
-21% - +25%
-0.13ms - +0.15ms
unsure 🔍
-37% - +10%
-0.27ms - +0.08ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.59ms - 0.75ms-unsure 🔍
-15% - +21%
-0.10ms - +0.14ms
unsure 🔍
-6% - +34%
-0.02ms - +0.19ms
preact-local0.57ms - 0.74msunsure 🔍
-20% - +15%
-0.14ms - +0.10ms
-unsure 🔍
-10% - +32%
-0.05ms - +0.18ms
preact-hooks0.51ms - 0.66msunsure 🔍
-28% - +3%
-0.19ms - +0.02ms
unsure 🔍
-27% - +7%
-0.18ms - +0.05ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.33ms - 0.39ms-unsure 🔍
-6% - +15%
-0.02ms - +0.05ms
faster ✔
5% - 25%
0.02ms - 0.11ms
preact-local0.32ms - 0.37msunsure 🔍
-14% - +5%
-0.05ms - +0.02ms
-faster ✔
9% - 28%
0.03ms - 0.13ms
preact-hooks0.38ms - 0.47msslower ❌
3% - 32%
0.02ms - 0.11ms
slower ❌
9% - 38%
0.03ms - 0.13ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.87ms - 3.68ms-unsure 🔍
-44% - +58%
-1.09ms - +1.45ms
slower ❌
101% - 545%
1.17ms - 3.07ms
preact-local1.70ms - 3.48msunsure 🔍
-51% - +38%
-1.45ms - +1.09ms
-slower ❌
84% - 507%
1.01ms - 2.87ms
preact-hooks0.39ms - 0.93msfaster ✔
64% - 89%
1.17ms - 3.07ms
faster ✔
61% - 88%
1.01ms - 2.87ms
-

run-final

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.22ms - 0.29ms-unsure 🔍
-24% - +10%
-0.07ms - +0.03ms
unsure 🔍
-24% - +9%
-0.07ms - +0.03ms
preact-local0.24ms - 0.31msunsure 🔍
-12% - +27%
-0.03ms - +0.07ms
-unsure 🔍
-18% - +17%
-0.05ms - +0.05ms
preact-hooks0.24ms - 0.31msunsure 🔍
-11% - +28%
-0.03ms - +0.07ms
unsure 🔍
-17% - +18%
-0.05ms - +0.05ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master43.82ms - 46.18ms-unsure 🔍
-3% - +4%
-1.41ms - +1.81ms
unsure 🔍
-2% - +5%
-0.84ms - +2.16ms
preact-local43.71ms - 45.90msunsure 🔍
-4% - +3%
-1.81ms - +1.41ms
-unsure 🔍
-2% - +4%
-0.97ms - +1.90ms
preact-hooks43.41ms - 45.26msunsure 🔍
-5% - +2%
-2.16ms - +0.84ms
unsure 🔍
-4% - +2%
-1.90ms - +0.97ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.74ms - 3.77ms-unsure 🔍
-0% - +1%
-0.01ms - +0.02ms
faster ✔
8% - 9%
0.31ms - 0.35ms
preact-local3.74ms - 3.76msunsure 🔍
-1% - +0%
-0.02ms - +0.01ms
-faster ✔
8% - 9%
0.32ms - 0.36ms
preact-hooks4.07ms - 4.10msslower ❌
8% - 9%
0.31ms - 0.35ms
slower ❌
8% - 10%
0.32ms - 0.36ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1662.92ms - 1683.59ms-unsure 🔍
-1% - +1%
-15.56ms - +19.33ms
faster ✔
2% - 4%
37.84ms - 66.71ms
preact-local1657.32ms - 1685.42msunsure 🔍
-1% - +1%
-19.33ms - +15.56ms
-faster ✔
2% - 4%
36.88ms - 71.45ms
preact-hooks1715.46ms - 1735.60msslower ❌
2% - 4%
37.84ms - 66.71ms
slower ❌
2% - 4%
36.88ms - 71.45ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master25.52ms - 25.52ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
9% - 9%
2.55ms - 2.55ms
preact-local25.52ms - 25.52msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
9% - 9%
2.55ms - 2.55ms
preact-hooks28.07ms - 28.07msslower ❌
10% - 10%
2.55ms - 2.55ms
slower ❌
10% - 10%
2.55ms - 2.55ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master23.58ms - 24.21ms-unsure 🔍
-3% - +1%
-0.63ms - +0.21ms
unsure 🔍
-0% - +3%
-0.04ms - +0.77ms
preact-local23.82ms - 24.39msunsure 🔍
-1% - +3%
-0.21ms - +0.63ms
-slower ❌
1% - 4%
0.19ms - 0.97ms
preact-hooks23.27ms - 23.79msunsure 🔍
-3% - +0%
-0.77ms - +0.04ms
faster ✔
1% - 4%
0.19ms - 0.97ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.75ms - 1.75ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
12% - 14%
0.25ms - 0.28ms
preact-local1.75ms - 1.75msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
12% - 14%
0.25ms - 0.28ms
preact-hooks2.00ms - 2.03msslower ❌
14% - 16%
0.25ms - 0.28ms
slower ❌
14% - 16%
0.25ms - 0.28ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master153.05ms - 157.42ms-unsure 🔍
-1% - +2%
-1.75ms - +3.78ms
unsure 🔍
-4% - +0%
-5.71ms - +0.74ms
preact-local152.52ms - 155.91msunsure 🔍
-2% - +1%
-3.78ms - +1.75ms
-faster ✔
0% - 4%
0.58ms - 6.41ms
preact-hooks155.34ms - 160.09msunsure 🔍
-0% - +4%
-0.74ms - +5.71ms
slower ❌
0% - 4%
0.58ms - 6.41ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master6.41ms - 6.78ms-slower ❌
1% - 7%
0.08ms - 0.46ms
faster ✔
8% - 16%
0.57ms - 1.24ms
preact-local6.31ms - 6.33msfaster ✔
1% - 7%
0.08ms - 0.46ms
-faster ✔
13% - 19%
0.90ms - 1.45ms
preact-hooks7.22ms - 7.77msslower ❌
8% - 19%
0.57ms - 1.24ms
slower ❌
14% - 23%
0.90ms - 1.45ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master31.40ms - 33.00ms-unsure 🔍
-2% - +5%
-0.65ms - +1.57ms
faster ✔
6% - 12%
2.09ms - 4.37ms
preact-local30.97ms - 32.51msunsure 🔍
-5% - +2%
-1.57ms - +0.65ms
-faster ✔
7% - 13%
2.57ms - 4.81ms
preact-hooks34.62ms - 36.24msslower ❌
6% - 14%
2.09ms - 4.37ms
slower ❌
8% - 15%
2.57ms - 4.81ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.81ms - 4.82ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
8% - 9%
0.45ms - 0.45ms
preact-local4.81ms - 4.82msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
8% - 8%
0.45ms - 0.45ms
preact-hooks5.26ms - 5.26msslower ❌
9% - 9%
0.45ms - 0.45ms
slower ❌
9% - 9%
0.45ms - 0.45ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.92ms - 4.17ms-unsure 🔍
-1% - +7%
-0.04ms - +0.27ms
faster ✔
3% - 10%
0.11ms - 0.41ms
preact-local3.83ms - 4.03msunsure 🔍
-7% - +1%
-0.27ms - +0.04ms
-faster ✔
6% - 12%
0.25ms - 0.51ms
preact-hooks4.23ms - 4.39msslower ❌
3% - 10%
0.11ms - 0.41ms
slower ❌
6% - 13%
0.25ms - 0.51ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.98ms - 0.98ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
faster ✔
1% - 1%
0.01ms - 0.01ms
preact-local0.98ms - 0.98msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-faster ✔
1% - 1%
0.01ms - 0.01ms
preact-hooks1.00ms - 1.00msslower ❌
2% - 2%
0.01ms - 0.01ms
slower ❌
2% - 2%
0.01ms - 0.01ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master69.54ms - 71.28ms-faster ✔
1% - 5%
0.94ms - 3.85ms
faster ✔
4% - 8%
2.59ms - 5.79ms
preact-local71.63ms - 73.97msslower ❌
1% - 5%
0.94ms - 3.85ms
-faster ✔
0% - 5%
0.01ms - 3.58ms
preact-hooks73.25ms - 75.95msslower ❌
4% - 8%
2.59ms - 5.79ms
unsure 🔍
-0% - +5%
+0.01ms - +3.58ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.28ms - 1.32ms-faster ✔
4% - 7%
0.06ms - 0.10ms
unsure 🔍
-2% - +2%
-0.02ms - +0.02ms
preact-local1.37ms - 1.39msslower ❌
5% - 8%
0.06ms - 0.10ms
-slower ❌
5% - 7%
0.06ms - 0.10ms
preact-hooks1.29ms - 1.32msunsure 🔍
-2% - +2%
-0.02ms - +0.02ms
faster ✔
4% - 7%
0.06ms - 0.10ms
-

tachometer-reporter-action v2 for Benchmarks

@JoviDeCroock JoviDeCroock marked this pull request as ready for review September 4, 2022 07:49
@mafintosh
Copy link

fyi this fixed a massive memleak we had in a real world application, awesome stuff!

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Let's merge this 💯

@JoviDeCroock JoviDeCroock merged commit 7469051 into master Sep 11, 2022
@JoviDeCroock JoviDeCroock deleted the cleanup-unmount branch September 11, 2022 08:36
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.

None yet

4 participants