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

Use a ref to track the hydrating state #4514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Sep 28, 2024

The main reason for this change is so that we discontinue hydration as soon as a mismatch is detected. For deferred subtrees this won't be a problem but for synchronous trees it's problematic that we can have the following

<Fragment>
  <span>Hello world</span>
</Fragment>
<span>Foo</span>

If the span mismatches we'll still try to hydrate Foo which could mean missing props/... This is more a proposal in follow up from #4490

One thing I need to check is whether this opts out of hydration for a mismatched text node as that would be undesirable

Copy link

github-actions bot commented Sep 28, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +0% (-6.79ms - +2.28ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -2% - +1% (-0.27ms - +0.18ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +3% (-1.13ms - +2.31ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +4% (-0.19ms - +0.58ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +2% (-0.59ms - +1.71ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +5% (-0.01ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.36ms - +0.47ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -3% - +3% (-1.01ms - +1.26ms)
    preact-local vs preact-main

usedJSHeapSize

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

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local966.61ms - 972.76ms-unsure 🔍
-1% - +0%
-6.79ms - +2.28ms
preact-main968.61ms - 975.27msunsure 🔍
-0% - +1%
-2.28ms - +6.79ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local25.38ms - 25.42ms-unsure 🔍
+0% - +0%
+0.00ms - +0.04ms
preact-main25.36ms - 25.39msunsure 🔍
-0% - -0%
-0.04ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.53ms - 16.72ms-unsure 🔍
-2% - +1%
-0.27ms - +0.18ms
preact-main16.47ms - 16.87msunsure 🔍
-1% - +2%
-0.18ms - +0.27ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.68ms - 1.71ms-unsure 🔍
-1% - +2%
-0.01ms - +0.03ms
preact-main1.67ms - 1.70msunsure 🔍
-2% - +1%
-0.03ms - +0.01ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local78.57ms - 81.34ms-unsure 🔍
-1% - +3%
-1.13ms - +2.31ms
preact-main78.34ms - 80.38msunsure 🔍
-3% - +1%
-2.31ms - +1.13ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local17.61ms - 18.06ms-unsure 🔍
-2% - +2%
-0.28ms - +0.37ms
preact-main17.55ms - 18.02msunsure 🔍
-2% - +2%
-0.37ms - +0.28ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.44ms - 17.15ms-unsure 🔍
-1% - +4%
-0.19ms - +0.58ms
preact-main16.46ms - 16.74msunsure 🔍
-3% - +1%
-0.58ms - +0.19ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.58ms - 4.59ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main4.58ms - 4.58msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local76.70ms - 78.35ms-unsure 🔍
-1% - +2%
-0.59ms - +1.71ms
preact-main76.17ms - 77.76msunsure 🔍
-2% - +1%
-1.71ms - +0.59ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.60ms - 3.62ms-unsure 🔍
-0% - +0%
-0.01ms - +0.02ms
preact-main3.60ms - 3.61msunsure 🔍
-0% - +0%
-0.02ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local31.72ms - 32.41ms-unsure 🔍
-0% - +3%
-0.05ms - +0.88ms
preact-main31.33ms - 31.96msunsure 🔍
-3% - +0%
-0.88ms - +0.05ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local37.11ms - 38.66ms-unsure 🔍
-3% - +2%
-1.33ms - +0.83ms
preact-main37.37ms - 38.89msunsure 🔍
-2% - +4%
-0.83ms - +1.33ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local27.52ms - 28.03ms-unsure 🔍
-1% - +2%
-0.38ms - +0.52ms
preact-main27.33ms - 28.07msunsure 🔍
-2% - +1%
-0.52ms - +0.38ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local27.87ms - 29.19ms-unsure 🔍
-2% - +5%
-0.48ms - +1.34ms
preact-main27.48ms - 28.73msunsure 🔍
-5% - +2%
-1.34ms - +0.48ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local21.66ms - 22.35ms-unsure 🔍
-2% - +3%
-0.34ms - +0.57ms
preact-main21.59ms - 22.20msunsure 🔍
-3% - +2%
-0.57ms - +0.34ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local23.47ms - 23.94ms-unsure 🔍
-1% - +2%
-0.20ms - +0.43ms
preact-main23.38ms - 23.79msunsure 🔍
-2% - +1%
-0.43ms - +0.20ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.02ms - 2.10ms-unsure 🔍
-1% - +5%
-0.01ms - +0.10ms
preact-main1.99ms - 2.06msunsure 🔍
-5% - +1%
-0.10ms - +0.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.12ms - 1.12ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main1.12ms - 1.12msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local34.50ms - 35.24ms-unsure 🔍
-1% - +1%
-0.36ms - +0.47ms
preact-main34.63ms - 35.01msunsure 🔍
-1% - +1%
-0.47ms - +0.36ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.23ms - 1.24ms-unsure 🔍
-2% - +1%
-0.02ms - +0.01ms
preact-main1.23ms - 1.25msunsure 🔍
-1% - +2%
-0.01ms - +0.02ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local36.02ms - 37.88ms-unsure 🔍
-3% - +3%
-1.01ms - +1.26ms
preact-main36.17ms - 37.47msunsure 🔍
-3% - +3%
-1.26ms - +1.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.54ms - 3.56ms-unsure 🔍
-1% - +0%
-0.04ms - +0.01ms
preact-main3.55ms - 3.58msunsure 🔍
-0% - +1%
-0.01ms - +0.04ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link

github-actions bot commented Sep 28, 2024

Size Change: +107 B (+0.17%)

Total Size: 62.1 kB

Filename Size Change
dist/preact.js 4.67 kB +19 B (+0.41%)
dist/preact.min.js 4.7 kB +17 B (+0.36%)
dist/preact.min.module.js 4.7 kB +18 B (+0.38%)
dist/preact.min.umd.js 4.73 kB +17 B (+0.36%)
dist/preact.module.js 4.69 kB +19 B (+0.41%)
dist/preact.umd.js 4.74 kB +17 B (+0.36%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.11 kB
compat/dist/compat.module.js 4.04 kB
compat/dist/compat.umd.js 4.18 kB
debug/dist/debug.js 3.82 kB
debug/dist/debug.module.js 3.83 kB
debug/dist/debug.umd.js 3.9 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 346 B
hooks/dist/hooks.js 1.53 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.6 kB
jsx-runtime/dist/jsxRuntime.js 981 B
jsx-runtime/dist/jsxRuntime.module.js 956 B
jsx-runtime/dist/jsxRuntime.umd.js 1.06 kB
test-utils/dist/testUtils.js 451 B
test-utils/dist/testUtils.module.js 456 B
test-utils/dist/testUtils.umd.js 536 B

compressed-size-action

@coveralls
Copy link

coveralls commented Sep 28, 2024

Coverage Status

coverage: 99.489% (+0.001%) from 99.488%
when pulling 13826a0 on set-hydrating-to-ref
into 6a66daa on main.

<Fragment>
<span>Foo</span>
</Fragment>
<div test-id="x">Hello world</div>
Copy link
Member Author

@JoviDeCroock JoviDeCroock Sep 28, 2024

Choose a reason for hiding this comment

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

On main this prop would not be set for instance, this could however be more problematic when we re-use a VNode. Let's say these are both a <div> but with an entirely different subtree or attributes we could reuse the wrong vnode.

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.

3 participants