Skip to content

Conversation

@JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jul 26, 2025

We can't safely remove _listeners as that would mean we are risking suspense-hydration breaking 😅 basically during suspense we store the vnodes which means that old and new vnode will always be equal, if we want to remove _listeners as well we'll have to probably stop storing our virtual DOM tree when it's a mount and store the previous variant when it's an update. This would however mean that our mutative approach is a bad thought.

EDIT: I solved the _listeners issue

Resolves #3668

@github-actions
Copy link

github-actions bot commented Jul 26, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +0% (-6.00ms - +2.86ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.04ms - +0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.51ms - +1.01ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -4% - +2% (-0.59ms - +0.33ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +2% (-0.57ms - +1.25ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -6% - +8% (-0.13ms - +0.17ms)
    preact-local vs preact-main
  • todo: faster ✔ 4% - 5% (1.41ms - 1.65ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -2% - +4% (-0.57ms - +1.34ms)
    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 🔍 -3% - +10% (-0.15ms - +0.57ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.02ms - +0.02ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -4% - +1% (-0.04ms - +0.01ms)
    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.01ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local972.38ms - 976.90ms-unsure 🔍
-1% - +0%
-6.00ms - +2.86ms
preact-main972.40ms - 980.02msunsure 🔍
-0% - +1%
-2.86ms - +6.00ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.03ms - 19.03ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main19.03ms - 19.03msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.47ms - 16.51ms-unsure 🔍
-0% - +0%
-0.04ms - +0.02ms
preact-main16.48ms - 16.52msunsure 🔍
-0% - +0%
-0.02ms - +0.04ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.53ms - 1.53ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-main1.52ms - 1.53msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local69.00ms - 70.82ms-unsure 🔍
-2% - +1%
-1.51ms - +1.01ms
preact-main69.28ms - 71.03msunsure 🔍
-1% - +2%
-1.01ms - +1.51ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.93ms - 6.45ms-unsure 🔍
-3% - +10%
-0.15ms - +0.57ms
preact-main5.73ms - 6.22msunsure 🔍
-9% - +2%
-0.57ms - +0.15ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local15.83ms - 16.41ms-unsure 🔍
-4% - +2%
-0.59ms - +0.33ms
preact-main15.90ms - 16.61msunsure 🔍
-2% - +4%
-0.33ms - +0.59ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.72ms - 3.73ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main3.72ms - 3.73msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5018
  • Commit: 1aaaa3d

duration

VersionAvg timevs preact-localvs preact-main
preact-local59.91ms - 61.36ms-unsure 🔍
-1% - +2%
-0.57ms - +1.25ms
preact-main59.74ms - 60.85msunsure 🔍
-2% - +1%
-1.25ms - +0.57ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.09ms - 3.12ms-unsure 🔍
-1% - +1%
-0.02ms - +0.02ms
preact-main3.09ms - 3.12msunsure 🔍
-1% - +1%
-0.02ms - +0.02ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local24.80ms - 25.69ms-unsure 🔍
-3% - +2%
-0.69ms - +0.45ms
preact-main25.01ms - 25.73msunsure 🔍
-2% - +3%
-0.45ms - +0.69ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local31.58ms - 32.59ms-unsure 🔍
-3% - +2%
-0.83ms - +0.60ms
preact-main31.69ms - 32.71msunsure 🔍
-2% - +3%
-0.60ms - +0.83ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.34ms - 30.11ms-slower ❌
2% - 7%
0.67ms - 1.88ms
preact-main27.99ms - 28.91msfaster ✔
2% - 6%
0.67ms - 1.88ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.16ms - 26.97ms-slower ❌
0% - 5%
0.12ms - 1.23ms
preact-main25.51ms - 26.26msfaster ✔
0% - 5%
0.12ms - 1.23ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local22.68ms - 23.81ms-slower ❌
1% - 8%
0.23ms - 1.81ms
preact-main21.68ms - 22.78msfaster ✔
1% - 8%
0.23ms - 1.81ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.56ms - 21.47ms-unsure 🔍
-1% - +4%
-0.27ms - +0.87ms
preact-main20.37ms - 21.06msunsure 🔍
-4% - +1%
-0.87ms - +0.27ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 230
  • Built by: CI #5018
  • Commit: 1aaaa3d

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.01ms - 2.22ms-unsure 🔍
-6% - +8%
-0.13ms - +0.17ms
preact-main1.99ms - 2.19msunsure 🔍
-8% - +6%
-0.17ms - +0.13ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local0.99ms - 1.02ms-unsure 🔍
-4% - +1%
-0.04ms - +0.01ms
preact-main1.00ms - 1.04msunsure 🔍
-1% - +4%
-0.01ms - +0.04ms
-
todo
  • Browser: chrome-headless
  • Sample size: 110
  • Built by: CI #5018
  • Commit: 1aaaa3d

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.34ms - 31.48ms-faster ✔
4% - 5%
1.41ms - 1.65ms
preact-main32.84ms - 33.04msslower ❌
4% - 5%
1.41ms - 1.65ms
-

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-local33.49ms - 34.72ms-unsure 🔍
-2% - +4%
-0.57ms - +1.34ms
preact-main32.99ms - 34.45msunsure 🔍
-4% - +2%
-1.34ms - +0.57ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.93ms - 2.94ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main2.93ms - 2.93msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-

tachometer-reporter-action v2 for CI

@github-actions
Copy link

github-actions bot commented Jul 26, 2025

Size Change: +103 B (+0.22%)

Total Size: 47.6 kB

Filename Size Change
compat/dist/compat.js 3.93 kB +8 B (+0.2%)
compat/dist/compat.mjs 3.85 kB +9 B (+0.23%)
compat/dist/compat.umd.js 3.98 kB +10 B (+0.25%)
dist/preact.js 4.7 kB +30 B (+0.64%)
dist/preact.mjs 4.71 kB +26 B (+0.55%)
dist/preact.umd.js 4.77 kB +20 B (+0.42%)
ℹ️ View Unchanged
Filename Size
debug/dist/debug.js 3.9 kB
debug/dist/debug.mjs 3.9 kB
debug/dist/debug.umd.js 3.98 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.mjs 271 B
devtools/dist/devtools.umd.js 346 B
hooks/dist/hooks.js 1.55 kB
hooks/dist/hooks.mjs 1.58 kB
hooks/dist/hooks.umd.js 1.62 kB
jsx-runtime/dist/jsxRuntime.js 892 B
jsx-runtime/dist/jsxRuntime.mjs 861 B
jsx-runtime/dist/jsxRuntime.umd.js 966 B
test-utils/dist/testUtils.js 473 B
test-utils/dist/testUtils.mjs 473 B
test-utils/dist/testUtils.umd.js 555 B

compressed-size-action

@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 3 times, most recently from 062d750 to 700495a Compare July 26, 2025 10:36
@coveralls
Copy link

coveralls commented Jul 26, 2025

Coverage Status

coverage: 99.539% (+0.002%) from 99.537%
when pulling 1aaaa3d on solve-possible-memory-leak
into f3430e0 on main.

@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 2 times, most recently from 2de3d28 to 2c711b4 Compare July 26, 2025 11:22
@DracoRunner

This comment was marked as duplicate.

@JoviDeCroock JoviDeCroock marked this pull request as ready for review August 5, 2025 18:44

function removeOriginal(vnode, detachedParent, originalParent) {
if (vnode && originalParent) {
if (typeof vnode.type == 'string') {
Copy link
Member Author

Choose a reason for hiding this comment

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

For DOM nodes we need to revalidate the props so that we re-attach event-listeners which are deleted by unmount as we do dom._listeners = undefined

suspendedVNode._component._parentDom,
suspendedVNode._component._originalParentDom
);
if (!c._vnode._children) {
Copy link
Member Author

Choose a reason for hiding this comment

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

It's now possible in non hydration suspense that we've cleared _children

@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 8 times, most recently from 63b4b37 to 2f5a9b8 Compare August 5, 2025 20:32
@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 5 times, most recently from c34bd59 to 2a72320 Compare August 6, 2025 06:38
}

vnode._component = vnode._parent = vnode._dom = UNDEFINED;
vnode._dom = vnode._component = vnode._parent = NULL;
Copy link
Member Author

@JoviDeCroock JoviDeCroock Aug 6, 2025

Choose a reason for hiding this comment

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

I stopped removing the reference to children because it has perf issues in the micro benchmarks, going to verify this further

@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 3 times, most recently from 228462c to ee2dc7d Compare August 6, 2025 10:50
@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 6 times, most recently from 337944a to d17b911 Compare August 6, 2025 11:09
@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch 2 times, most recently from dafa9e0 to 05d8984 Compare August 8, 2025 12:38
@JoviDeCroock JoviDeCroock force-pushed the solve-possible-memory-leak branch from 05d8984 to 1aaaa3d Compare August 8, 2025 12:45
@lucas-bortoli
Copy link

Great job Jovi, thank you

@JoviDeCroock JoviDeCroock merged commit 5843ad0 into main Aug 8, 2025
12 checks passed
@JoviDeCroock JoviDeCroock deleted the solve-possible-memory-leak branch August 8, 2025 13:46
@JoviDeCroock JoviDeCroock mentioned this pull request Aug 19, 2025
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.

Possible memory leak

6 participants