Skip to content

Conversation

@romgrk
Copy link
Contributor

@romgrk romgrk commented Dec 16, 2025

Summary

Considering that effects are only appended (the list of effects is never mutated in the middle), Array seems like a better fit because it has a better cache locality, and it creates less memory allocations so there's less pressure on the GC.

How did you test this change?

I have tested various benchmarks we have in Base UI and they've shown a fairly small but consistent improvement across the board. I've also spin up this benchmark that puts an extreme focus on effects to illustrate clearly the improvement. The average runtime is consistently lower, but interestingly the standard deviation is also consistently lower, which probably indicates that the garbage collector is doing less pauses (due to the fewer memory allocations).

Before:
image
After:
image

@meta-cla meta-cla bot added the CLA Signed label Dec 16, 2025
@react-sizebot
Copy link

Comparing: 88ee1f5...bb89000

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 608.16 kB 607.82 kB = 107.67 kB 107.62 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 667.39 kB 667.04 kB = 117.55 kB 117.51 kB
facebook-www/ReactDOM-prod.classic.js = 693.47 kB 693.12 kB = 122.05 kB 121.99 kB
facebook-www/ReactDOM-prod.modern.js = 683.89 kB 683.55 kB = 120.43 kB 120.37 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against bb89000

@gaearon
Copy link
Collaborator

gaearon commented Dec 17, 2025

cc @acdlite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants