Commit 5d1b889
committed
[compiler][poc] Quick experiment with SSR-optimization pass (#35102)
Just a quick poc:
* Inline useState when the initializer is known to not be a function.
The heuristic could be improved but will handle a large number of cases
already.
* Prune effects
* Prune useRef if the ref is unused, by pruning 'ref' props on primitive
components. Then DCE does the rest of the work - with a small change to
allow `useRef()` calls to be dropped since function calls aren't
normally eligible for dropping.
* Prune event handlers, by pruning props whose names start w "on" from
primitive components. Then DCE removes the functions themselves.
Per the fixture, this gets pretty far.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35102).
* #35112
* __->__ #35102
DiffTrain build for [4cf770d](4cf770d)1 parent d6637c6 commit 5d1b889
File tree
23 files changed
+516
-88
lines changed- compiled-rn
- facebook-fbsource/xplat/js
- RKJSModules/vendor/react
- react-dom/cjs
- react-test-renderer/cjs
- react/cjs
- react-native-github/Libraries/Renderer
- implementations
- tools/eslint-plugin-react-hooks
- cjs
23 files changed
+516
-88
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
30244 | 30244 | | |
30245 | 30245 | | |
30246 | 30246 | | |
30247 | | - | |
| 30247 | + | |
30248 | 30248 | | |
30249 | 30249 | | |
30250 | 30250 | | |
30251 | | - | |
| 30251 | + | |
30252 | 30252 | | |
30253 | 30253 | | |
30254 | 30254 | | |
| |||
30285 | 30285 | | |
30286 | 30286 | | |
30287 | 30287 | | |
30288 | | - | |
| 30288 | + | |
30289 | 30289 | | |
30290 | 30290 | | |
30291 | | - | |
| 30291 | + | |
30292 | 30292 | | |
30293 | 30293 | | |
30294 | 30294 | | |
| |||
30438 | 30438 | | |
30439 | 30439 | | |
30440 | 30440 | | |
30441 | | - | |
| 30441 | + | |
30442 | 30442 | | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17707 | 17707 | | |
17708 | 17708 | | |
17709 | 17709 | | |
17710 | | - | |
| 17710 | + | |
17711 | 17711 | | |
17712 | 17712 | | |
17713 | 17713 | | |
17714 | 17714 | | |
17715 | 17715 | | |
17716 | 17716 | | |
17717 | | - | |
| 17717 | + | |
17718 | 17718 | | |
17719 | 17719 | | |
17720 | 17720 | | |
| |||
17736 | 17736 | | |
17737 | 17737 | | |
17738 | 17738 | | |
17739 | | - | |
| 17739 | + | |
17740 | 17740 | | |
17741 | 17741 | | |
17742 | | - | |
| 17742 | + | |
17743 | 17743 | | |
17744 | 17744 | | |
17745 | 17745 | | |
| |||
17846 | 17846 | | |
17847 | 17847 | | |
17848 | 17848 | | |
17849 | | - | |
| 17849 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19833 | 19833 | | |
19834 | 19834 | | |
19835 | 19835 | | |
19836 | | - | |
| 19836 | + | |
19837 | 19837 | | |
19838 | 19838 | | |
19839 | 19839 | | |
19840 | 19840 | | |
19841 | 19841 | | |
19842 | 19842 | | |
19843 | | - | |
| 19843 | + | |
19844 | 19844 | | |
19845 | 19845 | | |
19846 | 19846 | | |
| |||
19862 | 19862 | | |
19863 | 19863 | | |
19864 | 19864 | | |
19865 | | - | |
| 19865 | + | |
19866 | 19866 | | |
19867 | 19867 | | |
19868 | | - | |
| 19868 | + | |
19869 | 19869 | | |
19870 | 19870 | | |
19871 | 19871 | | |
| |||
19988 | 19988 | | |
19989 | 19989 | | |
19990 | 19990 | | |
19991 | | - | |
| 19991 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
30306 | 30306 | | |
30307 | 30307 | | |
30308 | 30308 | | |
30309 | | - | |
| 30309 | + | |
30310 | 30310 | | |
30311 | 30311 | | |
30312 | 30312 | | |
30313 | | - | |
| 30313 | + | |
30314 | 30314 | | |
30315 | 30315 | | |
30316 | 30316 | | |
| |||
30347 | 30347 | | |
30348 | 30348 | | |
30349 | 30349 | | |
30350 | | - | |
| 30350 | + | |
30351 | 30351 | | |
30352 | 30352 | | |
30353 | | - | |
| 30353 | + | |
30354 | 30354 | | |
30355 | 30355 | | |
30356 | 30356 | | |
| |||
30816 | 30816 | | |
30817 | 30817 | | |
30818 | 30818 | | |
30819 | | - | |
| 30819 | + | |
30820 | 30820 | | |
30821 | 30821 | | |
30822 | 30822 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17724 | 17724 | | |
17725 | 17725 | | |
17726 | 17726 | | |
17727 | | - | |
| 17727 | + | |
17728 | 17728 | | |
17729 | 17729 | | |
17730 | 17730 | | |
17731 | 17731 | | |
17732 | 17732 | | |
17733 | 17733 | | |
17734 | | - | |
| 17734 | + | |
17735 | 17735 | | |
17736 | 17736 | | |
17737 | 17737 | | |
| |||
17753 | 17753 | | |
17754 | 17754 | | |
17755 | 17755 | | |
17756 | | - | |
| 17756 | + | |
17757 | 17757 | | |
17758 | 17758 | | |
17759 | | - | |
| 17759 | + | |
17760 | 17760 | | |
17761 | 17761 | | |
17762 | 17762 | | |
| |||
18016 | 18016 | | |
18017 | 18017 | | |
18018 | 18018 | | |
18019 | | - | |
| 18019 | + | |
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
19854 | 19854 | | |
19855 | 19855 | | |
19856 | 19856 | | |
19857 | | - | |
| 19857 | + | |
19858 | 19858 | | |
19859 | 19859 | | |
19860 | 19860 | | |
19861 | 19861 | | |
19862 | 19862 | | |
19863 | 19863 | | |
19864 | | - | |
| 19864 | + | |
19865 | 19865 | | |
19866 | 19866 | | |
19867 | 19867 | | |
| |||
19883 | 19883 | | |
19884 | 19884 | | |
19885 | 19885 | | |
19886 | | - | |
| 19886 | + | |
19887 | 19887 | | |
19888 | 19888 | | |
19889 | | - | |
| 19889 | + | |
19890 | 19890 | | |
19891 | 19891 | | |
19892 | 19892 | | |
| |||
20162 | 20162 | | |
20163 | 20163 | | |
20164 | 20164 | | |
20165 | | - | |
| 20165 | + | |
20166 | 20166 | | |
20167 | 20167 | | |
20168 | 20168 | | |
| |||
0 commit comments