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 keyed children would get removed #3779

Merged
merged 1 commit into from Oct 26, 2022

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Oct 26, 2022

Fixes #3766

When we have a fragment the DOM needs to dig deeper to find the matching elements, what happens is that we remove 1 element which means when we always skip by 2 we can't find any elements anymore, I know we have went back and forth on removing/not-removing this quite a bit now but this is a really valid case imo.

We can still opt not to do this for unkeyed elements if we find the byte-offset worth which might be a bit expensive as we would have to carry the fact that there's a parent to the Fragment that has a key

@github-actions
Copy link

github-actions bot commented Oct 26, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -6% - +24% (-5.24ms - +22.50ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -5% - +1% (-2.54ms - +0.79ms)
    preact-local vs preact-master
  • 07_create10k: slower ❌ 0% - 3% (1.28ms - 55.24ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -2% - +2% (-0.43ms - +0.40ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -3% - +4% (-5.69ms - +7.63ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -3% - +5% (-1.06ms - +1.78ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -2% - +1% (-0.06ms - +0.03ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -1% - +0% (-0.62ms - +0.05ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -12% - +4% (-0.56ms - +0.22ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.00ms - +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 🔍 -4% - +3% (-0.62ms - +0.53ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master87.02ms - 107.94ms-unsure 🔍
-21% - +4%
-22.50ms - +5.24ms
unsure 🔍
-12% - +23%
-10.29ms - +20.89ms
preact-local97.00ms - 115.21msunsure 🔍
-6% - +24%
-5.24ms - +22.50ms
-unsure 🔍
-2% - +33%
-0.78ms - +28.64ms
preact-hooks80.62ms - 103.74msunsure 🔍
-21% - +10%
-20.89ms - +10.29ms
unsure 🔍
-26% - +0%
-28.64ms - +0.78ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.44ms - 4.98ms-unsure 🔍
-5% - +12%
-0.22ms - +0.56ms
faster ✔
7% - 22%
0.36ms - 1.26ms
preact-local4.27ms - 4.81msunsure 🔍
-12% - +4%
-0.56ms - +0.22ms
-faster ✔
11% - 25%
0.53ms - 1.43ms
preact-hooks5.16ms - 5.88msslower ❌
7% - 27%
0.36ms - 1.26ms
slower ❌
11% - 32%
0.53ms - 1.43ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.01ms - 1.06ms-unsure 🔍
-3% - +3%
-0.03ms - +0.03ms
unsure 🔍
-5% - +1%
-0.05ms - +0.01ms
preact-local1.02ms - 1.05msunsure 🔍
-3% - +3%
-0.03ms - +0.03ms
-unsure 🔍
-5% - +1%
-0.05ms - +0.01ms
preact-hooks1.03ms - 1.08msunsure 🔍
-1% - +5%
-0.01ms - +0.05ms
unsure 🔍
-1% - +5%
-0.01ms - +0.05ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.82ms - 1.23ms-unsure 🔍
-35% - +19%
-0.40ms - +0.23ms
faster ✔
67% - 80%
2.29ms - 3.40ms
preact-local0.88ms - 1.35msunsure 🔍
-23% - +40%
-0.23ms - +0.40ms
-faster ✔
64% - 78%
2.19ms - 3.33ms
preact-hooks3.35ms - 4.39msslower ❌
186% - 370%
2.29ms - 3.40ms
slower ❌
161% - 336%
2.19ms - 3.33ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.41ms - 0.52ms-unsure 🔍
-7% - +22%
-0.03ms - +0.10ms
unsure 🔍
-2% - +28%
-0.01ms - +0.11ms
preact-local0.41ms - 0.45msunsure 🔍
-20% - +5%
-0.10ms - +0.03ms
-unsure 🔍
-1% - +11%
-0.01ms - +0.05ms
preact-hooks0.40ms - 0.43msunsure 🔍
-23% - +0%
-0.11ms - +0.01ms
unsure 🔍
-10% - +1%
-0.05ms - +0.01ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.35ms - 0.75ms-unsure 🔍
-39% - +68%
-0.18ms - +0.32ms
unsure 🔍
-47% - +48%
-0.25ms - +0.26ms
preact-local0.34ms - 0.63msunsure 🔍
-54% - +28%
-0.32ms - +0.18ms
-unsure 🔍
-50% - +25%
-0.29ms - +0.15ms
preact-hooks0.38ms - 0.71msunsure 🔍
-47% - +46%
-0.26ms - +0.25ms
unsure 🔍
-35% - +62%
-0.15ms - +0.29ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.30ms - 0.36ms-unsure 🔍
-16% - +11%
-0.06ms - +0.04ms
faster ✔
22% - 39%
0.10ms - 0.19ms
preact-local0.30ms - 0.37msunsure 🔍
-12% - +17%
-0.04ms - +0.06ms
-faster ✔
20% - 38%
0.09ms - 0.18ms
preact-hooks0.44ms - 0.50msslower ❌
27% - 60%
0.10ms - 0.19ms
slower ❌
22% - 58%
0.09ms - 0.18ms
-

run-final

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.28ms - 0.33ms-unsure 🔍
-23% - +4%
-0.08ms - +0.02ms
faster ✔
17% - 32%
0.06ms - 0.13ms
preact-local0.30ms - 0.38msunsure 🔍
-6% - +26%
-0.02ms - +0.08ms
-faster ✔
5% - 28%
0.02ms - 0.12ms
preact-hooks0.38ms - 0.43msslower ❌
19% - 45%
0.06ms - 0.13ms
slower ❌
3% - 37%
0.02ms - 0.12ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master52.64ms - 55.10ms-unsure 🔍
-2% - +5%
-0.79ms - +2.54ms
unsure 🔍
-2% - +3%
-1.33ms - +1.81ms
preact-local51.87ms - 54.12msunsure 🔍
-5% - +1%
-2.54ms - +0.79ms
-unsure 🔍
-4% - +2%
-2.13ms - +0.85ms
preact-hooks52.65ms - 54.61msunsure 🔍
-3% - +2%
-1.81ms - +1.33ms
unsure 🔍
-2% - +4%
-0.85ms - +2.13ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.78ms - 3.79ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
faster ✔
10% - 10%
0.40ms - 0.41ms
preact-local3.78ms - 3.79msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-faster ✔
10% - 10%
0.40ms - 0.41ms
preact-hooks4.19ms - 4.19msslower ❌
11% - 11%
0.40ms - 0.41ms
slower ❌
11% - 11%
0.40ms - 0.41ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1594.34ms - 1630.06ms-faster ✔
0% - 3%
1.28ms - 55.24ms
faster ✔
2% - 5%
35.47ms - 87.35ms
preact-local1620.23ms - 1660.68msslower ❌
0% - 3%
1.28ms - 55.24ms
-faster ✔
0% - 4%
5.53ms - 60.77ms
preact-hooks1654.80ms - 1692.42msslower ❌
2% - 5%
35.47ms - 87.35ms
slower ❌
0% - 4%
5.53ms - 60.77ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master25.84ms - 25.84ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
9% - 9%
2.55ms - 2.55ms
preact-local25.84ms - 25.84msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
9% - 9%
2.55ms - 2.55ms
preact-hooks28.39ms - 28.39msslower ❌
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-master22.47ms - 23.05ms-unsure 🔍
-2% - +2%
-0.40ms - +0.43ms
slower ❌
0% - 3%
0.03ms - 0.77ms
preact-local22.45ms - 23.03msunsure 🔍
-2% - +2%
-0.43ms - +0.40ms
-slower ❌
0% - 3%
0.02ms - 0.75ms
preact-hooks22.14ms - 22.58msfaster ✔
0% - 3%
0.03ms - 0.77ms
faster ✔
0% - 3%
0.02ms - 0.75ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.93ms - 1.93ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
11% - 11%
0.24ms - 0.24ms
preact-local1.93ms - 1.93msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
11% - 11%
0.24ms - 0.24ms
preact-hooks2.16ms - 2.16msslower ❌
12% - 12%
0.24ms - 0.24ms
slower ❌
12% - 12%
0.24ms - 0.24ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master196.46ms - 206.21ms-unsure 🔍
-4% - +3%
-7.63ms - +5.69ms
unsure 🔍
-6% - +1%
-11.61ms - +1.66ms
preact-local197.76ms - 206.85msunsure 🔍
-3% - +4%
-5.69ms - +7.63ms
-unsure 🔍
-5% - +1%
-10.40ms - +2.39ms
preact-hooks201.81ms - 210.81msunsure 🔍
-1% - +6%
-1.66ms - +11.61ms
unsure 🔍
-1% - +5%
-2.39ms - +10.40ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master15.15ms - 15.93ms-unsure 🔍
-3% - +4%
-0.53ms - +0.62ms
unsure 🔍
-3% - +6%
-0.39ms - +0.85ms
preact-local15.08ms - 15.91msunsure 🔍
-4% - +3%
-0.62ms - +0.53ms
-unsure 🔍
-3% - +5%
-0.46ms - +0.82ms
preact-hooks14.83ms - 15.79msunsure 🔍
-5% - +3%
-0.85ms - +0.39ms
unsure 🔍
-5% - +3%
-0.82ms - +0.46ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master35.04ms - 37.11ms-unsure 🔍
-5% - +3%
-1.78ms - +1.06ms
faster ✔
1% - 8%
0.35ms - 2.90ms
preact-local35.46ms - 37.41msunsure 🔍
-3% - +5%
-1.06ms - +1.78ms
-faster ✔
0% - 7%
0.04ms - 2.49ms
preact-hooks36.96ms - 38.44msslower ❌
1% - 8%
0.35ms - 2.90ms
slower ❌
0% - 7%
0.04ms - 2.49ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.96ms - 4.97ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
faster ✔
8% - 8%
0.44ms - 0.45ms
preact-local4.97ms - 4.97msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-faster ✔
8% - 8%
0.44ms - 0.44ms
preact-hooks5.41ms - 5.41msslower ❌
9% - 9%
0.44ms - 0.45ms
slower ❌
9% - 9%
0.44ms - 0.44ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master2.89ms - 2.96ms-unsure 🔍
-1% - +2%
-0.03ms - +0.06ms
faster ✔
8% - 11%
0.25ms - 0.37ms
preact-local2.88ms - 2.93msunsure 🔍
-2% - +1%
-0.06ms - +0.03ms
-faster ✔
8% - 12%
0.27ms - 0.38ms
preact-hooks3.18ms - 3.28msslower ❌
8% - 13%
0.25ms - 0.37ms
slower ❌
9% - 13%
0.27ms - 0.38ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.14ms - 1.14ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
1% - 1%
0.02ms - 0.02ms
preact-local1.14ms - 1.14msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
1% - 1%
0.02ms - 0.02ms
preact-hooks1.16ms - 1.16msslower ❌
1% - 1%
0.02ms - 0.02ms
slower ❌
1% - 1%
0.02ms - 0.02ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master56.31ms - 56.83ms-unsure 🔍
-0% - +1%
-0.05ms - +0.62ms
faster ✔
4% - 6%
2.63ms - 3.53ms
preact-local56.08ms - 56.50msunsure 🔍
-1% - +0%
-0.62ms - +0.05ms
-faster ✔
5% - 6%
2.94ms - 3.78ms
preact-hooks59.28ms - 60.02msslower ❌
5% - 6%
2.63ms - 3.53ms
slower ❌
5% - 7%
2.94ms - 3.78ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.43ms - 1.43ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
2% - 3%
0.04ms - 0.04ms
preact-local1.43ms - 1.43msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
2% - 3%
0.03ms - 0.04ms
preact-hooks1.47ms - 1.47msslower ❌
2% - 3%
0.04ms - 0.04ms
slower ❌
2% - 3%
0.03ms - 0.04ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.531% when pulling deb2646 on fix-finding-keyed-elements into c629fc2 on master.

@github-actions
Copy link

Size Change: -1 B

Total Size: 53.1 kB

Filename Size Change
dist/preact.js 4.06 kB -1 B
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.81 kB 0 B
compat/dist/compat.module.js 3.75 kB 0 B
compat/dist/compat.umd.js 3.87 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 314 B 0 B
dist/preact.min.js 4.08 kB 0 B
dist/preact.min.module.js 4.08 kB 0 B
dist/preact.min.umd.js 4.11 kB 0 B
dist/preact.module.js 4.07 kB 0 B
dist/preact.umd.js 4.12 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.64 kB 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

@JoviDeCroock JoviDeCroock merged commit 16d570f into master Oct 26, 2022
@JoviDeCroock JoviDeCroock deleted the fix-finding-keyed-elements branch October 26, 2022 14:46
@andrewiggins
Copy link
Member

Huh, I surprised this change fixes that issue. Definitely an important issue to fix ofc. I'm gonna look into this as well to refresh my memory on how this works.

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.

Preact doesn't preserve the DOM nodes of a keyed list when there are multiple DOM node children
4 participants