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 case where we would omit the ref from reused vnodes #3696

Merged
merged 4 commits into from Aug 28, 2022
Merged

Conversation

JoviDeCroock
Copy link
Member

fixes #3695

I think this should be a safe change as the ref from a reused element i.e. const x = <div ref={ref}> will always point at the same ref

@github-actions
Copy link

github-actions bot commented Aug 27, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -3% - +2% (-4.14ms - +2.64ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -6% - +1% (-2.81ms - +0.77ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -1% - +1% (-7.51ms - +7.44ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -1% - +3% (-0.17ms - +0.69ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -2% - +4% (-1.97ms - +3.97ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -5% - +2% (-1.59ms - +0.66ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -3% - +1% (-0.12ms - +0.05ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -1% - +2% (-0.03ms - +0.09ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -1% - +0% (-0.03ms - +0.02ms)
    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 🔍 -0% - +0% (-0.02ms - +0.01ms)
    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

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master138.14ms - 141.47ms-unsure 🔍
-2% - +3%
-2.64ms - +4.14ms
preact-local136.11ms - 142.00msunsure 🔍
-3% - +2%
-4.14ms - +2.64ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.78ms - 3.79ms-unsure 🔍
-2% - +1%
-0.09ms - +0.03ms
preact-local3.75ms - 3.87msunsure 🔍
-1% - +2%
-0.03ms - +0.09ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-local
preact-master1.20ms - 1.27ms-unsure 🔍
-6% - +3%
-0.07ms - +0.04ms
preact-local1.20ms - 1.29msunsure 🔍
-3% - +6%
-0.04ms - +0.07ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-local
preact-master0.64ms - 0.80ms-unsure 🔍
-2% - +26%
-0.01ms - +0.17ms
preact-local0.60ms - 0.68msunsure 🔍
-22% - +1%
-0.17ms - +0.01ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-local
preact-master0.78ms - 0.96ms-unsure 🔍
-14% - +16%
-0.12ms - +0.14ms
preact-local0.77ms - 0.95msunsure 🔍
-16% - +13%
-0.14ms - +0.12ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-local
preact-master0.41ms - 0.47ms-unsure 🔍
-12% - +8%
-0.05ms - +0.04ms
preact-local0.42ms - 0.49msunsure 🔍
-9% - +12%
-0.04ms - +0.05ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-local
preact-master0.56ms - 1.05ms-unsure 🔍
-41% - +56%
-0.29ms - +0.40ms
preact-local0.50ms - 0.99msunsure 🔍
-49% - +35%
-0.40ms - +0.29ms
-

run-final

VersionAvg timevs preact-mastervs preact-local
preact-master0.38ms - 0.46ms-unsure 🔍
-18% - +9%
-0.08ms - +0.04ms
preact-local0.39ms - 0.48msunsure 🔍
-10% - +20%
-0.04ms - +0.08ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-local
preact-master49.04ms - 51.79ms-unsure 🔍
-2% - +6%
-0.77ms - +2.81ms
preact-local48.25ms - 50.53msunsure 🔍
-6% - +1%
-2.81ms - +0.77ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.74ms - 3.77ms-unsure 🔍
-0% - +1%
-0.02ms - +0.03ms
preact-local3.74ms - 3.77msunsure 🔍
-1% - +0%
-0.03ms - +0.02ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master1168.82ms - 1180.76ms-unsure 🔍
-1% - +1%
-7.44ms - +7.51ms
preact-local1170.27ms - 1179.25msunsure 🔍
-1% - +1%
-7.51ms - +7.44ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master25.58ms - 25.59ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-local25.58ms - 25.59msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-local
preact-master23.11ms - 23.64ms-unsure 🔍
-3% - +1%
-0.69ms - +0.17ms
preact-local23.29ms - 23.97msunsure 🔍
-1% - +3%
-0.17ms - +0.69ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.81ms - 1.81ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-local1.81ms - 1.81msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master90.22ms - 94.10ms-unsure 🔍
-4% - +2%
-3.97ms - +1.97ms
preact-local90.91ms - 95.41msunsure 🔍
-2% - +4%
-1.97ms - +3.97ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master6.40ms - 6.42ms-unsure 🔍
-0% - +0%
-0.01ms - +0.02ms
preact-local6.39ms - 6.41msunsure 🔍
-0% - +0%
-0.02ms - +0.01ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-local
preact-master32.77ms - 34.11ms-unsure 🔍
-2% - +5%
-0.66ms - +1.59ms
preact-local32.07ms - 33.88msunsure 🔍
-5% - +2%
-1.59ms - +0.66ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.87ms - 4.88ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-local4.87ms - 4.88msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-local
preact-master3.44ms - 3.59ms-unsure 🔍
-1% - +3%
-0.05ms - +0.12ms
preact-local3.44ms - 3.52msunsure 🔍
-3% - +1%
-0.12ms - +0.05ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.04ms - 1.04ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-local1.04ms - 1.04msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

coveralls commented Aug 27, 2022

Coverage Status

Coverage remained the same at 99.291% when pulling 51e3148 on fix-refs into 1633907 on master.

@github-actions
Copy link

github-actions bot commented Aug 27, 2022

Size Change: +27 B (0%)

Total Size: 44 kB

Filename Size Change
dist/preact.js 4.01 kB +7 B (0%)
dist/preact.min.js 4.03 kB +7 B (0%)
dist/preact.module.js 4.02 kB +7 B (0%)
dist/preact.umd.js 4.07 kB +6 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.72 kB 0 B
compat/dist/compat.module.js 3.7 kB 0 B
compat/dist/compat.umd.js 3.78 kB 0 B
debug/dist/debug.js 3 kB 0 B
debug/dist/debug.module.js 3 kB 0 B
debug/dist/debug.umd.js 3.08 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 307 B 0 B
hooks/dist/hooks.js 1.4 kB 0 B
hooks/dist/hooks.module.js 1.43 kB 0 B
hooks/dist/hooks.umd.js 1.48 kB 0 B
jsx-runtime/dist/jsxRuntime.js 317 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 327 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 395 B 0 B
test-utils/dist/testUtils.js 444 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 521 B 0 B

compressed-size-action

render(<App count={0} />, scratch);
expect(calls[0]).to.equal(scratch.firstChild.firstChild);
render(<App count={1} />, scratch);
expect(calls[1]).to.equal(null);
Copy link
Member Author

Choose a reason for hiding this comment

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

this seems to still be called in the wrong order for functions i.e. applyRef(null); applyRef(element);

This could be similar to v11 ref ordering #3493 i.e. we basically unmount the parent but have already applied the ref as part of the diff in the child - this could be because our equality logic falls apart as we have no oldVNode to match against

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.

Really good find 🙌

@JoviDeCroock JoviDeCroock mentioned this pull request Aug 28, 2022
1 task
@JoviDeCroock JoviDeCroock merged commit 4672611 into master Aug 28, 2022
@JoviDeCroock JoviDeCroock deleted the fix-refs branch August 28, 2022 07:43
JoviDeCroock added a commit that referenced this pull request Oct 26, 2022
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.

refs in memoized elements
3 participants