preact icon indicating copy to clipboard operation
preact copied to clipboard

major(core): forward ref by default

Open JoviDeCroock opened this issue 4 months ago • 3 comments

This removes the ability to get a component instance assigned to the ref, instead we will preserve ref on props for functional components and assign for normal DOM nodes. In the start I wanted to preserve props.ref entirely but that would make us access props.ref quite a lot which would be megamorphic access as well as need a new condition during element diffing.

I left the base tests untouched as we are removing component.base anyway in #4356. During this implementation I realised that if we're able to derive that a VNode comes from a JSX transform that we could stop cloning in compat VNode props handling which would safe a lot of memory.

JoviDeCroock avatar Apr 29 '24 18:04 JoviDeCroock

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +3% (-7.52ms - +25.14ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +1% (-0.23ms - +0.12ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +2% (-1.34ms - +1.51ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +5% (-0.18ms - +0.84ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +1% (-1.40ms - +0.43ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -6% - +0% (-0.11ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.24ms - +0.28ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -1% - +2% (-0.48ms - +0.68ms)
    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 🔍 -2% - +3% (-0.27ms - +0.48ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -6% - +1% (-0.07ms - +0.02ms)
    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.00ms)
    preact-local vs preact-main

Results

create10k
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local903.07ms - 932.11ms-unsure 🔍
-1% - +3%
-7.52ms - +25.14ms
preact-main901.30ms - 916.25msunsure 🔍
-3% - +1%
-25.14ms - +7.52ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local26.75ms - 26.75ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main26.75ms - 26.75msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.65ms - 16.82ms-unsure 🔍
-1% - +1%
-0.23ms - +0.12ms
preact-main16.64ms - 16.94msunsure 🔍
-1% - +1%
-0.12ms - +0.23ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.75ms - 1.76ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-main1.75ms - 1.75msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-
hydrate1k
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local76.18ms - 78.01ms-unsure 🔍
-2% - +2%
-1.34ms - +1.51ms
preact-main75.92ms - 78.10msunsure 🔍
-2% - +2%
-1.51ms - +1.34ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local14.17ms - 14.73ms-unsure 🔍
-2% - +3%
-0.27ms - +0.48ms
preact-main14.10ms - 14.60msunsure 🔍
-3% - +2%
-0.48ms - +0.27ms
-
many-updates
  • Browser: chrome-headless
  • Sample size: 90
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local17.69ms - 18.38ms-unsure 🔍
-1% - +5%
-0.18ms - +0.84ms
preact-main17.33ms - 18.08msunsure 🔍
-5% - +1%
-0.84ms - +0.18ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.86ms - 4.86ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main4.86ms - 4.86msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local63.40ms - 64.54ms-unsure 🔍
-2% - +1%
-1.40ms - +0.43ms
preact-main63.74ms - 65.17msunsure 🔍
-1% - +2%
-0.43ms - +1.40ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.64ms - 3.66ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main3.64ms - 3.66msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local26.57ms - 27.29ms-unsure 🔍
-2% - +1%
-0.64ms - +0.38ms
preact-main26.70ms - 27.42msunsure 🔍
-1% - +2%
-0.38ms - +0.64ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.38ms - 35.17ms-unsure 🔍
-5% - +2%
-1.64ms - +0.85ms
preact-main33.80ms - 35.54msunsure 🔍
-3% - +5%
-0.85ms - +1.64ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local23.68ms - 24.21ms-unsure 🔍
-2% - +2%
-0.54ms - +0.40ms
preact-main23.63ms - 24.41msunsure 🔍
-2% - +2%
-0.40ms - +0.54ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local22.44ms - 23.33ms-unsure 🔍
-0% - +6%
-0.01ms - +1.26ms
preact-main21.80ms - 22.72msunsure 🔍
-5% - +0%
-1.26ms - +0.01ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local27.99ms - 29.33ms-unsure 🔍
-5% - +2%
-1.56ms - +0.53ms
preact-main28.37ms - 29.97msunsure 🔍
-2% - +5%
-0.53ms - +1.56ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.64ms - 22.50ms-unsure 🔍
-3% - +3%
-0.76ms - +0.56ms
preact-main21.67ms - 22.67msunsure 🔍
-3% - +3%
-0.56ms - +0.76ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 320
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.69ms - 1.76ms-unsure 🔍
-6% - +0%
-0.11ms - +0.00ms
preact-main1.74ms - 1.82msunsure 🔍
-0% - +6%
-0.00ms - +0.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.16ms - 1.23ms-unsure 🔍
-6% - +1%
-0.07ms - +0.02ms
preact-main1.19ms - 1.26msunsure 🔍
-2% - +6%
-0.02ms - +0.07ms
-
todo
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local27.64ms - 27.99ms-unsure 🔍
-1% - +1%
-0.24ms - +0.28ms
preact-main27.61ms - 27.98msunsure 🔍
-1% - +1%
-0.28ms - +0.24ms
-

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
  • Browser: chrome-headless
  • Sample size: 50
  • Built by: Benchmarks #1449
  • Commit: d47b6b3

duration

VersionAvg timevs preact-localvs preact-main
preact-local32.16ms - 33.02ms-unsure 🔍
-1% - +2%
-0.48ms - +0.68ms
preact-main32.10ms - 32.88msunsure 🔍
-2% - +1%
-0.68ms - +0.48ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.70ms - 3.70ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main3.69ms - 3.69msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-

tachometer-reporter-action v2 for Benchmarks

github-actions[bot] avatar Apr 29 '24 18:04 github-actions[bot]

Size Change: -22 B (0%)

Total Size: 61 kB

Filename Size Change
compat/dist/compat.js 4.04 kB -49 B (1%)
compat/dist/compat.module.js 3.97 kB -45 B (1%)
compat/dist/compat.umd.js 4.1 kB -45 B (1%)
debug/dist/debug.js 3.63 kB +4 B (0%)
debug/dist/debug.module.js 3.63 kB +3 B (0%)
debug/dist/debug.umd.js 3.72 kB +11 B (0%)
dist/preact.js 4.62 kB +12 B (0%)
dist/preact.min.js 4.66 kB +14 B (0%)
dist/preact.min.module.js 4.65 kB +11 B (0%)
dist/preact.min.umd.js 4.68 kB +14 B (0%)
dist/preact.module.js 4.63 kB +14 B (0%)
dist/preact.umd.js 4.69 kB +10 B (0%)
jsx-runtime/dist/jsxRuntime.js 983 B +7 B (0%)
jsx-runtime/dist/jsxRuntime.module.js 959 B +10 B (1%)
jsx-runtime/dist/jsxRuntime.umd.js 1.06 kB +7 B (0%)
ℹ️ View Unchanged
Filename Size Change
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
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.63 kB 0 B
test-utils/dist/testUtils.js 453 B 0 B
test-utils/dist/testUtils.module.js 454 B 0 B
test-utils/dist/testUtils.umd.js 536 B 0 B

compressed-size-action

github-actions[bot] avatar Apr 29 '24 18:04 github-actions[bot]

Coverage Status

coverage: 99.605% (-0.004%) from 99.609% when pulling d47b6b37233e745fa2fe0e0108b0fac4a57951d5 on forward-ref-by-default into a832512a4e749bac9e618bc1cdbff3b5e1f41853 on main.

coveralls avatar Apr 29 '24 18:04 coveralls