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

Experiment with using an object literal for Fiber creation #28734

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kassens
Copy link
Member

@kassens kassens commented Apr 3, 2024

Experiment with using an object literal for Fiber creation

Object literals should be faster at least on React Native with Hermes as the JS engine.
It might also be interesting to confirm the old comments in this file from years ago are even still valid. Creating an object from a literal should be a simpler operation.

It's a bit unfortunate that this introduces a bunch of copied code, but since we rearely update the fields on fibers, this seems like an okay tradeoff for a hot code path. An alternative would be some sort of macro system, but that doesn't seem worth the extra complexity.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 3, 2024
@kassens kassens force-pushed the pr28734 branch 2 times, most recently from 834d891 to 16e5343 Compare April 3, 2024 18:08
@react-sizebot
Copy link

react-sizebot commented Apr 3, 2024

Comparing: 20e710a...6aee07c

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.min.js = 169.31 kB 169.31 kB = 52.76 kB 52.76 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 171.13 kB 171.13 kB = 53.32 kB 53.33 kB
facebook-www/ReactDOM-prod.classic.js +0.04% 588.80 kB 589.01 kB +0.03% 103.63 kB 103.66 kB
facebook-www/ReactDOM-prod.modern.js +0.04% 565.82 kB 566.04 kB +0.03% 99.54 kB 99.57 kB
test_utils/ReactAllWarnings.js Deleted 64.21 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 64.21 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Generated by 🚫 dangerJS against 6aee07c

@kassens kassens marked this pull request as ready for review April 3, 2024 18:29
@josephsavona
Copy link
Contributor

Awesome! It definitely makes sense to proceed if we can confirm that this is a perf win on Hermes. It should be given our earlier profiling results but let's check first?

Object literals should be faster at least on React Native with Hermes as the JS engine.
It might also be interesting to confirm the old comments in this file from years ago are even still valid. Creating an object from a literal should be a simpler operation.

It's a bit unfortunate that this introduces a bunch of copied code, but since we rearely update the fields on fibers, this seems like an okay tradeoff for a hot code path. An alternative would be some sort of macro system, but that doesn't seem worth the extra complexity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants