facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
224.31k stars 45.71k forks source link

compiler: fixture for suboptimal jsx sibling memo block merging #29155

Closed josephsavona closed 3 weeks ago

josephsavona commented 1 month ago

Stack from ghstack (oldest at bottom):

React Compiler attempts to merge consecutive reactive scopes in order to reduce overhead. The basic idea is that if two consecutive scopes would always invalidate together then we should merge them. It gets more complicated, though, because values produced by the earlier scope may not always invalidate when their inputs do. For example, a scope that produces fn(x) may not invalidate on all changes to x if the function is Math.max(x, 10) (changing x from 8 to 9 won't change the output).

Previously we were conservative and only merged if either:

You can see this in the new fixture, where the second <button> gets its own scope, which happens because the preceding scope has an extra output that isn't a dep of the <button>'s scope.

vercel[bot] commented 1 month ago

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 May 21, 2024 0:16am
react-sizebot commented 1 month ago

Comparing: bf046e86531141d0eb9ffc1165f775a57ffb00f5...9c54058a5f4b4df576226079a999f27b1f40b918

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 = 495.71 kB 495.71 kB = 88.78 kB 88.78 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 = 500.51 kB 500.51 kB = 89.47 kB 89.47 kB
facebook-www/ReactDOM-prod.classic.js = 592.86 kB 592.86 kB = 104.28 kB 104.28 kB
facebook-www/ReactDOM-prod.modern.js = 569.08 kB 569.08 kB = 100.69 kB 100.69 kB
__test_utils__/ReactAllWarnings.js Deleted 64.35 kB 0.00 kB Deleted 16.05 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](https://react-builds.vercel.app/commits/9c54058a5f4b4df576226079a999f27b1f40b918/files/__test_utils__/ReactAllWarnings.js?compare=bf046e86531141d0eb9ffc1165f775a57ffb00f5) | **Deleted** | 64.35 kB | 0.00 kB | Deleted | 16.05 kB | 0.00 kB

Generated by :no_entry_sign: dangerJS against 9c54058a5f4b4df576226079a999f27b1f40b918