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

perf(core): create hot path for unmounting a tree of context #4396

Merged
merged 2 commits into from
May 22, 2024

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented May 22, 2024

currently when we unmount an entire tree we have to look at the subscribers of the Provider even though this is unmounted. This can also avoid a memory leak by freeing all subs automatically even though components could refer to them, all though this is very much an edge case.

Resolves #4347

Copy link

github-actions bot commented May 22, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-2.56ms - +5.62ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.18ms - +0.07ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +2% (-0.73ms - +1.62ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -4% - +3% (-0.52ms - +0.41ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +2% (-1.07ms - +1.29ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +4% (-0.10ms - +0.09ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -2% - +3% (-0.67ms - +0.92ms)
    preact-local vs preact-main
  • update10th1k: faster ✔ 0% - 2% (0.02ms - 0.56ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -3% - +3% (-0.40ms - +0.40ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +0% (-0.03ms - +0.02ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    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

duration

VersionAvg timevs preact-localvs preact-main
preact-local875.99ms - 882.45ms-unsure 🔍
-0% - +1%
-2.56ms - +5.62ms
preact-main875.18ms - 880.21msunsure 🔍
-1% - +0%
-5.62ms - +2.56ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local27.30ms - 27.31ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main27.30ms - 27.31msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.77ms - 16.93ms-unsure 🔍
-1% - +0%
-0.18ms - +0.07ms
preact-main16.81ms - 17.00msunsure 🔍
-0% - +1%
-0.07ms - +0.18ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.76ms - 1.76ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.76ms - 1.77msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local76.73ms - 78.73ms-unsure 🔍
-1% - +2%
-0.73ms - +1.62ms
preact-main76.66ms - 77.90msunsure 🔍
-2% - +1%
-1.62ms - +0.73ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local14.37ms - 14.94ms-unsure 🔍
-3% - +3%
-0.40ms - +0.40ms
preact-main14.38ms - 14.94msunsure 🔍
-3% - +3%
-0.40ms - +0.40ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local13.92ms - 14.68ms-unsure 🔍
-4% - +3%
-0.52ms - +0.41ms
preact-main14.08ms - 14.62msunsure 🔍
-3% - +4%
-0.41ms - +0.52ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.95ms - 4.95ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-main4.95ms - 4.95msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local73.43ms - 74.80ms-unsure 🔍
-1% - +2%
-1.07ms - +1.29ms
preact-main73.04ms - 74.97msunsure 🔍
-2% - +1%
-1.29ms - +1.07ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.80ms - 3.83ms-unsure 🔍
-1% - +0%
-0.03ms - +0.02ms
preact-main3.80ms - 3.83msunsure 🔍
-0% - +1%
-0.02ms - +0.03ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local29.70ms - 30.57ms-unsure 🔍
-3% - +1%
-0.94ms - +0.23ms
preact-main30.10ms - 30.88msunsure 🔍
-1% - +3%
-0.23ms - +0.94ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local35.82ms - 37.86ms-unsure 🔍
-5% - +2%
-2.02ms - +0.91ms
preact-main36.34ms - 38.44msunsure 🔍
-3% - +6%
-0.91ms - +2.02ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local27.50ms - 28.02ms-unsure 🔍
-1% - +2%
-0.27ms - +0.43ms
preact-main27.44ms - 27.92msunsure 🔍
-2% - +1%
-0.43ms - +0.27ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local25.55ms - 26.36ms-unsure 🔍
-1% - +3%
-0.24ms - +0.85ms
preact-main25.28ms - 26.01msunsure 🔍
-3% - +1%
-0.85ms - +0.24ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local27.56ms - 29.33ms-unsure 🔍
-2% - +7%
-0.50ms - +1.92ms
preact-main26.91ms - 28.56msunsure 🔍
-7% - +2%
-1.92ms - +0.50ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local24.31ms - 25.28ms-unsure 🔍
-3% - +3%
-0.64ms - +0.82ms
preact-main24.16ms - 25.25msunsure 🔍
-3% - +3%
-0.82ms - +0.64ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.02ms - 2.16ms-unsure 🔍
-5% - +4%
-0.10ms - +0.09ms
preact-main2.03ms - 2.16msunsure 🔍
-4% - +5%
-0.09ms - +0.10ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local0.98ms - 0.98ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-main0.98ms - 0.98msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local28.55ms - 29.94ms-unsure 🔍
-2% - +3%
-0.67ms - +0.92ms
preact-main28.74ms - 29.50msunsure 🔍
-3% - +2%
-0.92ms - +0.67ms
-

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local29.06ms - 29.25ms-faster ✔
0% - 2%
0.02ms - 0.56ms
preact-main29.19ms - 29.69msslower ❌
0% - 2%
0.02ms - 0.56ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.74ms - 3.74ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-main3.74ms - 3.74msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link

github-actions bot commented May 22, 2024

Size Change: +61 B (+0.1%)

Total Size: 61.6 kB

Filename Size Change
dist/preact.js 4.66 kB +11 B (+0.24%)
dist/preact.min.js 4.69 kB +10 B (+0.21%)
dist/preact.min.module.js 4.68 kB +9 B (+0.19%)
dist/preact.min.umd.js 4.72 kB +11 B (+0.23%)
dist/preact.module.js 4.67 kB +10 B (+0.21%)
dist/preact.umd.js 4.73 kB +10 B (+0.21%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.09 kB
compat/dist/compat.module.js 4.01 kB
compat/dist/compat.umd.js 4.14 kB
debug/dist/debug.js 3.71 kB
debug/dist/debug.module.js 3.71 kB
debug/dist/debug.umd.js 3.79 kB
devtools/dist/devtools.js 231 B
devtools/dist/devtools.module.js 240 B
devtools/dist/devtools.umd.js 314 B
hooks/dist/hooks.js 1.55 kB
hooks/dist/hooks.module.js 1.59 kB
hooks/dist/hooks.umd.js 1.63 kB
jsx-runtime/dist/jsxRuntime.js 976 B
jsx-runtime/dist/jsxRuntime.module.js 949 B
jsx-runtime/dist/jsxRuntime.umd.js 1.06 kB
test-utils/dist/testUtils.js 453 B
test-utils/dist/testUtils.module.js 454 B
test-utils/dist/testUtils.umd.js 536 B

compressed-size-action

@JoviDeCroock JoviDeCroock merged commit 8d228d2 into main May 22, 2024
13 checks passed
@JoviDeCroock JoviDeCroock deleted the unmount-provider branch May 22, 2024 18:45
@JoviDeCroock JoviDeCroock mentioned this pull request Jun 30, 2024
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.

Performance of unmounting a context provider
2 participants