Skip to content

Commit 73378c9

Browse files
authored
[Fiber] Performance measurements (#9071)
* wip * better * better * track commits * better * wip * Fix * Add some lifecycles * wip * Naming * Moar emojis * Remove stacks in favor of a flag * Fix Flow * Gate behind __DEV__ * Revert flag for testing * Measure all lifecycles * Push it to the limits * Polish * Indent * Refactor and track cascading updates * More prominent warnings * Make mark names themselves readable This is useful for RN Systrace which doesn't let us assign labels after the fact. * Keep track of how many effects we call * Fix typo * Do less work to reduce the overhead * Fix lint * Remove closure * Remove unintentional formatting changes * Add tests * Fix test regex and record tests * Disable irrelevant tests needed for ReactPerf * Fix typo * Fix lint and flow * Don't treat cWM or cWRP as cascading * Whitespace * Update tests * Gate callComponentWillUnmountWithTimerInDev definition by DEV
1 parent 4e9d7ac commit 73378c9

17 files changed

+1593
-427
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"./scripts/jest/environment.js"
108108
],
109109
"setupTestFrameworkScriptFile": "./scripts/jest/test-framework-setup.js",
110-
"testRegex": "/__tests__/",
110+
"testRegex": "/__tests__/.*(\\.js|coffee|ts)$",
111111
"moduleFileExtensions": [
112112
"js",
113113
"json",

scripts/fiber/tests-failing.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
22
* should pass previous context to lifecycles
33

4-
src/renderers/__tests__/ReactComponentTreeHook-test.js
5-
* can be retrieved by ID
6-
7-
src/renderers/__tests__/ReactHostOperationHistoryHook-test.js
8-
* gets recorded during an update
9-
10-
src/renderers/__tests__/ReactPerf-test.js
11-
* should count no-op update as waste
12-
* should count no-op update in child as waste
13-
* should include stats for components unmounted during measurement
14-
* should include lifecycle methods in measurements
15-
* should include render time of functional components
16-
* should not count time in a portal towards lifecycle method
17-
* should work when measurement starts during reconciliation
18-
194
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
205
* gives source code refs for unknown prop warning (ssr)
216
* gives source code refs for unknown prop warning for exact elements (ssr)

scripts/fiber/tests-passing-except-dev.txt

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,3 @@
1-
src/renderers/__tests__/ReactComponentTreeHook-test.js
2-
* uses displayName or Unknown for classic components
3-
* uses displayName, name, or ReactComponent for modern components
4-
* uses displayName, name, or Object for factory components
5-
* uses displayName, name, or StatelessComponent for functional components
6-
* reports a host tree correctly
7-
* reports a simple tree with composites correctly
8-
* reports a tree with composites correctly
9-
* ignores null children
10-
* ignores false children
11-
* reports text nodes as children
12-
* reports a single text node as a child
13-
* reports a single number node as a child
14-
* reports a zero as a child
15-
* skips empty nodes for multiple children
16-
* reports html content as no children
17-
* updates text of a single text child
18-
* updates from no children to a single text child
19-
* updates from a single text child to no children
20-
* updates from html content to a single text child
21-
* updates from a single text child to html content
22-
* updates from no children to multiple text children
23-
* updates from multiple text children to no children
24-
* updates from html content to multiple text children
25-
* updates from multiple text children to html content
26-
* updates from html content to no children
27-
* updates from no children to html content
28-
* updates from one text child to multiple text children
29-
* updates from multiple text children to one text child
30-
* updates text nodes when reordering
31-
* updates host nodes when reordering with keys
32-
* updates host nodes when reordering without keys
33-
* updates a single composite child of a different type
34-
* updates a single composite child of the same type
35-
* updates from no children to a single composite child
36-
* updates from a single composite child to no children
37-
* updates mixed children
38-
* updates with a host child
39-
* updates from null to a host child
40-
* updates from a host child to null
41-
* updates from a host child to a composite child
42-
* updates from a composite child to a host child
43-
* updates from null to a composite child
44-
* updates from a composite child to null
45-
* updates with a host child
46-
* updates from null to a host child
47-
* updates from a host child to null
48-
* updates from a host child to a composite child
49-
* updates from a composite child to a host child
50-
* updates from null to a composite child
51-
* updates from a composite child to null
52-
* tracks owner correctly
53-
* purges unmounted components automatically
54-
* reports update counts
55-
* does not report top-level wrapper as a root
56-
* registers inlined text nodes
57-
* works
58-
59-
src/renderers/__tests__/ReactComponentTreeHook-test.native.js
60-
* uses displayName or Unknown for classic components
61-
* uses displayName, name, or ReactComponent for modern components
62-
* uses displayName, name, or Object for factory components
63-
* uses displayName, name, or StatelessComponent for functional components
64-
* reports a host tree correctly
65-
* reports a simple tree with composites correctly
66-
* reports a tree with composites correctly
67-
* ignores null children
68-
* ignores false children
69-
* reports text nodes as children
70-
* reports a single text node as a child
71-
* reports a single number node as a child
72-
* reports a zero as a child
73-
* skips empty nodes for multiple children
74-
* updates text of a single text child
75-
* updates from no children to a single text child
76-
* updates from a single text child to no children
77-
* updates from no children to multiple text children
78-
* updates from multiple text children to no children
79-
* updates from one text child to multiple text children
80-
* updates from multiple text children to one text child
81-
* updates text nodes when reordering
82-
* updates host nodes when reordering with keys
83-
* updates host nodes when reordering with keys
84-
* updates a single composite child of a different type
85-
* updates a single composite child of the same type
86-
* updates from no children to a single composite child
87-
* updates from a single composite child to no children
88-
* updates mixed children
89-
* updates with a host child
90-
* updates from null to a host child
91-
* updates from a host child to null
92-
* updates from a host child to a composite child
93-
* updates from a composite child to a host child
94-
* updates from null to a composite child
95-
* updates from a composite child to null
96-
* updates with a host child
97-
* updates from null to a host child
98-
* updates from a host child to null
99-
* updates from a host child to a composite child
100-
* updates from a composite child to a host child
101-
* updates from null to a composite child
102-
* updates from a composite child to null
103-
* tracks owner correctly
104-
* purges unmounted components automatically
105-
* reports update counts
106-
* does not report top-level wrapper as a root
107-
108-
src/renderers/__tests__/ReactHostOperationHistoryHook-test.js
109-
* gets recorded for host roots
110-
* gets recorded for composite roots
111-
* gets recorded when a native is mounted deeply instead of null
112-
* gets recorded during mount
113-
* gets recorded during an update
114-
* gets ignored if the styles are shallowly equal
115-
* gets recorded during mount
116-
* gets recorded during mount
117-
* gets recorded during mount
118-
* gets recorded during an update from text content
119-
* gets recorded during an update from html
120-
* gets recorded during an update from children
121-
* gets recorded when composite renders to a different type
122-
* gets recorded when composite renders to null after a native
123-
* gets recorded during an update from text content
124-
* gets recorded during an update from html
125-
* gets recorded during an update from children
126-
* gets reported when a child is inserted
127-
* gets reported when a child is inserted
128-
* gets reported when a child is removed
129-
1301
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
1312
* should not warn when server-side rendering `onScroll`
1323
* should warn about incorrect casing on properties (ssr)

scripts/fiber/tests-passing.txt

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,6 @@ src/renderers/__tests__/ReactComponentLifeCycle-test.js
561561

562562
src/renderers/__tests__/ReactComponentTreeHook-test.js
563563
* gets created
564-
* is created during mounting
565-
* is created when calling renderToString during render
566564

567565
src/renderers/__tests__/ReactCompositeComponent-test.js
568566
* should support module pattern components
@@ -673,17 +671,6 @@ src/renderers/__tests__/ReactErrorBoundaries-test.js
673671
* renders empty output if error boundary does not handle the error
674672
* passes first error when two errors happen in commit
675673

676-
src/renderers/__tests__/ReactHostOperationHistoryHook-test.js
677-
* gets ignored for composite roots that return null
678-
* gets recorded during an update
679-
* gets recorded as a removal during an update
680-
* gets recorded during an update
681-
* gets recorded during an update
682-
* gets ignored if new text is equal
683-
* gets ignored if new text is equal
684-
* gets ignored if the type has not changed
685-
* gets ignored if new html is equal
686-
687674
src/renderers/__tests__/ReactIdentity-test.js
688675
* should allow key property to express identity
689676
* should use composite identity
@@ -750,33 +737,6 @@ src/renderers/__tests__/ReactMultiChildText-test.js
750737
* should throw if rendering both HTML and children
751738
* should render between nested components and inline children
752739

753-
src/renderers/__tests__/ReactPerf-test.js
754-
* should not count initial render as waste
755-
* should not count unmount as waste
756-
* should not count content update as waste
757-
* should not count child addition as waste
758-
* should not count child removal as waste
759-
* should not count property update as waste
760-
* should not count style update as waste
761-
* should not count property removal as waste
762-
* should not count raw HTML update as waste
763-
* should not count child reordering as waste
764-
* should not count text update as waste
765-
* should not count replacing null with a host as waste
766-
* should not count replacing a host with null as waste
767-
* warns once when using getMeasurementsSummaryMap
768-
* warns once when using printDOM
769-
* returns isRunning state
770-
* start has no effect when already running
771-
* stop has no effect when already stopped
772-
* should print console error only once
773-
* should not print errant warnings if render() throws
774-
* should not print errant warnings if componentWillMount() throws
775-
* should not print errant warnings if componentDidMount() throws
776-
* should not print errant warnings if portal throws in render()
777-
* should not print errant warnings if portal throws in componentWillMount()
778-
* should not print errant warnings if portal throws in componentDidMount()
779-
780740
src/renderers/__tests__/ReactStatelessComponent-test.js
781741
* should render stateless component
782742
* should update stateless component
@@ -1565,6 +1525,21 @@ src/renderers/shared/fiber/__tests__/ReactIncrementalErrorHandling-test.js
15651525
* should ignore errors thrown in log method to prevent cycle
15661526
* should relay info about error boundary and retry attempts if applicable
15671527

1528+
src/renderers/shared/fiber/__tests__/ReactIncrementalPerf-test.js
1529+
* measures a simple reconciliation
1530+
* skips parents during setState
1531+
* warns on cascading renders from setState
1532+
* warns on cascading renders from top-level render
1533+
* does not treat setState from cWM or cWRP as cascading
1534+
* captures all lifecycles
1535+
* measures deprioritized work
1536+
* measures deferred work in chunks
1537+
* recovers from fatal errors
1538+
* recovers from caught errors
1539+
* deduplicates lifecycle names during commit to reduce overhead
1540+
* supports coroutines
1541+
* supports portals
1542+
15681543
src/renderers/shared/fiber/__tests__/ReactIncrementalReflection-test.js
15691544
* handles isMounted even when the initial render is deferred
15701545
* handles isMounted when an unmount is deferred

0 commit comments

Comments
 (0)