react icon indicating copy to clipboard operation
react copied to clipboard

compiler: fixture for suboptimal jsx sibling memo block merging

Open josephsavona opened this issue 1 year ago • 2 comments

Stack from ghstack (oldest at bottom):

  • #29197
  • #29157
  • #29156
  • -> #29155

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:

  • the two scopes had the same dependencies
  • the second scope's deps exactly matched the previous scope's outputs.

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.

josephsavona avatar May 17 '24 23:05 josephsavona

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

vercel[bot] avatar May 17 '24 23:05 vercel[bot]

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 Deleted 64.35 kB 0.00 kB Deleted 16.05 kB 0.00 kB

Generated by :no_entry_sign: dangerJS against 9c54058a5f4b4df576226079a999f27b1f40b918

react-sizebot avatar May 17 '24 23:05 react-sizebot