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

Add enableShallowPropDiffing feature flag #29664

Conversation

dmytrorykun
Copy link
Contributor

Summary

We currently do deep diffing for object props, and also use custom differs, if they are defined, for props with custom attribute config.

The idea is to simply do a === comparison instead of all that work. We will do less computation on the JS side, but send more data to native.

The hypothesis is that this change should be neutral in terms of performance. If that's the case, we'll be able to get rid of custom differs, and be one step closer to deleting view configs.

This PR adds the enableShallowPropDiffing feature flag to support this experiment.

How did you test this change?

With enableShallowPropDiffing hardcoded to true:

yarn test packages/react-native-renderer

This fails on the following test cases:

  • should use the diff attribute
  • should do deep diffs of Objects by default
  • should skip deeply-nested changed functions

Which makes sense with this change. These test cases should be deleted if the experiment is shipped.

Copy link

vercel bot commented May 30, 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 Jun 5, 2024 8:19am

@dmytrorykun dmytrorykun changed the title Add enableShallowPropDiffing feature flag. Add enableShallowPropDiffing feature flag May 30, 2024
@react-sizebot
Copy link

react-sizebot commented May 30, 2024

Comparing: 1df34bd...3a1eb45

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.66 kB 6.66 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.26 kB 497.26 kB = 89.11 kB 89.11 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.08 kB 502.08 kB = 89.80 kB 89.80 kB
facebook-www/ReactDOM-prod.classic.js = 594.56 kB 594.56 kB = 104.72 kB 104.72 kB
facebook-www/ReactDOM-prod.modern.js = 570.95 kB 570.95 kB = 101.13 kB 101.13 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 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 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against 3a1eb45

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

With enableShallowPropDiffing hardcoded to true

If those test fail, then we need to make sure there is a testing variant that runs then, so we can add the @gate !enableShallowPropDiffing to disable those tests when this flag is on. As it stands, none of the tests seem to be running with this flag enabled, so there's no coverage for it.

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

See above comment

@rickhanlonii
Copy link
Member

@dmytrorykun sorry I wasn't clear, just adding the gate pragma isn't sufficient. The issue is that there are no test variants running with the feature flag enabled. If you hardcode it to true, you'll see this test failure:

Screenshot 2024-05-31 at 12 02 26 PM

This shows that one of the tests you gated actually passes when the flag is enabled (which we fail for, gate tests must fail if the condition isn't met). This doesn't fail on the PR, because the test is not running when this flag is enabled.

I can help creating a test variant that runs when the variant is enabled.

@rickhanlonii
Copy link
Member

PR for xplat test variants: #29734

rickhanlonii added a commit that referenced this pull request Jun 4, 2024
## Overview

We didn't have any tests that ran in persistent mode with the xplat
feature flags (for either variant).

As a result, invalid test gating like in
#29664 were not caught.

This PR adds test flavors for `ReactFeatureFlag-native-fb.js` in both
variants.
github-actions bot pushed a commit that referenced this pull request Jun 4, 2024
## Overview

We didn't have any tests that ran in persistent mode with the xplat
feature flags (for either variant).

As a result, invalid test gating like in
#29664 were not caught.

This PR adds test flavors for `ReactFeatureFlag-native-fb.js` in both
variants.

DiffTrain build for commit eabb681.
Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for waiting for the tests to be fixed.

@dmytrorykun dmytrorykun merged commit eb259b5 into facebook:main Jun 5, 2024
44 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
## Summary

We currently do deep diffing for object props, and also use custom
differs, if they are defined, for props with custom attribute config.

The idea is to simply do a `===` comparison instead of all that work. We
will do less computation on the JS side, but send more data to native.

The hypothesis is that this change should be neutral in terms of
performance. If that's the case, we'll be able to get rid of custom
differs, and be one step closer to deleting view configs.

This PR adds the `enableShallowPropDiffing` feature flag to support this
experiment.

## How did you test this change?

With `enableShallowPropDiffing` hardcoded to `true`:
```
yarn test packages/react-native-renderer
```
This fails on the following test cases:
- should use the diff attribute
- should do deep diffs of Objects by default
- should skip deeply-nested changed functions

Which makes sense with this change. These test cases should be deleted
if the experiment is shipped.

DiffTrain build for [eb259b5](eb259b5)
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
## Summary

We currently do deep diffing for object props, and also use custom
differs, if they are defined, for props with custom attribute config.

The idea is to simply do a `===` comparison instead of all that work. We
will do less computation on the JS side, but send more data to native.

The hypothesis is that this change should be neutral in terms of
performance. If that's the case, we'll be able to get rid of custom
differs, and be one step closer to deleting view configs.

This PR adds the `enableShallowPropDiffing` feature flag to support this
experiment.

## How did you test this change?

With `enableShallowPropDiffing` hardcoded to `true`:
```
yarn test packages/react-native-renderer
```
This fails on the following test cases:
- should use the diff attribute
- should do deep diffs of Objects by default
- should skip deeply-nested changed functions

Which makes sense with this change. These test cases should be deleted
if the experiment is shipped.

DiffTrain build for commit eb259b5.
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.

4 participants