preact icon indicating copy to clipboard operation
preact copied to clipboard

Testing out renderer state + alternatives

Open developit opened this issue 2 years ago • 3 comments

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.

developit avatar Apr 22 '22 15:04 developit

📊 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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 80
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 50
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 50
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 70
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 80
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 60
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 80
  • Built by: Benchmarks #753
  • Commit: 79c1628

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
  • Browser: chrome-headless 100.0.4896.75
  • Sample size: 50
  • Built by: Benchmarks #753
  • Commit: 79c1628

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[bot] avatar Apr 22 '22 15:04 github-actions[bot]

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

github-actions[bot] avatar Apr 22 '22 15:04 github-actions[bot]

Coverage Status

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

coveralls avatar Apr 22 '22 15:04 coveralls