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

Simplify the logic introduced in #4322 & use eventClock for capture events too #4324

Merged
merged 1 commit into from
Mar 24, 2024
Merged

Conversation

jviide
Copy link
Contributor

@jviide jviide commented Mar 24, 2024

This pull request contains two modifications to event handlers:

  • Simplify the logic introduced in fix: use a virtual clock instead of Date.now() for event dispatch times #4322. eventClock is now incremented every time a new event is dispatched. The logic is now more straightforward and build artifacts smaller. In certain scenarios this could make eventClock increase faster than the previous solutions, but in certain scenarios slower. However, it still requires 1 000 000 new events per second, every second, for over 280 years before the clock reaches Number.MAX_SAFE_INTEGER.

  • Apply the eventClock to event capture phase as well. The eventProxy and eventProxyCapture functions become almost the same, so they're generated with createEventProxy. This also saves some bytes. Duplicating the eventProxy code to eventProxyCapture would save a couple of more bytes, but would also add maintenance hassle.

Copy link

github-actions bot commented Mar 24, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -4% - +2% (-2.80ms - +1.91ms)
    preact-local vs preact-main
  • 03_update10th1k_x16: unsure 🔍 -2% - +4% (-0.69ms - +1.18ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -0% - +2% (-3.47ms - +14.33ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -0% - +0% (-0.02ms - +0.03ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.37ms - +0.97ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -2% - +1% (-0.38ms - +0.15ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -2% - +3% (-0.04ms - +0.07ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +2% (-0.16ms - +0.49ms)
    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.00ms - +0.01ms)
    preact-local vs preact-main
  • 07_create10k: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    preact-local vs preact-main
  • filter_list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • many_updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text_update: unsure 🔍 -1% - +0% (-0.00ms - +0.00ms)
    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-main76.89ms - 80.16ms-unsure 🔍
-2% - +4%
-1.91ms - +2.80ms
unsure 🔍
-2% - +3%
-1.76ms - +2.30ms
preact-local76.38ms - 79.77msunsure 🔍
-4% - +2%
-2.80ms - +1.91ms
-unsure 🔍
-3% - +2%
-2.27ms - +1.91ms
preact-hooks77.04ms - 79.47msunsure 🔍
-3% - +2%
-2.30ms - +1.76ms
unsure 🔍
-2% - +3%
-1.91ms - +2.27ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.38ms - 3.39ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
0% - 1%
0.02ms - 0.02ms
preact-local3.38ms - 3.39msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
0% - 1%
0.02ms - 0.02ms
preact-hooks3.40ms - 3.40msslower ❌
0% - 1%
0.02ms - 0.02ms
slower ❌
0% - 1%
0.02ms - 0.02ms
-

run-warmup-0

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main29.89ms - 30.60ms-unsure 🔍
-1% - +2%
-0.37ms - +0.67ms
unsure 🔍
-2% - +1%
-0.62ms - +0.44ms
preact-local29.71ms - 30.48msunsure 🔍
-2% - +1%
-0.67ms - +0.37ms
-unsure 🔍
-3% - +1%
-0.79ms - +0.31ms
preact-hooks29.94ms - 30.73msunsure 🔍
-1% - +2%
-0.44ms - +0.62ms
unsure 🔍
-1% - +3%
-0.31ms - +0.79ms
-

run-warmup-1

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main40.29ms - 41.91ms-unsure 🔍
-2% - +4%
-0.94ms - +1.47ms
unsure 🔍
-4% - +1%
-1.61ms - +0.32ms
preact-local39.95ms - 41.73msunsure 🔍
-4% - +2%
-1.47ms - +0.94ms
-unsure 🔍
-5% - +0%
-1.94ms - +0.13ms
preact-hooks41.22ms - 42.26msunsure 🔍
-1% - +4%
-0.32ms - +1.61ms
unsure 🔍
-0% - +5%
-0.13ms - +1.94ms
-

run-warmup-2

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.89ms - 27.80ms-unsure 🔍
-1% - +3%
-0.37ms - +0.78ms
unsure 🔍
-2% - +3%
-0.59ms - +0.79ms
preact-local26.79ms - 27.49msunsure 🔍
-3% - +1%
-0.78ms - +0.37ms
-unsure 🔍
-3% - +2%
-0.73ms - +0.52ms
preact-hooks26.72ms - 27.76msunsure 🔍
-3% - +2%
-0.79ms - +0.59ms
unsure 🔍
-2% - +3%
-0.52ms - +0.73ms
-

run-warmup-3

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main25.31ms - 26.48ms-unsure 🔍
-0% - +6%
-0.02ms - +1.50ms
unsure 🔍
-3% - +5%
-0.64ms - +1.16ms
preact-local24.68ms - 25.64msunsure 🔍
-6% - +0%
-1.50ms - +0.02ms
-unsure 🔍
-5% - +1%
-1.31ms - +0.36ms
preact-hooks24.95ms - 26.32msunsure 🔍
-4% - +2%
-1.16ms - +0.64ms
unsure 🔍
-1% - +5%
-0.36ms - +1.31ms
-

run-warmup-4

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main25.87ms - 26.95ms-unsure 🔍
-3% - +5%
-0.80ms - +1.35ms
unsure 🔍
-6% - +0%
-1.71ms - +0.03ms
preact-local25.21ms - 27.06msunsure 🔍
-5% - +3%
-1.35ms - +0.80ms
-unsure 🔍
-8% - +0%
-2.26ms - +0.03ms
preact-hooks26.57ms - 27.93msunsure 🔍
-0% - +7%
-0.03ms - +1.71ms
unsure 🔍
-0% - +9%
-0.03ms - +2.26ms
-

run-final

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main22.57ms - 23.84ms-unsure 🔍
-2% - +5%
-0.40ms - +1.14ms
unsure 🔍
-6% - +0%
-1.53ms - +0.06ms
preact-local22.41ms - 23.27msunsure 🔍
-5% - +2%
-1.14ms - +0.40ms
-faster ✔
2% - 7%
0.46ms - 1.75ms
preact-hooks23.47ms - 24.42msunsure 🔍
-0% - +7%
-0.06ms - +1.53ms
slower ❌
2% - 8%
0.46ms - 1.75ms
-
03_update10th1k_x16

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main33.09ms - 34.39ms-unsure 🔍
-3% - +2%
-1.18ms - +0.69ms
unsure 🔍
-2% - +3%
-0.75ms - +1.14ms
preact-local33.31ms - 34.66msunsure 🔍
-2% - +4%
-0.69ms - +1.18ms
-unsure 🔍
-2% - +4%
-0.52ms - +1.40ms
preact-hooks32.86ms - 34.23msunsure 🔍
-3% - +2%
-1.14ms - +0.75ms
unsure 🔍
-4% - +2%
-1.40ms - +0.52ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main3.35ms - 3.36ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
faster ✔
0% - 1%
0.01ms - 0.02ms
preact-local3.35ms - 3.36msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-faster ✔
0% - 1%
0.01ms - 0.02ms
preact-hooks3.37ms - 3.38msslower ❌
0% - 1%
0.01ms - 0.02ms
slower ❌
0% - 1%
0.01ms - 0.02ms
-
07_create10k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main895.87ms - 900.36ms-unsure 🔍
-2% - +0%
-14.33ms - +3.47ms
unsure 🔍
-1% - +0%
-8.40ms - +0.21ms
preact-local894.93ms - 912.16msunsure 🔍
-0% - +2%
-3.47ms - +14.33ms
-unsure 🔍
-1% - +1%
-8.02ms - +10.70ms
preact-hooks898.53ms - 905.88msunsure 🔍
-0% - +1%
-0.21ms - +8.40ms
unsure 🔍
-1% - +1%
-10.70ms - +8.02ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.16ms - 26.16ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-local26.16ms - 26.16msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-hooks26.18ms - 26.18msunsure 🔍
+0% - +0%
+0.02ms - +0.02ms
unsure 🔍
+0% - +0%
+0.02ms - +0.02ms
-
filter_list

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main16.57ms - 16.60ms-unsure 🔍
-0% - +0%
-0.03ms - +0.02ms
unsure 🔍
-0% - +0%
-0.02ms - +0.03ms
preact-local16.57ms - 16.61msunsure 🔍
-0% - +0%
-0.02ms - +0.03ms
-unsure 🔍
-0% - +0%
-0.02ms - +0.04ms
preact-hooks16.56ms - 16.60msunsure 🔍
-0% - +0%
-0.03ms - +0.02ms
unsure 🔍
-0% - +0%
-0.04ms - +0.02ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main1.42ms - 1.43ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
faster ✔
2% - 2%
0.02ms - 0.03ms
preact-local1.42ms - 1.43msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-faster ✔
2% - 2%
0.02ms - 0.03ms
preact-hooks1.45ms - 1.45msslower ❌
2% - 2%
0.02ms - 0.03ms
slower ❌
2% - 2%
0.02ms - 0.03ms
-
hydrate1k

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main74.74ms - 76.84ms-unsure 🔍
-1% - +2%
-0.97ms - +1.37ms
unsure 🔍
-1% - +2%
-1.07ms - +1.66ms
preact-local75.06ms - 76.12msunsure 🔍
-2% - +1%
-1.37ms - +0.97ms
-unsure 🔍
-1% - +1%
-0.93ms - +1.12ms
preact-hooks74.61ms - 76.37msunsure 🔍
-2% - +1%
-1.66ms - +1.07ms
unsure 🔍
-1% - +1%
-1.12ms - +0.93ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main6.05ms - 6.05ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
unsure 🔍
-0% - -0%
-0.03ms - -0.02ms
preact-local6.05ms - 6.05msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-unsure 🔍
-0% - -0%
-0.03ms - -0.02ms
preact-hooks6.07ms - 6.07msunsure 🔍
+0% - +0%
+0.02ms - +0.03ms
unsure 🔍
+0% - +0%
+0.02ms - +0.03ms
-
many_updates

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main18.77ms - 19.15ms-unsure 🔍
-1% - +2%
-0.15ms - +0.38ms
unsure 🔍
-3% - +2%
-0.67ms - +0.33ms
preact-local18.67ms - 19.04msunsure 🔍
-2% - +1%
-0.38ms - +0.15ms
-unsure 🔍
-4% - +1%
-0.78ms - +0.21ms
preact-hooks18.68ms - 19.59msunsure 🔍
-2% - +4%
-0.33ms - +0.67ms
unsure 🔍
-1% - +4%
-0.21ms - +0.78ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main4.52ms - 4.52ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-local4.52ms - 4.52msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-unsure 🔍
-0% - -0%
-0.02ms - -0.02ms
preact-hooks4.54ms - 4.54msunsure 🔍
+0% - +0%
+0.02ms - +0.02ms
unsure 🔍
+0% - +0%
+0.02ms - +0.02ms
-
text_update

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main2.45ms - 2.52ms-unsure 🔍
-3% - +2%
-0.07ms - +0.04ms
faster ✔
7% - 11%
0.18ms - 0.30ms
preact-local2.46ms - 2.54msunsure 🔍
-2% - +3%
-0.04ms - +0.07ms
-faster ✔
6% - 11%
0.17ms - 0.29ms
preact-hooks2.68ms - 2.78msslower ❌
7% - 12%
0.18ms - 0.30ms
slower ❌
7% - 12%
0.17ms - 0.29ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.80ms - 0.80ms-unsure 🔍
-0% - +1%
-0.00ms - +0.00ms
faster ✔
3% - 5%
0.02ms - 0.04ms
preact-local0.80ms - 0.80msunsure 🔍
-1% - +0%
-0.00ms - +0.00ms
-faster ✔
3% - 5%
0.02ms - 0.04ms
preact-hooks0.83ms - 0.85msslower ❌
3% - 5%
0.02ms - 0.04ms
slower ❌
3% - 6%
0.02ms - 0.04ms
-
todo

duration

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main26.43ms - 26.58ms-unsure 🔍
-2% - +1%
-0.49ms - +0.16ms
faster ✔
3% - 8%
0.69ms - 2.26ms
preact-local26.35ms - 26.98msunsure 🔍
-1% - +2%
-0.16ms - +0.49ms
-faster ✔
2% - 8%
0.47ms - 2.15ms
preact-hooks27.20ms - 28.76msslower ❌
3% - 9%
0.69ms - 2.26ms
slower ❌
2% - 8%
0.47ms - 2.15ms
-

usedJSHeapSize

VersionAvg timevs preact-mainvs preact-localvs preact-hooks
preact-main0.88ms - 0.88ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
faster ✔
3% - 3%
0.03ms - 0.03ms
preact-local0.88ms - 0.88msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-faster ✔
3% - 3%
0.03ms - 0.03ms
preact-hooks0.91ms - 0.91msslower ❌
3% - 3%
0.03ms - 0.03ms
slower ❌
3% - 3%
0.03ms - 0.03ms
-

tachometer-reporter-action v2 for Benchmarks

@coveralls
Copy link

coveralls commented Mar 24, 2024

Coverage Status

coverage: 99.601% (+0.1%) from 99.469%
when pulling a92e4de on jviide:event-clock
into b1d1b87 on preactjs:main.

@JoviDeCroock JoviDeCroock merged commit 8759dad into preactjs:main Mar 24, 2024
13 checks passed
@jviide jviide deleted the event-clock branch March 24, 2024 16:42
@JoviDeCroock JoviDeCroock mentioned this pull request Apr 9, 2024
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.

3 participants