Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf: created NULL constant #4682

Merged
merged 2 commits into from
Feb 18, 2025
Merged

Conversation

Ben-Brady
Copy link
Contributor

Slightly reduced output size by creating a constant for null (NULL), so that the bunder can reduce the size of null uses. This is similar to the existing UNDEFINED constant.

Also something I noticed was that in the module build, both the NULL and UNDEFINED constants are outlined. This isn't the same in the UMD buid, where they are properly substitued for variables.

You can quickly test this by loking for null or void 0 literals in the output, for preact.min.js and preact.min.umd.js there's only 2 instances, but for preact.min.module.js there's 97. I'm not sure what's causing this behaviour, whether if it's a correctness thing or just a weird build result.

Copy link

github-actions bot commented Feb 18, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +1% (-8.47ms - +7.74ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +3% (-0.02ms - +0.51ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +1% (-0.48ms - +0.45ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +2% (-0.12ms - +0.30ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +0% (-1.47ms - +0.32ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -1% - +5% (-0.02ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -2% - +1% (-0.65ms - +0.25ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -3% - +4% (-1.01ms - +1.15ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -3% - +1% (-0.04ms - +0.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +6% (-0.14ms - +0.61ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +0% (-0.02ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 +0% - +0% (+0.00ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +3% (-0.02ms - +0.03ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -1% - +1% (-0.02ms - +0.04ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local932.50ms - 942.02ms-unsure 🔍
-1% - +1%
-8.47ms - +7.74ms
preact-main931.06ms - 944.19msunsure 🔍
-1% - +1%
-7.74ms - +8.47ms
-

usedJSHeapSize

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.56ms - 17.09ms-unsure 🔍
-0% - +3%
-0.02ms - +0.51ms
preact-main16.53ms - 16.62msunsure 🔍
-3% - +0%
-0.51ms - +0.02ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.53ms - 1.56ms-unsure 🔍
-3% - +1%
-0.04ms - +0.01ms
preact-main1.54ms - 1.58msunsure 🔍
-1% - +3%
-0.01ms - +0.04ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local73.38ms - 74.08ms-unsure 🔍
-1% - +1%
-0.48ms - +0.45ms
preact-main73.44ms - 74.05msunsure 🔍
-1% - +1%
-0.45ms - +0.48ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local9.70ms - 10.22ms-unsure 🔍
-1% - +6%
-0.14ms - +0.61ms
preact-main9.46ms - 10.00msunsure 🔍
-6% - +1%
-0.61ms - +0.14ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.41ms - 16.81ms-unsure 🔍
-1% - +2%
-0.12ms - +0.30ms
preact-main16.45ms - 16.59msunsure 🔍
-2% - +1%
-0.30ms - +0.12ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.75ms - 3.77ms-unsure 🔍
-1% - +0%
-0.02ms - +0.01ms
preact-main3.76ms - 3.78msunsure 🔍
-0% - +1%
-0.01ms - +0.02ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local66.24ms - 67.50ms-unsure 🔍
-2% - +0%
-1.47ms - +0.32ms
preact-main66.81ms - 68.08msunsure 🔍
-0% - +2%
-0.32ms - +1.47ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.97ms - 2.98ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-main2.97ms - 2.97msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local30.14ms - 31.04ms-unsure 🔍
-1% - +3%
-0.27ms - +0.93ms
preact-main29.87ms - 30.65msunsure 🔍
-3% - +1%
-0.93ms - +0.27ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.76ms - 34.85ms-unsure 🔍
-3% - +2%
-0.95ms - +0.69ms
preact-main33.82ms - 35.05msunsure 🔍
-2% - +3%
-0.69ms - +0.95ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local26.14ms - 27.19ms-unsure 🔍
-1% - +3%
-0.26ms - +0.88ms
preact-main26.14ms - 26.58msunsure 🔍
-3% - +1%
-0.88ms - +0.26ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.13ms - 27.35ms-unsure 🔍
-3% - +4%
-0.76ms - +0.93ms
preact-main26.06ms - 27.25msunsure 🔍
-3% - +3%
-0.93ms - +0.76ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local26.04ms - 27.39ms-unsure 🔍
-4% - +2%
-1.14ms - +0.62ms
preact-main26.41ms - 27.53msunsure 🔍
-2% - +4%
-0.62ms - +1.14ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.39ms - 20.94ms-unsure 🔍
-3% - +1%
-0.60ms - +0.16ms
preact-main20.63ms - 21.14msunsure 🔍
-1% - +3%
-0.16ms - +0.60ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 220
  • Built by: CI #4432
  • Commit: b64a7b7

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.06ms - 2.14ms-unsure 🔍
-1% - +5%
-0.02ms - +0.10ms
preact-main2.01ms - 2.11msunsure 🔍
-5% - +1%
-0.10ms - +0.02ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.12ms - 1.12ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main1.12ms - 1.12msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.82ms - 34.40ms-unsure 🔍
-2% - +1%
-0.65ms - +0.25ms
preact-main33.96ms - 34.65msunsure 🔍
-1% - +2%
-0.25ms - +0.65ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.23ms - 1.27ms-unsure 🔍
-1% - +3%
-0.02ms - +0.03ms
preact-main1.23ms - 1.26msunsure 🔍
-3% - +1%
-0.03ms - +0.02ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.07ms - 31.53ms-unsure 🔍
-3% - +4%
-1.01ms - +1.15ms
preact-main29.94ms - 31.52msunsure 🔍
-4% - +3%
-1.15ms - +1.01ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.94ms - 2.98ms-unsure 🔍
-1% - +1%
-0.02ms - +0.04ms
preact-main2.94ms - 2.97msunsure 🔍
-1% - +1%
-0.04ms - +0.02ms
-

tachometer-reporter-action v2 for CI

@coveralls
Copy link

Coverage Status

coverage: 99.609% (-0.009%) from 99.618%
when pulling b64a7b7 on Ben-Brady:null-constant
into 501d7e6 on preactjs:main.

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.

Nice golfing!


Size Change: -56 B (-0.07%)

Total Size: 78.3 kB

Filename Size Change
dist/preact.min.js 4.71 kB -14 B (-0.3%)
dist/preact.min.umd.js 4.74 kB -14 B (-0.29%)
dist/preact.umd.js 4.74 kB -28 B (-0.59%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.12 kB
compat/dist/compat.mjs 4.05 kB
compat/dist/compat.module.js 4.05 kB
compat/dist/compat.umd.js 4.19 kB
debug/dist/debug.js 3.83 kB
debug/dist/debug.mjs 3.83 kB
debug/dist/debug.module.js 3.83 kB
debug/dist/debug.umd.js 3.91 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.mjs 274 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 346 B
dist/preact.js 4.71 kB
dist/preact.min.module.js 4.73 kB
dist/preact.mjs 4.72 kB
dist/preact.module.js 4.72 kB
hooks/dist/hooks.js 1.54 kB
hooks/dist/hooks.mjs 1.57 kB
hooks/dist/hooks.module.js 1.57 kB
hooks/dist/hooks.umd.js 1.61 kB
jsx-runtime/dist/jsxRuntime.js 978 B
jsx-runtime/dist/jsxRuntime.mjs 952 B
jsx-runtime/dist/jsxRuntime.module.js 952 B
jsx-runtime/dist/jsxRuntime.umd.js 1.05 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


I wouldn't pay much mind to the .min builds, I don't think they've ever been set up right.

@rschristian rschristian merged commit 44ef318 into preactjs:main Feb 18, 2025
13 checks passed
@JoviDeCroock JoviDeCroock mentioned this pull request Feb 18, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants