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

Inline diffProps function #4200

Merged
merged 12 commits into from
Nov 8, 2023
Merged

Inline diffProps function #4200

merged 12 commits into from
Nov 8, 2023

Conversation

andrewiggins
Copy link
Member

@andrewiggins andrewiggins commented Nov 8, 2023

Inline diffProps to take advantage of the props loop to read values and use later in the diff. This avoids duplicate megamorphic reads for props like dangerouslySetInnerHTML, children, value, and checked since we can reuse reading the value in the props loop for handling elsewhere.

Copy link

github-actions bot commented Nov 8, 2023

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -1% - +1% (-0.80ms - +1.12ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -5% - +2% (-1.56ms - +0.79ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -1% - +0% (-12.21ms - +2.31ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -3% - +1% (-0.84ms - +0.15ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +1% (-1.09ms - +0.87ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -1% - +1% (-0.24ms - +0.11ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -4% - +9% (-0.17ms - +0.36ms)
    preact-local vs preact-main
  • todo: faster ✔ 5% - 6% (2.09ms - 2.45ms)
    preact-local vs preact-main

usedJSHeapSize

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

Results

02_replace1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main87.74ms - 88.96ms-unsure 🔍
-1% - +1%
-1.12ms - +0.80ms
unsure 🔍
-1% - +1%
-0.70ms - +1.01ms
preact-local87.76ms - 89.26msunsure 🔍
-1% - +1%
-0.80ms - +1.12ms
-unsure 🔍
-1% - +1%
-0.65ms - +1.28ms
preact-hooks87.59ms - 88.79msunsure 🔍
-1% - +1%
-1.01ms - +0.70ms
unsure 🔍
-1% - +1%
-1.28ms - +0.65ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.32ms - 3.32ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
faster ✔
1% - 1%
0.02ms - 0.02ms
preact-local3.32ms - 3.32msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-faster ✔
1% - 1%
0.02ms - 0.03ms
preact-hooks3.34ms - 3.34msslower ❌
1% - 1%
0.02ms - 0.02ms
slower ❌
1% - 1%
0.02ms - 0.03ms
-

run-warmup-0

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main32.22ms - 33.20ms-unsure 🔍
-2% - +2%
-0.72ms - +0.73ms
unsure 🔍
-2% - +2%
-0.69ms - +0.78ms
preact-local32.18ms - 33.24msunsure 🔍
-2% - +2%
-0.73ms - +0.72ms
-unsure 🔍
-2% - +2%
-0.72ms - +0.80ms
preact-hooks32.12ms - 33.22msunsure 🔍
-2% - +2%
-0.78ms - +0.69ms
unsure 🔍
-2% - +2%
-0.80ms - +0.72ms
-

run-warmup-1

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main40.74ms - 42.78ms-unsure 🔍
-4% - +2%
-1.53ms - +0.90ms
unsure 🔍
-5% - +0%
-2.32ms - +0.03ms
preact-local41.42ms - 42.73msunsure 🔍
-2% - +4%
-0.90ms - +1.53ms
-unsure 🔍
-4% - +0%
-1.71ms - +0.05ms
preact-hooks42.31ms - 43.49msunsure 🔍
-0% - +6%
-0.03ms - +2.32ms
unsure 🔍
-0% - +4%
-0.05ms - +1.71ms
-

run-warmup-2

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main31.09ms - 31.67ms-slower ❌
1% - 3%
0.24ms - 0.98ms
unsure 🔍
-1% - +1%
-0.34ms - +0.42ms
preact-local30.53ms - 31.01msfaster ✔
1% - 3%
0.24ms - 0.98ms
-faster ✔
1% - 3%
0.23ms - 0.92ms
preact-hooks31.10ms - 31.59msunsure 🔍
-1% - +1%
-0.42ms - +0.34ms
slower ❌
1% - 3%
0.23ms - 0.92ms
-

run-warmup-3

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main25.35ms - 25.88ms-slower ❌
2% - 4%
0.38ms - 0.96ms
unsure 🔍
-1% - +2%
-0.36ms - +0.46ms
preact-local24.83ms - 25.06msfaster ✔
1% - 4%
0.38ms - 0.96ms
-faster ✔
1% - 4%
0.29ms - 0.95ms
preact-hooks25.26ms - 25.87msunsure 🔍
-2% - +1%
-0.46ms - +0.36ms
slower ❌
1% - 4%
0.29ms - 0.95ms
-

run-warmup-4

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main40.86ms - 42.71ms-unsure 🔍
-3% - +2%
-1.23ms - +0.99ms
faster ✔
1% - 6%
0.39ms - 2.59ms
preact-local41.29ms - 42.52msunsure 🔍
-2% - +3%
-0.99ms - +1.23ms
-faster ✔
1% - 5%
0.52ms - 2.22ms
preact-hooks42.69ms - 43.86msslower ❌
1% - 6%
0.39ms - 2.59ms
slower ❌
1% - 5%
0.52ms - 2.22ms
-

run-final

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main24.54ms - 25.13ms-unsure 🔍
-1% - +3%
-0.34ms - +0.64ms
unsure 🔍
-1% - +2%
-0.22ms - +0.61ms
preact-local24.30ms - 25.08msunsure 🔍
-3% - +1%
-0.64ms - +0.34ms
-unsure 🔍
-2% - +2%
-0.44ms - +0.53ms
preact-hooks24.35ms - 24.93msunsure 🔍
-2% - +1%
-0.61ms - +0.22ms
unsure 🔍
-2% - +2%
-0.53ms - +0.44ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main31.60ms - 33.25ms-unsure 🔍
-2% - +5%
-0.79ms - +1.56ms
unsure 🔍
-4% - +3%
-1.45ms - +0.94ms
preact-local31.20ms - 32.89msunsure 🔍
-5% - +2%
-1.56ms - +0.79ms
-unsure 🔍
-6% - +2%
-1.85ms - +0.58ms
preact-hooks31.81ms - 33.56msunsure 🔍
-3% - +4%
-0.94ms - +1.45ms
unsure 🔍
-2% - +6%
-0.58ms - +1.85ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.28ms - 3.29ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
faster ✔
0% - 1%
0.02ms - 0.03ms
preact-local3.28ms - 3.29msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-faster ✔
1% - 1%
0.02ms - 0.03ms
preact-hooks3.30ms - 3.31msslower ❌
0% - 1%
0.02ms - 0.03ms
slower ❌
1% - 1%
0.02ms - 0.03ms
-
07_create10k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main931.17ms - 944.46ms-unsure 🔍
-0% - +1%
-2.31ms - +12.21ms
unsure 🔍
-1% - +1%
-8.13ms - +6.74ms
preact-local929.94ms - 935.80msunsure 🔍
-1% - +0%
-12.21ms - +2.31ms
-faster ✔
0% - 1%
1.20ms - 10.09ms
preact-hooks935.17ms - 941.85msunsure 🔍
-1% - +1%
-6.74ms - +8.13ms
slower ❌
0% - 1%
1.20ms - 10.09ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.33ms - 26.33ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
unsure 🔍
-0% - -0%
-0.02ms - -0.01ms
preact-local26.32ms - 26.33msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-hooks26.34ms - 26.34msunsure 🔍
+0% - +0%
+0.01ms - +0.02ms
unsure 🔍
+0% - +0%
+0.02ms - +0.02ms
-
filter_list

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.98ms - 27.81ms-unsure 🔍
-1% - +3%
-0.15ms - +0.84ms
faster ✔
0% - 6%
0.03ms - 1.67ms
preact-local26.77ms - 27.32msunsure 🔍
-3% - +1%
-0.84ms - +0.15ms
-faster ✔
2% - 7%
0.44ms - 1.95ms
preact-hooks27.54ms - 28.94msslower ❌
0% - 6%
0.03ms - 1.67ms
slower ❌
2% - 7%
0.44ms - 1.95ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main1.35ms - 1.37ms-unsure 🔍
-1% - +1%
-0.01ms - +0.01ms
faster ✔
1% - 3%
0.01ms - 0.04ms
preact-local1.35ms - 1.37msunsure 🔍
-1% - +1%
-0.01ms - +0.01ms
-faster ✔
1% - 3%
0.01ms - 0.04ms
preact-hooks1.37ms - 1.39msslower ❌
1% - 3%
0.01ms - 0.04ms
slower ❌
1% - 3%
0.01ms - 0.04ms
-
hydrate1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main81.89ms - 83.60ms-unsure 🔍
-1% - +1%
-0.87ms - +1.09ms
unsure 🔍
-1% - +2%
-0.68ms - +1.27ms
preact-local82.16ms - 83.11msunsure 🔍
-1% - +1%
-1.09ms - +0.87ms
-unsure 🔍
-1% - +1%
-0.49ms - +0.85ms
preact-hooks81.98ms - 82.93msunsure 🔍
-2% - +1%
-1.27ms - +0.68ms
unsure 🔍
-1% - +1%
-0.85ms - +0.49ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main6.12ms - 6.13ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
unsure 🔍
-0% - -0%
-0.03ms - -0.01ms
preact-local6.11ms - 6.12msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-faster ✔
0% - 1%
0.02ms - 0.03ms
preact-hooks6.14ms - 6.15msunsure 🔍
+0% - +0%
+0.01ms - +0.03ms
slower ❌
0% - 1%
0.02ms - 0.03ms
-
many_updates

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main16.53ms - 16.79ms-unsure 🔍
-1% - +1%
-0.11ms - +0.24ms
unsure 🔍
-2% - +1%
-0.34ms - +0.22ms
preact-local16.48ms - 16.71msunsure 🔍
-1% - +1%
-0.24ms - +0.11ms
-unsure 🔍
-2% - +1%
-0.40ms - +0.15ms
preact-hooks16.47ms - 16.96msunsure 🔍
-1% - +2%
-0.22ms - +0.34ms
unsure 🔍
-1% - +2%
-0.15ms - +0.40ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main4.45ms - 4.46ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
unsure 🔍
-0% - -0%
-0.01ms - -0.00ms
preact-local4.45ms - 4.46msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.00ms
preact-hooks4.46ms - 4.47msunsure 🔍
+0% - +0%
+0.00ms - +0.01ms
unsure 🔍
+0% - +0%
+0.00ms - +0.02ms
-
text_update

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.93ms - 4.30ms-unsure 🔍
-9% - +4%
-0.36ms - +0.17ms
faster ✔
5% - 16%
0.21ms - 0.78ms
preact-local4.01ms - 4.40msunsure 🔍
-4% - +9%
-0.17ms - +0.36ms
-faster ✔
3% - 15%
0.11ms - 0.69ms
preact-hooks4.39ms - 4.82msslower ❌
5% - 19%
0.21ms - 0.78ms
slower ❌
2% - 17%
0.11ms - 0.69ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.65ms - 0.68ms-unsure 🔍
-4% - +2%
-0.03ms - +0.01ms
faster ✔
1% - 7%
0.00ms - 0.05ms
preact-local0.66ms - 0.69msunsure 🔍
-2% - +4%
-0.01ms - +0.03ms
-unsure 🔍
-5% - +0%
-0.04ms - +0.00ms
preact-hooks0.68ms - 0.71msslower ❌
1% - 7%
0.00ms - 0.05ms
unsure 🔍
-0% - +6%
-0.00ms - +0.04ms
-
todo

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main39.67ms - 39.91ms-slower ❌
6% - 7%
2.09ms - 2.45ms
slower ❌
2% - 3%
0.82ms - 1.19ms
preact-local37.39ms - 37.66msfaster ✔
5% - 6%
2.09ms - 2.45ms
-faster ✔
3% - 4%
1.06ms - 1.46ms
preact-hooks38.64ms - 38.92msfaster ✔
2% - 3%
0.82ms - 1.19ms
slower ❌
3% - 4%
1.06ms - 1.46ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.80ms - 0.80ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
faster ✔
3% - 3%
0.02ms - 0.02ms
preact-local0.79ms - 0.79msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-faster ✔
3% - 3%
0.02ms - 0.03ms
preact-hooks0.82ms - 0.82msslower ❌
3% - 3%
0.02ms - 0.02ms
slower ❌
3% - 3%
0.02ms - 0.03ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

coveralls commented Nov 8, 2023

Coverage Status

coverage: 99.463% (-0.002%) from 99.465%
when pulling b9d8d67 on inline-diff-props
into b4a1cc2 on main.

Copy link

github-actions bot commented Nov 8, 2023

Size Change: -132 B (0%)

Total Size: 59.6 kB

Filename Size Change
dist/preact.js 4.48 kB -20 B (0%)
dist/preact.min.js 4.51 kB -22 B (0%)
dist/preact.min.module.js 4.5 kB -25 B (0%)
dist/preact.min.umd.js 4.53 kB -23 B (0%)
dist/preact.module.js 4.49 kB -25 B (0%)
dist/preact.umd.js 4.54 kB -17 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 4 kB 0 B
compat/dist/compat.module.js 3.93 kB 0 B
compat/dist/compat.umd.js 4.08 kB 0 B
debug/dist/debug.js 3.52 kB 0 B
debug/dist/debug.module.js 3.52 kB 0 B
debug/dist/debug.umd.js 3.6 kB 0 B
devtools/dist/devtools.js 232 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 315 B 0 B
hooks/dist/hooks.js 1.53 kB 0 B
hooks/dist/hooks.module.js 1.56 kB 0 B
hooks/dist/hooks.umd.js 1.62 kB 0 B
jsx-runtime/dist/jsxRuntime.js 963 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 938 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 1.04 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

@developit
Copy link
Member

Do you think the bench regression is due to the bench change? Or is it due to the second loop? I like the idea of using the first loop to store the incoming checked and value values and then replacing the second loop with two conditionals.

@andrewiggins
Copy link
Member Author

The changes to the bench are me trying the debug the regression. Will try the storing in a variable to see if that improves it at all

@andrewiggins
Copy link
Member Author

Yup, that fixes it

@andrewiggins andrewiggins merged commit 51771f7 into main Nov 8, 2023
@andrewiggins andrewiggins deleted the inline-diff-props branch November 8, 2023 22:59
@JoviDeCroock JoviDeCroock mentioned this pull request Nov 10, 2023
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