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

[Not for Merge] Investigate CI failures on Symbol/Function warning PR #13453

Conversation

nhunzaker
Copy link
Contributor

@nhunzaker nhunzaker commented Aug 21, 2018

#13394 fails CI due to a memory issue. I'm using this PR to slowly peal back the changes and see where the issue might be.

  • Idea 1: The SSR Integration tests are heavy, adding the extra tests is the root of the issue
  • Idea 2: jest.resetModuleRegistry() is the culprit
  • Where is memory usage going?
  • Why are these select tests leaking memory?

Here goes...

@pull-bot
Copy link

pull-bot commented Aug 21, 2018

ReactDOM: size: 🔺+0.2%, gzip: 🔺+0.1%

Details of bundled changes.

Comparing: 146c9fb...7fac775

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js 0.0% -0.0% 651.66 KB 651.9 KB 152.93 KB 152.88 KB UMD_DEV
react-dom.production.min.js 🔺+0.2% 🔺+0.1% 97.25 KB 97.43 KB 31.43 KB 31.47 KB UMD_PROD
react-dom.development.js 0.0% -0.0% 647.8 KB 648.03 KB 151.82 KB 151.77 KB NODE_DEV
react-dom.production.min.js 🔺+0.2% 🔺+0.1% 97.24 KB 97.42 KB 31.04 KB 31.07 KB NODE_PROD
react-dom-server.browser.development.js +0.7% +0.5% 104.21 KB 104.97 KB 27.82 KB 27.97 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+1.9% 🔺+1.4% 15.42 KB 15.71 KB 5.88 KB 5.96 KB UMD_PROD
react-dom-server.browser.development.js +0.8% +0.5% 100.34 KB 101.1 KB 26.84 KB 26.99 KB NODE_DEV
react-dom-server.browser.production.min.js 🔺+2.0% 🔺+1.4% 15.32 KB 15.62 KB 5.82 KB 5.9 KB NODE_PROD
react-dom-server.node.development.js +0.7% +0.5% 102.27 KB 103.02 KB 27.37 KB 27.52 KB NODE_DEV
react-dom-server.node.production.min.js 🔺+1.9% 🔺+1.3% 16.13 KB 16.42 KB 6.13 KB 6.21 KB NODE_PROD
ReactDOM-dev.js 0.0% -0.0% 655.16 KB 655.4 KB 149.96 KB 149.92 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.2% 🔺+0.1% 285.53 KB 285.98 KB 53.06 KB 53.1 KB FB_WWW_PROD
ReactDOMServer-dev.js +0.8% +0.6% 101.48 KB 102.25 KB 26.52 KB 26.67 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+1.9% 🔺+1.5% 33.27 KB 33.91 KB 8.03 KB 8.15 KB FB_WWW_PROD
react-dom.profiling.min.js +0.2% +0.2% 98.45 KB 98.62 KB 31.43 KB 31.48 KB NODE_PROFILING
ReactDOM-profiling.js +0.2% +0.1% 287.97 KB 288.41 KB 53.7 KB 53.74 KB FB_WWW_PROFILING

Generated by 🚫 dangerJS

@nhunzaker nhunzaker changed the title [Not for Merge] Investigate CI failures on [Not for Merge] Investigate CI failures on Symbol/Function warning PR Aug 21, 2018
@gaearon
Copy link
Collaborator

gaearon commented Aug 21, 2018

I might be worth merging some SSR integration tests together. Each individual test case generates 4 Jest tests. I think they're unnecessarily isolated right now. Maybe we can have less tests where each test checks more than a single property.

@nhunzaker
Copy link
Contributor Author

That seems like it's the way to go. I still need to trace memory allocation, but most of the execution time cost of these tests seems to be the result of calling jest.resetModuleRegistry(), which gets called about 300 times over the course of the Form SSR integration tests alone.

Consolidating similar tests is probably the easiest fix, but I'm going to also try to gather some more info about memory to see if there's a more systemic fix.

@gaearon
Copy link
Collaborator

gaearon commented Aug 29, 2018

We’ve talked more with @sebmarkbage about this and he raised a good point.

It seems like overall treating them consistently is adding significant overhead in the implementation readability. And there’s undoubtedly runtime overhead to it too. However we already warn about those cases.

So what if we pivot into the opposite direction? For bad inputs, ensure we warn — and do the least amount of work possible. It doesn’t have to be consistent if we print a warning, and we reserve the right to change warned-about behavior between patch versions.

In that world, what would an ideal implementation look like?

@nhunzaker
Copy link
Contributor Author

Ahh neat, @rickhanlonii added a memory leak feature to Jest and, indeed, something is leaking. This is the best!

@nhunzaker
Copy link
Contributor Author

I might be thinking too narrowly about this, but I think a good step towards "least amount of work" could be to move property warnings into single call upfront, like where validatePropertiesInDevelopment lives in this PR.

Working on this code, dealing with validators later in the renderer was the biggest source of frustration. For example: when does a textarea validate on value vs the children prop? Why does that happen in two different places?

Having a clear validation step up could mitigate a lot of that.

@nhunzaker
Copy link
Contributor Author

Beyond that, for the purposes of the SSR tests, it seems like jest.resetModuleRegistry() gets called exclusively to reset warnings. This is a significant cost! I wonder what execution time improvements could be made by having a warning module that was easy to reset.

@nhunzaker
Copy link
Contributor Author

Looks like Jest thinks that there is a memory leak in the dangerouslySetInnerHTML tests for selects.

| `defaultValue=(null)`| (initial, ssr warning)| `<empty string>` |
| `defaultValue=(symbol)`| (initial, warning)| `<empty string>` |
| `defaultValue=(function)`| (initial, warning)| `<empty string>` |
| `defaultValue=(null)`| (initial)| `<empty string>` |
| `defaultValue=(undefined)`| (initial)| `<empty string>` |

## `defaultValuE` (on `<input>` inside `<div>`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Noticed the capital e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is intentional, to catch bad casing of defaultValue.

@nhunzaker
Copy link
Contributor Author

I think I've found the memory leak, there's some shared code in the closures for https://github.com/facebook/react/blob/master/packages/react-dom/src/__tests__/utils/ReactDOMServerIntegrationTestUtils.js#L263-L285. I'm going to see if I can stamp it out.

Also I'll close this out. I think I have a good direction, and I don't need to blast CI :)

@nhunzaker nhunzaker closed this Aug 31, 2018
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.

5 participants