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

use microtick outside of events #3879

Merged
merged 1 commit into from Feb 3, 2023
Merged

Conversation

JoviDeCroock
Copy link
Member

Fixes #3775
Fixes #3724

When we are in events we need setTimeout to deal with how events bubble, we want the events to complete before we start our rendering process. This however isn't needed when we are dealing with internal updates coming from effects/...

@github-actions
Copy link

github-actions bot commented Feb 3, 2023

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: slower ❌ 3% - 20% (5.53ms - 25.24ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -4% - +4% (-1.83ms - +1.80ms)
    preact-local vs preact-master
  • 07_create10k: slower ❌ 1% - 2% (6.84ms - 21.51ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -1% - +2% (-0.29ms - +0.35ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -2% - +2% (-3.60ms - +4.35ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -2% - +1% (-0.45ms - +0.30ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -0% - +2% (-0.01ms - +0.05ms)
    preact-local vs preact-master
  • todo: unsure 🔍 -2% - +0% (-0.89ms - +0.13ms)
    preact-local vs preact-master

usedJSHeapSize

  • 02_replace1k: faster ✔ 4% - 15% (0.14ms - 0.60ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: faster ✔ 1% - 2% (0.05ms - 0.08ms)
    preact-local vs preact-master
  • 07_create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-master
  • filter_list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • hydrate1k: unsure 🔍 -3% - +8% (-0.28ms - +0.85ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -0% - +1% (-0.01ms - +0.02ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • todo: faster ✔ 1% - 1% (0.01ms - 0.02ms)
    preact-local vs preact-master

Results

02_replace1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master121.85ms - 141.29ms-faster ✔
4% - 17%
5.53ms - 25.24ms
faster ✔
5% - 19%
8.02ms - 27.79ms
preact-local145.30ms - 148.60msslower ❌
3% - 20%
5.53ms - 25.24ms
-faster ✔
0% - 3%
0.09ms - 4.97ms
preact-hooks147.67ms - 151.28msslower ❌
5% - 22%
8.02ms - 27.79ms
slower ❌
0% - 3%
0.09ms - 4.97ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.59ms - 4.03ms-slower ❌
4% - 17%
0.14ms - 0.60ms
slower ❌
4% - 17%
0.15ms - 0.59ms
preact-local3.37ms - 3.51msfaster ✔
4% - 15%
0.14ms - 0.60ms
-unsure 🔍
-2% - +2%
-0.06ms - +0.07ms
preact-hooks3.43ms - 3.44msfaster ✔
5% - 15%
0.15ms - 0.59ms
unsure 🔍
-2% - +2%
-0.07ms - +0.06ms
-

run-warmup-0

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.92ms - 0.96ms-faster ✔
98% - 98%
50.93ms - 53.93ms
faster ✔
98% - 98%
51.24ms - 53.80ms
preact-local51.87ms - 54.87msslower ❌
5386% - 5769%
50.93ms - 53.93ms
-unsure 🔍
-4% - +4%
-2.06ms - +1.88ms
preact-hooks52.18ms - 54.74msslower ❌
5415% - 5759%
51.24ms - 53.80ms
unsure 🔍
-4% - +4%
-1.88ms - +2.06ms
-

run-warmup-1

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.57ms - 0.82ms-faster ✔
99% - 99%
68.39ms - 71.87ms
faster ✔
99% - 99%
69.15ms - 72.03ms
preact-local69.08ms - 72.56msslower ❌
8234% - 11967%
68.39ms - 71.87ms
-unsure 🔍
-4% - +2%
-2.72ms - +1.79ms
preact-hooks69.85ms - 72.72msslower ❌
8294% - 12041%
69.15ms - 72.03ms
unsure 🔍
-3% - +4%
-1.79ms - +2.72ms
-

run-warmup-2

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.35ms - 0.45ms-faster ✔
99% - 99%
55.20ms - 57.92ms
faster ✔
99% - 99%
51.74ms - 54.60ms
preact-local55.60ms - 58.32msslower ❌
12439% - 15841%
55.20ms - 57.92ms
-slower ❌
3% - 10%
1.42ms - 5.36ms
preact-hooks52.14ms - 55.00msslower ❌
11685% - 14900%
51.74ms - 54.60ms
faster ✔
3% - 9%
1.42ms - 5.36ms
-

run-warmup-3

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.43ms - 0.84ms-faster ✔
98% - 99%
42.75ms - 44.40ms
faster ✔
98% - 99%
44.41ms - 47.11ms
preact-local43.41ms - 45.01msslower ❌
4592% - 9179%
42.75ms - 44.40ms
-faster ✔
1% - 8%
0.63ms - 3.74ms
preact-hooks45.06ms - 47.72msslower ❌
4818% - 9643%
44.41ms - 47.11ms
slower ❌
1% - 9%
0.63ms - 3.74ms
-

run-warmup-4

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.39ms - 0.47ms-faster ✔
99% - 99%
44.70ms - 46.45ms
faster ✔
99% - 99%
46.40ms - 48.43ms
preact-local45.13ms - 46.88msslower ❌
9642% - 11698%
44.70ms - 46.45ms
-faster ✔
1% - 7%
0.50ms - 3.18ms
preact-hooks46.82ms - 48.86msslower ❌
10026% - 12175%
46.40ms - 48.43ms
slower ❌
1% - 7%
0.50ms - 3.18ms
-

run-final

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.29ms - 0.58ms-faster ✔
98% - 99%
32.07ms - 33.23ms
faster ✔
98% - 99%
32.21ms - 33.26ms
preact-local32.53ms - 33.65msslower ❌
4987% - 9951%
32.07ms - 33.23ms
-unsure 🔍
-3% - +2%
-0.84ms - +0.67ms
preact-hooks32.67ms - 33.68msslower ❌
5001% - 9976%
32.21ms - 33.26ms
unsure 🔍
-2% - +3%
-0.67ms - +0.84ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master41.08ms - 44.13ms-unsure 🔍
-4% - +4%
-1.80ms - +1.83ms
unsure 🔍
-4% - +4%
-1.80ms - +1.85ms
preact-local41.60ms - 43.57msunsure 🔍
-4% - +4%
-1.83ms - +1.80ms
-unsure 🔍
-3% - +3%
-1.40ms - +1.42ms
preact-hooks41.57ms - 43.58msunsure 🔍
-4% - +4%
-1.85ms - +1.80ms
unsure 🔍
-3% - +3%
-1.42ms - +1.40ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master3.32ms - 3.35ms-slower ❌
1% - 2%
0.05ms - 0.08ms
slower ❌
1% - 2%
0.03ms - 0.06ms
preact-local3.27ms - 3.28msfaster ✔
1% - 2%
0.05ms - 0.08ms
-faster ✔
0% - 1%
0.01ms - 0.02ms
preact-hooks3.29ms - 3.30msfaster ✔
1% - 2%
0.03ms - 0.06ms
slower ❌
0% - 1%
0.01ms - 0.02ms
-
07_create10k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1222.03ms - 1232.67ms-faster ✔
1% - 2%
6.84ms - 21.51ms
faster ✔
1% - 2%
12.18ms - 31.06ms
preact-local1236.47ms - 1246.58msslower ❌
1% - 2%
6.84ms - 21.51ms
-unsure 🔍
-1% - +0%
-16.74ms - +1.85ms
preact-hooks1241.17ms - 1256.77msslower ❌
1% - 3%
12.18ms - 31.06ms
unsure 🔍
-0% - +1%
-1.85ms - +16.74ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master25.36ms - 25.36ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-local25.36ms - 25.36msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-hooks25.38ms - 25.38msunsure 🔍
+0% - +0%
+0.02ms - +0.02ms
unsure 🔍
+0% - +0%
+0.02ms - +0.02ms
-
filter_list

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master22.73ms - 23.19ms-unsure 🔍
-2% - +1%
-0.35ms - +0.29ms
unsure 🔍
-2% - +1%
-0.49ms - +0.18ms
preact-local22.77ms - 23.21msunsure 🔍
-1% - +2%
-0.29ms - +0.35ms
-unsure 🔍
-2% - +1%
-0.46ms - +0.20ms
preact-hooks22.87ms - 23.36msunsure 🔍
-1% - +2%
-0.18ms - +0.49ms
unsure 🔍
-1% - +2%
-0.20ms - +0.46ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.61ms - 1.61ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
1% - 2%
0.02ms - 0.03ms
preact-local1.61ms - 1.61msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
1% - 1%
0.02ms - 0.02ms
preact-hooks1.63ms - 1.63msslower ❌
1% - 2%
0.02ms - 0.03ms
slower ❌
1% - 1%
0.02ms - 0.02ms
-
hydrate1k

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master177.77ms - 183.49ms-unsure 🔍
-2% - +2%
-4.35ms - +3.60ms
unsure 🔍
-3% - +1%
-5.83ms - +2.29ms
preact-local178.24ms - 183.76msunsure 🔍
-2% - +2%
-3.60ms - +4.35ms
-unsure 🔍
-3% - +1%
-5.39ms - +2.59ms
preact-hooks179.52ms - 185.28msunsure 🔍
-1% - +3%
-2.29ms - +5.83ms
unsure 🔍
-1% - +3%
-2.59ms - +5.39ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master10.52ms - 11.32ms-unsure 🔍
-7% - +2%
-0.85ms - +0.28ms
unsure 🔍
-6% - +4%
-0.68ms - +0.39ms
preact-local10.81ms - 11.60msunsure 🔍
-3% - +8%
-0.28ms - +0.85ms
-unsure 🔍
-4% - +6%
-0.39ms - +0.67ms
preact-hooks10.71ms - 11.42msunsure 🔍
-4% - +6%
-0.39ms - +0.68ms
unsure 🔍
-6% - +3%
-0.67ms - +0.39ms
-
many_updates

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master25.50ms - 26.12ms-unsure 🔍
-1% - +2%
-0.30ms - +0.45ms
unsure 🔍
-3% - +1%
-0.70ms - +0.15ms
preact-local25.52ms - 25.94msunsure 🔍
-2% - +1%
-0.45ms - +0.30ms
-unsure 🔍
-3% - +0%
-0.71ms - +0.01ms
preact-hooks25.79ms - 26.37msunsure 🔍
-1% - +3%
-0.15ms - +0.70ms
unsure 🔍
-0% - +3%
-0.01ms - +0.71ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master4.61ms - 4.64ms-unsure 🔍
-1% - +0%
-0.02ms - +0.01ms
faster ✔
0% - 1%
0.02ms - 0.05ms
preact-local4.62ms - 4.64msunsure 🔍
-0% - +1%
-0.01ms - +0.02ms
-faster ✔
0% - 1%
0.01ms - 0.04ms
preact-hooks4.65ms - 4.67msslower ❌
0% - 1%
0.02ms - 0.05ms
slower ❌
0% - 1%
0.01ms - 0.04ms
-
text_update

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master2.91ms - 2.95ms-unsure 🔍
-2% - +0%
-0.05ms - +0.01ms
faster ✔
4% - 6%
0.12ms - 0.18ms
preact-local2.93ms - 2.98msunsure 🔍
-0% - +2%
-0.01ms - +0.05ms
-faster ✔
3% - 5%
0.09ms - 0.16ms
preact-hooks3.06ms - 3.11msslower ❌
4% - 6%
0.12ms - 0.18ms
slower ❌
3% - 6%
0.09ms - 0.16ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master0.82ms - 0.82ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
2% - 2%
0.01ms - 0.01ms
preact-local0.82ms - 0.82msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
2% - 2%
0.01ms - 0.02ms
preact-hooks0.83ms - 0.83msslower ❌
2% - 2%
0.01ms - 0.01ms
slower ❌
2% - 2%
0.01ms - 0.02ms
-
todo

duration

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master55.05ms - 55.87ms-unsure 🔍
-0% - +2%
-0.13ms - +0.89ms
faster ✔
1% - 4%
0.82ms - 2.00ms
preact-local54.78ms - 55.38msunsure 🔍
-2% - +0%
-0.89ms - +0.13ms
-faster ✔
2% - 4%
1.27ms - 2.31ms
preact-hooks56.45ms - 57.29msslower ❌
1% - 4%
0.82ms - 2.00ms
slower ❌
2% - 4%
1.27ms - 2.31ms
-

usedJSHeapSize

VersionAvg timevs preact-mastervs preact-localvs preact-hooks
preact-master1.10ms - 1.11ms-slower ❌
1% - 1%
0.01ms - 0.02ms
faster ✔
1% - 1%
0.01ms - 0.01ms
preact-local1.09ms - 1.09msfaster ✔
1% - 1%
0.01ms - 0.02ms
-faster ✔
2% - 2%
0.02ms - 0.02ms
preact-hooks1.11ms - 1.12msslower ❌
1% - 1%
0.01ms - 0.01ms
slower ❌
2% - 2%
0.02ms - 0.02ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

coveralls commented Feb 3, 2023

Coverage Status

Coverage: 99.543% (+0.005%) from 99.538% when pulling 46bbf78 on microtick-outside-of-evnts into ef708b9 on master.

@github-actions
Copy link

github-actions bot commented Feb 3, 2023

Size Change: +317 B (0%)

Total Size: 53.9 kB

Filename Size Change
dist/preact.js 4.22 kB +46 B (1%)
dist/preact.min.js 4.25 kB +55 B (1%)
dist/preact.min.module.js 4.25 kB +55 B (1%)
dist/preact.min.umd.js 4.27 kB +51 B (1%)
dist/preact.module.js 4.23 kB +51 B (1%)
dist/preact.umd.js 4.29 kB +59 B (1%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.81 kB 0 B
compat/dist/compat.module.js 3.75 kB 0 B
compat/dist/compat.umd.js 3.87 kB 0 B
debug/dist/debug.js 3 kB 0 B
debug/dist/debug.module.js 3.01 kB 0 B
debug/dist/debug.umd.js 3.08 kB 0 B
devtools/dist/devtools.js 231 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.49 kB 0 B
hooks/dist/hooks.module.js 1.52 kB 0 B
hooks/dist/hooks.umd.js 1.57 kB 0 B
jsx-runtime/dist/jsxRuntime.js 360 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 326 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 441 B 0 B
test-utils/dist/testUtils.js 442 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 526 B 0 B

compressed-size-action

Copy link
Member

@andrewiggins andrewiggins left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together!

Co-authored-by: andrewiggins <andre@preact.dev>
@andrewiggins
Copy link
Member

I took a look at the pref regressions in the 02_replace1k benchmark locally and I believe it is caused by a bug in our benchmark. In the change from microtask to setTimeout scheduling in #3608 some assumptions our benchmarks made about when work would be done changed (it previously assumed microtask, etc.). So some measures that previously measured JS execution now just measured the time it takes to scheduled work. As such the change back in this PR isn't comparing apples (preact-master) and oranges (preact-local).

In preact-master, the run-* measures only measure the time it takes to schedule rerender and the duration measure no longer includes browser layout & paint.

image

In preact-local (this branch), the run-* now measure the execution of the rerender and the duration measure covers the rerender + browser layout & paint.

image

I suspect this behavior might change depending on how the browser decides to do scheduling of the afterFrame postMessage so the results from the GH actions might be slightly different. But at least locally things look comparable so I'm going to go ahead with these changes for now.

@andrewiggins andrewiggins merged commit 6e2e952 into master Feb 3, 2023
@andrewiggins andrewiggins deleted the microtick-outside-of-evnts branch February 3, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants