Skip to content

Create a unique event-clock for each Preact instance on a page.#5068

Open
JoviDeCroock wants to merge 4 commits intov10.xfrom
create-unique-event-counter-per-preact-instance
Open

Create a unique event-clock for each Preact instance on a page.#5068
JoviDeCroock wants to merge 4 commits intov10.xfrom
create-unique-event-counter-per-preact-instance

Conversation

@JoviDeCroock
Copy link
Copy Markdown
Member

@JoviDeCroock JoviDeCroock commented Mar 30, 2026

If a library bundles its own variant of Preact and relies on event-bubbling to step through its root and into other roots. Think a custom-element component library bubbling up into your regular application. Then the event-clock can be out of sync meaning that events aren't firing on the root application.

Theoretically this can't reproduce the bug of shifting roots as the first touch-point into the new Preact root will re-create with its own root.

We eliminate the bug from deliberate multi-bundle applications but it would now be introduced in ones where the user accidentally does a dual package hazard combination, that however would also have issues with the options hooks so I think that's okay.

It's a bit hard to add tests for this so I decided to leave it be and make huge comments instead.

A lower bundle size variant could be self._id++

If a library bundles its own variant of Preact and relies on
event-bubbling to step through its root and into other roots.
Think a custom-element component library bubbling up into your
regular application. Then the event-clock can be out of sync meaning
that events aren't firing on the root application.

Theoretically this can't reproduce the bug of shifting roots as
the first touch-point into the new Preact root will re-create
with its own root.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-2.72ms - +6.59ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.11ms - +0.04ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.34ms - +0.31ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +0% (-0.13ms - +0.03ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.83ms - +0.44ms)
    preact-local vs preact-main
  • text-update: slower ❌ 1% - 11% (0.01ms - 0.20ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.41ms - +0.41ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -5% - +1% (-1.70ms - +0.23ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -7% - +6% (-0.48ms - +0.38ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +5% (-0.01ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -1% - +1% (-0.04ms - +0.03ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local845.97ms - 851.92ms-unsure 🔍
-0% - +1%
-2.72ms - +6.59ms
preact-main843.42ms - 850.59msunsure 🔍
-1% - +0%
-6.59ms - +2.72ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.20ms - 19.20ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main19.20ms - 19.20msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.56ms - 16.62ms-unsure 🔍
-1% - +0%
-0.11ms - +0.04ms
preact-main16.55ms - 16.70msunsure 🔍
-0% - +1%
-0.04ms - +0.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.57ms - 1.57ms-unsure 🔍
-1% - +0%
-0.01ms - +0.00ms
preact-main1.57ms - 1.58msunsure 🔍
-0% - +1%
-0.00ms - +0.01ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local59.66ms - 60.77ms-unsure 🔍
-2% - +1%
-1.34ms - +0.31ms
preact-main60.12ms - 61.34msunsure 🔍
-1% - +2%
-0.31ms - +1.34ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local6.11ms - 6.72ms-unsure 🔍
-7% - +6%
-0.48ms - +0.38ms
preact-main6.15ms - 6.77msunsure 🔍
-6% - +8%
-0.38ms - +0.48ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.43ms - 16.54ms-unsure 🔍
-1% - +0%
-0.13ms - +0.03ms
preact-main16.47ms - 16.59msunsure 🔍
-0% - +1%
-0.03ms - +0.13ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.73ms - 3.73ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.73ms - 3.73msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5472
  • Commit: 003c43d

duration

VersionAvg timevs preact-localvs preact-main
preact-local59.90ms - 60.42ms-unsure 🔍
-1% - +1%
-0.83ms - +0.44ms
preact-main59.78ms - 60.94msunsure 🔍
-1% - +1%
-0.44ms - +0.83ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.02ms - 3.04ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main3.02ms - 3.04msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.67ms - 26.38ms-slower ❌
0% - 4%
0.02ms - 1.06ms
preact-main25.11ms - 25.86msfaster ✔
0% - 4%
0.02ms - 1.06ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local30.18ms - 31.40ms-unsure 🔍
-4% - +1%
-1.29ms - +0.44ms
preact-main30.60ms - 31.82msunsure 🔍
-1% - +4%
-0.44ms - +1.29ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local30.06ms - 31.08ms-unsure 🔍
-3% - +2%
-0.86ms - +0.56ms
preact-main30.24ms - 31.21msunsure 🔍
-2% - +3%
-0.56ms - +0.86ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local25.76ms - 26.26ms-unsure 🔍
-1% - +2%
-0.16ms - +0.48ms
preact-main25.65ms - 26.05msunsure 🔍
-2% - +1%
-0.48ms - +0.16ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.07ms - 24.28ms-unsure 🔍
-7% - +1%
-1.60ms - +0.24ms
preact-main23.67ms - 25.05msunsure 🔍
-1% - +7%
-0.24ms - +1.60ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.67ms - 21.02ms-unsure 🔍
-1% - +1%
-0.31ms - +0.31ms
preact-main20.60ms - 21.10msunsure 🔍
-1% - +1%
-0.31ms - +0.31ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 220
  • Built by: CI #5472
  • Commit: 003c43d

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.99ms - 2.14ms-slower ❌
1% - 11%
0.01ms - 0.20ms
preact-main1.90ms - 2.01msfaster ✔
1% - 10%
0.01ms - 0.20ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.01ms - 1.06ms-unsure 🔍
-1% - +5%
-0.01ms - +0.05ms
preact-main1.00ms - 1.04msunsure 🔍
-5% - +1%
-0.05ms - +0.01ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local34.80ms - 35.23ms-unsure 🔍
-1% - +1%
-0.41ms - +0.41ms
preact-main34.66ms - 35.37msunsure 🔍
-1% - +1%
-0.41ms - +0.41ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.26ms - 1.26ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.26ms - 1.26msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.87ms - 35.11ms-unsure 🔍
-5% - +1%
-1.70ms - +0.23ms
preact-main34.48ms - 35.96msunsure 🔍
-1% - +5%
-0.23ms - +1.70ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.06ms - 3.11ms-unsure 🔍
-1% - +1%
-0.04ms - +0.03ms
preact-main3.06ms - 3.11msunsure 🔍
-1% - +1%
-0.03ms - +0.04ms
-

tachometer-reporter-action v2 for CI

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Size Change: +202 B (+0.26%)

Total Size: 79 kB

📦 View Changed
Filename Size Change
dist/preact.js 4.76 kB +27 B (+0.57%)
dist/preact.min.js 4.78 kB +29 B (+0.61%)
dist/preact.min.module.js 4.78 kB +28 B (+0.59%)
dist/preact.min.umd.js 4.8 kB +26 B (+0.54%)
dist/preact.mjs 4.78 kB +31 B (+0.65%)
dist/preact.module.js 4.78 kB +31 B (+0.65%)
dist/preact.umd.js 4.8 kB +30 B (+0.63%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.19 kB
compat/dist/compat.mjs 4.11 kB
compat/dist/compat.module.js 4.11 kB
compat/dist/compat.umd.js 4.25 kB
debug/dist/debug.js 3.85 kB
debug/dist/debug.mjs 3.85 kB
debug/dist/debug.module.js 3.85 kB
debug/dist/debug.umd.js 3.93 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.mjs 273 B
devtools/dist/devtools.module.js 273 B
devtools/dist/devtools.umd.js 345 B
hooks/dist/hooks.js 1.52 kB
hooks/dist/hooks.mjs 1.56 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.59 kB
jsx-runtime/dist/jsxRuntime.js 1.01 kB
jsx-runtime/dist/jsxRuntime.mjs 985 B
jsx-runtime/dist/jsxRuntime.module.js 985 B
jsx-runtime/dist/jsxRuntime.umd.js 1.08 kB
test-utils/dist/testUtils.js 473 B
test-utils/dist/testUtils.mjs 477 B
test-utils/dist/testUtils.module.js 477 B
test-utils/dist/testUtils.umd.js 555 B

compressed-size-action

@JoviDeCroock JoviDeCroock force-pushed the create-unique-event-counter-per-preact-instance branch from 5673284 to 127236e Compare March 30, 2026 18:31
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