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

Single text node hot path #4523

Closed
wants to merge 2 commits into from
Closed

Single text node hot path #4523

wants to merge 2 commits into from

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Oct 3, 2024

Supersedes #3939

Similar to 3939 we are seeing some operations take longer as rather than mutating the text-node we'll be swapping positions instead. The impact seems higher in skew based diff though so not sure whether the performance impact will be as high as in 3939.

The replace_1k difference is similar to #3939 (comment)

This could also be problematic with signals as text-updates won't automatically update afaik

Looks like this should not break signals actually
image

From #2618 we can derive that there are actually a lot of cases where the single child type is a text-node.

@JoviDeCroock JoviDeCroock force-pushed the revive-3939 branch 2 times, most recently from f5156c4 to 428ac57 Compare October 3, 2024 07:38
@JoviDeCroock JoviDeCroock changed the title Revive 3939 Single text node hot path Oct 3, 2024
@JoviDeCroock JoviDeCroock deleted the revive-3939 branch October 9, 2024 13:06
@JoviDeCroock JoviDeCroock restored the revive-3939 branch October 12, 2024 07:07
@JoviDeCroock JoviDeCroock deleted the revive-3939 branch October 12, 2024 07:07
@JoviDeCroock JoviDeCroock restored the revive-3939 branch October 12, 2024 07:07
@JoviDeCroock JoviDeCroock reopened this Oct 12, 2024
@JoviDeCroock JoviDeCroock marked this pull request as ready for review October 12, 2024 07:08
@JoviDeCroock JoviDeCroock force-pushed the revive-3939 branch 2 times, most recently from 20e7020 to 91f6188 Compare October 12, 2024 07:21
Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re:Andre's comment about the "regression" in replace1k, have you by chance tried giving it more warmup runs? Say bumping up to 25 like a few of the other benches?

That very well might have been in one of your force pushes, just thought I'd ask.

@rschristian
Copy link
Member

rschristian commented Oct 12, 2024

Looking at the results, the warmup might close the gap a little on average, but not totally: https://github.com/preactjs/preact/actions/runs/11304050028/job/31441949188

Can probably revert/drop that, sorry. Was good to confirm I suppose though.

@JoviDeCroock JoviDeCroock force-pushed the revive-3939 branch 4 times, most recently from e109c40 to c664014 Compare October 12, 2024 09:15
Copy link

github-actions bot commented Oct 13, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-3.97ms - +6.07ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -3% - +1% (-0.53ms - +0.11ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +0% (-0.69ms - +0.33ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +2% (-0.32ms - +0.35ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -3% - +2% (-2.43ms - +1.49ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -0% - +9% (-0.01ms - +0.20ms)
    preact-local vs preact-main
  • todo: faster ✔ 3% - 7% (1.06ms - 2.41ms)
    preact-local vs preact-main
  • update10th1k: faster ✔ 4% - 9% (1.57ms - 3.25ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +2% (-0.00ms - +0.03ms)
    preact-local vs preact-main
  • hydrate1k: faster ✔ 0% - 4% (0.03ms - 0.59ms)
    preact-local vs preact-main
  • many-updates: slower ❌ 34% - 35% (1.58ms - 1.61ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.02ms - +0.02ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +1% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • update10th1k: slower ❌ 52% - 53% (1.84ms - 1.87ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local936.90ms - 944.83ms-unsure 🔍
-0% - +1%
-3.97ms - +6.07ms
preact-main936.74ms - 942.89msunsure 🔍
-1% - +0%
-6.07ms - +3.97ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local25.28ms - 25.28ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main25.28ms - 25.28msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.46ms - 16.60ms-unsure 🔍
-3% - +1%
-0.53ms - +0.11ms
preact-main16.43ms - 17.05msunsure 🔍
-1% - +3%
-0.11ms - +0.53ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.67ms - 1.69ms-unsure 🔍
-0% - +2%
-0.00ms - +0.03ms
preact-main1.66ms - 1.67msunsure 🔍
-2% - +0%
-0.03ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local68.27ms - 68.80ms-unsure 🔍
-1% - +0%
-0.69ms - +0.33ms
preact-main68.28ms - 69.15msunsure 🔍
-0% - +1%
-0.33ms - +0.69ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local12.65ms - 13.07ms-faster ✔
0% - 4%
0.03ms - 0.59ms
preact-main12.98ms - 13.36msslower ❌
0% - 5%
0.03ms - 0.59ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.56ms - 16.60ms-unsure 🔍
-2% - +2%
-0.32ms - +0.35ms
preact-main16.23ms - 16.90msunsure 🔍
-2% - +2%
-0.35ms - +0.32ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local6.16ms - 6.18ms-slower ❌
34% - 35%
1.58ms - 1.61ms
preact-main4.57ms - 4.59msfaster ✔
26% - 26%
1.58ms - 1.61ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local76.63ms - 79.37ms-unsure 🔍
-3% - +2%
-2.43ms - +1.49ms
preact-main77.06ms - 79.87msunsure 🔍
-2% - +3%
-1.49ms - +2.43ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.56ms - 3.59ms-unsure 🔍
-1% - +1%
-0.02ms - +0.02ms
preact-main3.56ms - 3.59msunsure 🔍
-1% - +1%
-0.02ms - +0.02ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local31.04ms - 31.93ms-unsure 🔍
-3% - +1%
-0.86ms - +0.47ms
preact-main31.19ms - 32.16msunsure 🔍
-2% - +3%
-0.47ms - +0.86ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local36.54ms - 38.43ms-unsure 🔍
-2% - +4%
-0.91ms - +1.47ms
preact-main36.49ms - 37.93msunsure 🔍
-4% - +2%
-1.47ms - +0.91ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local26.65ms - 27.18ms-unsure 🔍
-2% - +2%
-0.53ms - +0.49ms
preact-main26.51ms - 27.37msunsure 🔍
-2% - +2%
-0.49ms - +0.53ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local28.93ms - 30.79ms-unsure 🔍
-4% - +5%
-1.04ms - +1.55ms
preact-main28.70ms - 30.51msunsure 🔍
-5% - +3%
-1.55ms - +1.04ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local21.23ms - 21.89ms-unsure 🔍
-0% - +4%
-0.06ms - +0.81ms
preact-main20.91ms - 21.47msunsure 🔍
-4% - +0%
-0.81ms - +0.06ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local23.45ms - 24.16ms-unsure 🔍
-2% - +2%
-0.58ms - +0.54ms
preact-main23.40ms - 24.26msunsure 🔍
-2% - +2%
-0.54ms - +0.58ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 220
  • Built by: CI #3992
  • Commit: df6c646

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.13ms - 2.29ms-unsure 🔍
-0% - +9%
-0.01ms - +0.20ms
preact-main2.05ms - 2.19msunsure 🔍
-9% - +0%
-0.20ms - +0.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.10ms - 1.11ms-unsure 🔍
-1% - +0%
-0.01ms - +0.00ms
preact-main1.11ms - 1.11msunsure 🔍
-0% - +1%
-0.00ms - +0.01ms
-
todo
  • Browser: chrome-headless
  • Sample size: 110
  • Built by: CI #3992
  • Commit: df6c646

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.45ms - 32.77ms-faster ✔
3% - 7%
1.06ms - 2.41ms
preact-main33.69ms - 34.01msslower ❌
3% - 8%
1.06ms - 2.41ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.23ms - 1.23ms-unsure 🔍
-0% - +1%
-0.00ms - +0.01ms
preact-main1.22ms - 1.23msunsure 🔍
-1% - +0%
-0.01ms - +0.00ms
-
update10th1k
  • Browser: chrome-headless
  • Sample size: 130
  • Built by: CI #3992
  • Commit: df6c646

duration

VersionAvg timevs preact-localvs preact-main
preact-local32.88ms - 34.18ms-faster ✔
4% - 9%
1.57ms - 3.25ms
preact-main35.40ms - 36.47msslower ❌
5% - 10%
1.57ms - 3.25ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.38ms - 5.40ms-slower ❌
52% - 53%
1.84ms - 1.87ms
preact-main3.53ms - 3.54msfaster ✔
34% - 35%
1.84ms - 1.87ms
-

tachometer-reporter-action v2 for CI

@JoviDeCroock JoviDeCroock force-pushed the revive-3939 branch 2 times, most recently from 20942aa to 021c18d Compare October 13, 2024 10:30
Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very impressed with the findings. Really good work!

src/diff/index.js Outdated Show resolved Hide resolved
src/diff/index.js Outdated Show resolved Hide resolved
@JoviDeCroock JoviDeCroock force-pushed the revive-3939 branch 3 times, most recently from 242a543 to e1c277d Compare November 1, 2024 08:35
@preactjs preactjs deleted a comment from github-actions bot Nov 1, 2024
@preactjs preactjs deleted a comment from github-actions bot Nov 1, 2024
Copy link

github-actions bot commented Nov 1, 2024

Size Change: +230 B (+0.37%)

Total Size: 62.4 kB

Filename Size Change
dist/preact.js 4.72 kB +39 B (+0.83%)
dist/preact.min.js 4.75 kB +37 B (+0.79%)
dist/preact.min.module.js 4.75 kB +39 B (+0.83%)
dist/preact.min.umd.js 4.77 kB +37 B (+0.78%)
dist/preact.module.js 4.74 kB +41 B (+0.87%)
dist/preact.umd.js 4.79 kB +37 B (+0.78%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.13 kB
compat/dist/compat.module.js 4.05 kB
compat/dist/compat.umd.js 4.19 kB
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
hooks/dist/hooks.js 1.53 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.6 kB
jsx-runtime/dist/jsxRuntime.js 976 B
jsx-runtime/dist/jsxRuntime.module.js 949 B
jsx-runtime/dist/jsxRuntime.umd.js 1.05 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

@preactjs preactjs deleted a comment from coveralls Nov 1, 2024
@JoviDeCroock
Copy link
Member Author

Closing due to the memory regression

@JoviDeCroock JoviDeCroock deleted the revive-3939 branch November 1, 2024 08:46
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.

5 participants