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

Improve performance and reduce memory allocation #4521

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Oct 2, 2024

As @developit found out, delete x is much faster nowadays.

  • in jsx we delete the ref and always keep the props object, no cloning
    • Can leave this one out if we feel skeptical, would love to go for the forwardRef changes though
  • in forwardRef we delete and re-apply the ref to the props object to avoid cloning
  • in forwardRef we add a bail case where we keep props when no ref is passed to us

Copy link

github-actions bot commented Oct 2, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: slower ❌ 0% - 1% (0.34ms - 10.18ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -2% - +1% (-0.37ms - +0.15ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +2% (-0.39ms - +1.40ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +2% (-0.23ms - +0.41ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +1% (-1.76ms - +0.71ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +5% (-0.03ms - +0.09ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +0% (-0.36ms - +0.16ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -3% - +2% (-1.08ms - +0.74ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.04ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -2% - +1% (-0.03ms - +0.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +2% (-0.23ms - +0.33ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +0% (-0.02ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +0% (-0.02ms - +0.01ms)
    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.02ms - +0.01ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local966.99ms - 976.17ms-slower ❌
0% - 1%
0.34ms - 10.18ms
preact-main964.56ms - 968.08msfaster ✔
0% - 1%
0.34ms - 10.18ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local25.37ms - 25.40ms-unsure 🔍
-0% - +0%
-0.04ms - +0.01ms
preact-main25.38ms - 25.42msunsure 🔍
-0% - +0%
-0.01ms - +0.04ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.56ms - 16.61ms-unsure 🔍
-2% - +1%
-0.37ms - +0.15ms
preact-main16.43ms - 16.96msunsure 🔍
-1% - +2%
-0.15ms - +0.37ms
-

usedJSHeapSize

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local75.86ms - 77.11ms-unsure 🔍
-1% - +2%
-0.39ms - +1.40ms
preact-main75.34ms - 76.62msunsure 🔍
-2% - +1%
-1.40ms - +0.39ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local15.42ms - 15.75ms-unsure 🔍
-2% - +2%
-0.23ms - +0.33ms
preact-main15.30ms - 15.77msunsure 🔍
-2% - +1%
-0.33ms - +0.23ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.35ms - 16.97ms-unsure 🔍
-1% - +2%
-0.23ms - +0.41ms
preact-main16.49ms - 16.64msunsure 🔍
-2% - +1%
-0.41ms - +0.23ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.58ms - 4.60ms-unsure 🔍
-1% - +0%
-0.02ms - +0.01ms
preact-main4.58ms - 4.61msunsure 🔍
-0% - +1%
-0.01ms - +0.02ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local74.25ms - 75.74ms-unsure 🔍
-2% - +1%
-1.76ms - +0.71ms
preact-main74.53ms - 76.51msunsure 🔍
-1% - +2%
-0.71ms - +1.76ms
-

usedJSHeapSize

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

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local31.05ms - 31.80ms-unsure 🔍
-2% - +1%
-0.60ms - +0.41ms
preact-main31.18ms - 31.86msunsure 🔍
-1% - +2%
-0.41ms - +0.60ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local36.00ms - 37.35ms-unsure 🔍
-3% - +2%
-1.11ms - +0.85ms
preact-main36.10ms - 37.52msunsure 🔍
-2% - +3%
-0.85ms - +1.11ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local26.66ms - 27.13ms-unsure 🔍
-3% - +0%
-0.89ms - +0.01ms
preact-main26.95ms - 27.73msunsure 🔍
-0% - +3%
-0.01ms - +0.89ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local27.32ms - 28.59ms-unsure 🔍
-4% - +2%
-1.21ms - +0.62ms
preact-main27.60ms - 28.90msunsure 🔍
-2% - +4%
-0.62ms - +1.21ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local21.59ms - 22.27ms-unsure 🔍
-0% - +4%
-0.03ms - +0.83ms
preact-main21.26ms - 21.80msunsure 🔍
-4% - +0%
-0.83ms - +0.03ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local22.89ms - 23.26ms-unsure 🔍
-2% - +1%
-0.46ms - +0.22ms
preact-main22.91ms - 23.48msunsure 🔍
-1% - +2%
-0.22ms - +0.46ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.99ms - 2.07ms-unsure 🔍
-1% - +5%
-0.03ms - +0.09ms
preact-main1.95ms - 2.04msunsure 🔍
-5% - +1%
-0.09ms - +0.03ms
-

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-local35.00ms - 35.32ms-unsure 🔍
-1% - +0%
-0.36ms - +0.16ms
preact-main35.06ms - 35.46msunsure 🔍
-0% - +1%
-0.16ms - +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-local33.62ms - 34.77ms-unsure 🔍
-3% - +2%
-1.08ms - +0.74ms
preact-main33.65ms - 35.07msunsure 🔍
-2% - +3%
-0.74ms - +1.08ms
-

usedJSHeapSize

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

tachometer-reporter-action v2 for Benchmarks

Copy link

github-actions bot commented Oct 2, 2024

Size Change: +20 B (+0.03%)

Total Size: 62.1 kB

Filename Size Change
compat/dist/compat.js 4.13 kB +13 B (+0.32%)
compat/dist/compat.module.js 4.05 kB +13 B (+0.32%)
compat/dist/compat.umd.js 4.19 kB +11 B (+0.26%)
jsx-runtime/dist/jsxRuntime.js 976 B -5 B (-0.51%)
jsx-runtime/dist/jsxRuntime.module.js 949 B -7 B (-0.73%)
jsx-runtime/dist/jsxRuntime.umd.js 1.05 kB -5 B (-0.47%)
ℹ️ View Unchanged
Filename Size
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
dist/preact.js 4.66 kB
dist/preact.min.js 4.69 kB
dist/preact.min.module.js 4.68 kB
dist/preact.min.umd.js 4.71 kB
dist/preact.module.js 4.67 kB
dist/preact.umd.js 4.73 kB
hooks/dist/hooks.js 1.53 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.6 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 Oct 2, 2024

Coverage Status

coverage: 99.488%. remained the same
when pulling 79303ec on less-memory-allocation
into 6a66daa on main.

@coveralls
Copy link

Coverage Status

coverage: 99.489% (+0.001%) from 99.488%
when pulling 5de3be2 on less-memory-allocation
into 6a66daa on main.

@JoviDeCroock JoviDeCroock force-pushed the less-memory-allocation branch 2 times, most recently from 85f218d to 79303ec Compare October 2, 2024 18:41
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.

4 participants