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

Testing out renderer state + alternatives #3518

Draft
wants to merge 7 commits into
base: v11
Choose a base branch
from

Conversation

developit
Copy link
Member

@developit developit commented Apr 22, 2022

I'll be opening a few PRs for variants of this to get numbers from the perf bot. This one is an experiment to check the cost/benefit of arguments vs rendererState.

I'd originally intended to simply replace properties with accessor functions (rendererState.context = x becomes setCurrentContext(x)) in 8ea55ce, however Terser's inlining has degraded considerably since we last relied on this technique. In particular, it fails to inline any function that is used twice from within the same caller:

function patch() {
  let ctx = getCurrentContext(); // gets inlined
  if (child) {
    setCurrentContext(childCtx); // can be forced inline via @__INLINE__, but that's not great
    patch(child);
    setCurrentContext(ctx); // will never be inlined. forcing via @__INLINE__ inlines as an IIFE 😶‍🌫️
  }
}

So, I decided to try checking whether context or parentDom (the main two properties on RendererState) were driving performance. When I started looking into this though, I realized that context hasn't been an argument for quite some time - it's a backwards walk up the tree. I'd like to do another experimental PR to check if this is a performance tradeoff or not.

@github-actions
Copy link

github-actions bot commented Apr 22, 2022

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -1% - +3% (-0.96ms - +4.32ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -2% - +2% (-1.09ms - +0.89ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -1% - +0% (-8.85ms - +4.54ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -4% - +3% (-51.69ms - +37.13ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -6% - +12% (-5.76ms - +12.41ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -4% - +5% (-36.69ms - +43.94ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -4% - +10% (-15.24ms - +37.51ms)
    preact-local vs preact-master
  • todo: faster ✔ 0% - 2% (0.16ms - 1.06ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 -3% - +2% (-0.04ms - +0.03ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -1% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -0% - -0% (-0.01ms - -0.00ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -2% - +3% (-0.02ms - +0.04ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master145.15ms - 148.55ms-unsure 🔍
-3% - +1%
-4.32ms - +0.96ms
preact-local146.51ms - 150.55msunsure 🔍
-1% - +3%
-0.96ms - +4.32ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.18ms - 4.19ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-local4.18ms - 4.19msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-local
preact-master58.81ms - 60.98ms-unsure 🔍
-2% - +3%
-1.27ms - +1.64ms
preact-local58.75ms - 60.68msunsure 🔍
-3% - +2%
-1.64ms - +1.27ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-local
preact-master85.14ms - 90.38ms-unsure 🔍
-4% - +4%
-3.77ms - +3.37ms
preact-local85.54ms - 90.38msunsure 🔍
-4% - +4%
-3.37ms - +3.77ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-local
preact-master70.02ms - 72.63ms-unsure 🔍
-3% - +2%
-1.95ms - +1.75ms
preact-local70.12ms - 72.73msunsure 🔍
-2% - +3%
-1.75ms - +1.95ms
-

run-final

VersionAvg timevs preact-mastervs preact-local
preact-master145.18ms - 148.57ms-unsure 🔍
-3% - +1%
-4.33ms - +0.94ms
preact-local146.55ms - 150.58msunsure 🔍
-1% - +3%
-0.94ms - +4.33ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-local
preact-master49.36ms - 50.69ms-unsure 🔍
-2% - +2%
-0.89ms - +1.09ms
preact-local49.19ms - 50.66msunsure 🔍
-2% - +2%
-1.09ms - +0.89ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.20ms - 4.21ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-local4.20ms - 4.21msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master1307.26ms - 1318.82ms-unsure 🔍
-0% - +1%
-4.54ms - +8.85ms
preact-local1307.52ms - 1314.26msunsure 🔍
-1% - +0%
-8.85ms - +4.54ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.39ms - 1.44ms-unsure 🔍
-2% - +3%
-0.03ms - +0.04ms
preact-local1.39ms - 1.43msunsure 🔍
-3% - +2%
-0.04ms - +0.03ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-local
preact-master1373.81ms - 1437.14ms-unsure 🔍
-3% - +4%
-37.13ms - +51.69ms
preact-local1367.05ms - 1429.34msunsure 🔍
-4% - +3%
-51.69ms - +37.13ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master2.04ms - 2.05ms-unsure 🔍
-0% - +1%
-0.01ms - +0.01ms
preact-local2.03ms - 2.05msunsure 🔍
-1% - +0%
-0.01ms - +0.01ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-local
preact-master98.00ms - 110.15ms-unsure 🔍
-11% - +5%
-12.41ms - +5.76ms
preact-local100.64ms - 114.15msunsure 🔍
-6% - +12%
-5.76ms - +12.41ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master6.90ms - 6.90ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-local6.90ms - 6.90msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-local
preact-master933.96ms - 991.35ms-unsure 🔍
-5% - +4%
-43.94ms - +36.69ms
preact-local937.96ms - 994.60msunsure 🔍
-4% - +5%
-36.69ms - +43.94ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master5.70ms - 5.71ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-local5.70ms - 5.71msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-local
preact-master349.63ms - 386.49ms-unsure 🔍
-10% - +4%
-37.51ms - +15.24ms
preact-local360.33ms - 398.06msunsure 🔍
-4% - +10%
-15.24ms - +37.51ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.30ms - 1.30ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-local1.29ms - 1.30msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-local
preact-master44.47ms - 45.12ms-slower ❌
0% - 2%
0.16ms - 1.06ms
preact-local43.88ms - 44.51msfaster ✔
0% - 2%
0.16ms - 1.06ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master1.37ms - 1.42ms-unsure 🔍
-3% - +2%
-0.04ms - +0.02ms
preact-local1.38ms - 1.43msunsure 🔍
-2% - +3%
-0.02ms - +0.04ms
-

tachometer-reporter-action v2 for Benchmarks

@github-actions
Copy link

github-actions bot commented Apr 22, 2022

Size Change: -157 B (0%)

Total Size: 38.1 kB

Filename Size Change
dist/preact.js 4.58 kB -60 B (1%)
dist/preact.min.js 4.64 kB -53 B (1%)
dist/preact.umd.js 4.67 kB -44 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.63 kB 0 B
compat/dist/compat.umd.js 3.71 kB 0 B
debug/dist/debug.js 3.25 kB 0 B
debug/dist/debug.umd.js 3.33 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.umd.js 316 B 0 B
hooks/dist/hooks.js 1.32 kB 0 B
hooks/dist/hooks.umd.js 1.4 kB 0 B
jsx-runtime/dist/jsxRuntime.js 342 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 425 B 0 B
server/dist/server.js 2.6 kB 0 B
server/dist/server.umd.js 2.69 kB 0 B
test-utils/dist/testUtils.js 431 B 0 B
test-utils/dist/testUtils.umd.js 516 B 0 B

compressed-size-action

@coveralls
Copy link

coveralls commented Apr 22, 2022

Coverage Status

Coverage decreased (-0.006%) to 99.427% when pulling 79c1628 on renderer-state-refactor into d4ca6fd on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants