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

[Fiber] Set profiler values to doubles #30942

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Sep 11, 2024

At some point this trick was added to initialize the value first to NaN and then replace them with zeros and negative ones.

This is to address the issue noted in #14365 where these hidden classes can be initialized to SMIs at first and then deopt when we realize they're actually doubles.

However, this fix has been long broken and has deopted the profiling build for years because closure compiler optimizes out the first write.

I'm not sure because I haven't A/B-tested this in the JIT yet but I think we can use negative zero and -1.1 as the initial values instead since they're not simple integers. Negative zero === zero (but not Object.is) so is the same as far as our code is concerned. The negative value is just < 0 comparisons.

Copy link

vercel bot commented Sep 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 11, 2024 0:33am

@react-sizebot
Copy link

Comparing: bac33d1...2dff09c

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.68 kB 6.68 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 505.22 kB 505.22 kB = 90.29 kB 90.29 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 512.56 kB 512.56 kB = 91.52 kB 91.52 kB
facebook-www/ReactDOM-prod.classic.js = 600.88 kB 600.88 kB = 106.29 kB 106.29 kB
facebook-www/ReactDOM-prod.modern.js = 577.17 kB 577.17 kB = 102.43 kB 102.43 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 87b3818

@rickhanlonii
Copy link
Member

I've also noticed that the effects in the profiling builds are like 2x as slow or more because of the time spent in the recordLayoutEffectsDuration and recordLayoutEffectsDuration functions

function recordLayoutEffectDuration(fiber: Fiber): void {

I assumed that this is because we're searching back up the tree for the Profiler component to store the duration on, but would this also depot, because this.stateNode.effectDuration isn't defined until it's dynamically set:

fiber.stateNode = {
effectDuration: 0,
passiveEffectDuration: 0,
};

@sebmarkbage
Copy link
Collaborator Author

The stateNode is always created as a pointer field in createFiber. It’s just updated later. So that should be fine.

Copy link
Member

@kassens kassens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Build diff view doesn't load (500) but your description makes sense.

@sebmarkbage sebmarkbage merged commit 94e4aca into facebook:main Sep 13, 2024
184 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 13, 2024
At some point this trick was added to initialize the value first to NaN
and then replace them with zeros and negative ones.

This is to address the issue noted in
#14365 where these hidden
classes can be initialized to SMIs at first and then deopt when we
realize they're actually doubles.

However, this fix has been long broken and has deopted the profiling
build for years because closure compiler optimizes out the first write.

I'm not sure because I haven't A/B-tested this in the JIT yet but I
think we can use negative zero and -1.1 as the initial values instead
since they're not simple integers. Negative zero `===` zero (but not
Object.is) so is the same as far as our code is concerned. The negative
value is just `< 0` comparisons.

DiffTrain build for commit 94e4aca.
github-actions bot pushed a commit that referenced this pull request Sep 13, 2024
At some point this trick was added to initialize the value first to NaN
and then replace them with zeros and negative ones.

This is to address the issue noted in
#14365 where these hidden
classes can be initialized to SMIs at first and then deopt when we
realize they're actually doubles.

However, this fix has been long broken and has deopted the profiling
build for years because closure compiler optimizes out the first write.

I'm not sure because I haven't A/B-tested this in the JIT yet but I
think we can use negative zero and -1.1 as the initial values instead
since they're not simple integers. Negative zero `===` zero (but not
Object.is) so is the same as far as our code is concerned. The negative
value is just `< 0` comparisons.

DiffTrain build for [94e4aca](94e4aca)
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.

5 participants