Commit 4edc33e
Refactor implementation of performance.mark and performance.measure (#52586)
Summary:
Pull Request resolved: #52586
Changelog: [internal]
This fixes a "bug" (or spec-compliance issue) in the `performance.measure` method where `end` and `duration` couldn't be used together (only `start` and `duration`, and `start` and `end` could be used).
This also refactors the API to be "JS-first", preparing the native module methods to support passing instances of entries to fix other issues.
Verified performance impact: `mark` is slightly regressed (~7% slower) due to an additional JSI call to get the default start time and `measure` is significantly optimized (25/30% faster) due to simplified parameter handling in JSI calls.
* Before
| (index) | Task name | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0 | 'mark (default)' | '1621.03 ± 1.17%' | '1562.00' | '636986 ± 0.01%' | '640205' | 616890 |
| 1 | 'mark (with custom startTime)' | '1756.88 ± 1.15%' | '1693.00' | '586826 ± 0.01%' | '590667' | 569190 |
| 2 | 'measure (default)' | '2424.66 ± 1.35%' | '2333.00' | '426122 ± 0.02%' | '428633' | 412429 |
| 3 | 'measure (with start and end timestamps)' | '2679.96 ± 1.23%' | '2574.00' | '385266 ± 0.02%' | '388500' | 373140 |
| 4 | 'measure (with mark names)' | '2713.49 ± 0.50%' | '2644.00' | '375383 ± 0.02%' | '378215' | 368530 |
| 5 | 'clearMarks' | '691.13 ± 0.07%' | '681.00' | '1467016 ± 0.01%' | '1468429' | 1446900 |
| 6 | 'clearMeasures' | '706.00 ± 0.05%' | '691.00' | '1431489 ± 0.01%' | '1447178' | 1416435 |
| 7 | 'mark + clearMarks' | '2083.21 ± 1.14%' | '2003.00' | '497974 ± 0.01%' | '499251' | 480028 |
| 8 | 'measure + clearMeasures (with start and end timestamps)' | '3085.14 ± 0.88%' | '2974.00' | '334337 ± 0.02%' | '336247' | 324135 |
| 9 | 'measure + clearMeasures (with mark names)' | '2949.45 ± 0.62%' | '2884.00' | '345335 ± 0.02%' | '346741' | 339046 |
* After
| (index) | Task name | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0 | 'mark (default)' | '1740.06 ± 1.01%' | '1692.00' | '587400 ± 0.01%' | '591017' | 574695 |
| 1 | 'mark (with custom startTime)' | '1661.64 ± 1.16%' | '1612.00' | '617453 ± 0.01%' | '620347' | 601815 |
| 2 | 'measure (default)' | '1808.71 ± 1.28%' | '1753.00' | '566516 ± 0.01%' | '570451' | 552882 |
| 3 | 'measure (with start and end timestamps)' | '1869.21 ± 1.00%' | '1823.00' | '546571 ± 0.01%' | '548546' | 534987 |
| 4 | 'measure (with mark names)' | '2016.40 ± 0.74%' | '1983.00' | '502987 ± 0.01%' | '504286' | 496075 |
| 5 | 'clearMarks' | '682.18 ± 0.03%' | '671.00' | '1476364 ± 0.01%' | '1490313' | 1465899 |
| 6 | 'clearMeasures' | '686.78 ± 0.03%' | '681.00' | '1467264 ± 0.01%' | '1468429' | 1456081 |
| 7 | 'mark + clearMarks' | '2148.90 ± 1.28%' | '2073.00' | '480925 ± 0.01%' | '482393' | 465356 |
| 8 | 'measure + clearMeasures (with start and end timestamps)' | '2277.26 ± 1.10%' | '2204.00' | '451016 ± 0.01%' | '453721' | 439125 |
| 9 | 'measure + clearMeasures (with mark names)' | '2277.82 ± 0.51%' | '2243.00' | '443853 ± 0.01%' | '445831' | 439016 |
Reviewed By: hoxyq
Differential Revision: D78193072
fbshipit-source-id: 03b52927a1999f19a2baf0d02335a959525d7add1 parent 1b7c9ea commit 4edc33e
9 files changed
Lines changed: 214 additions & 302 deletions
File tree
- packages/react-native
- ReactCommon/react
- nativemodule/webperformance
- performance/timeline
- tests
- src/private/webapis/performance
- __tests__
- specs
Lines changed: 17 additions & 95 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
180 | 129 | | |
181 | 130 | | |
182 | | - | |
183 | | - | |
184 | | - | |
| 131 | + | |
| 132 | + | |
185 | 133 | | |
186 | 134 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
222 | 140 | | |
223 | | - | |
224 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
225 | 147 | | |
226 | 148 | | |
227 | 149 | | |
| |||
Lines changed: 8 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
95 | 94 | | |
96 | 95 | | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 99 | + | |
112 | 100 | | |
113 | 101 | | |
114 | 102 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
119 | 107 | | |
120 | 108 | | |
121 | 109 | | |
| |||
Lines changed: 6 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 172 | + | |
| 173 | + | |
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
| |||
183 | 181 | | |
184 | 182 | | |
185 | 183 | | |
186 | | - | |
187 | | - | |
188 | 184 | | |
189 | 185 | | |
190 | | - | |
| 186 | + | |
191 | 187 | | |
192 | 188 | | |
193 | | - | |
| 189 | + | |
194 | 190 | | |
195 | 191 | | |
196 | | - | |
197 | | - | |
198 | 192 | | |
199 | 193 | | |
200 | 194 | | |
| |||
209 | 203 | | |
210 | 204 | | |
211 | 205 | | |
212 | | - | |
213 | | - | |
214 | 206 | | |
215 | 207 | | |
216 | 208 | | |
| |||
275 | 267 | | |
276 | 268 | | |
277 | 269 | | |
278 | | - | |
| 270 | + | |
279 | 271 | | |
280 | 272 | | |
281 | 273 | | |
| |||
302 | 294 | | |
303 | 295 | | |
304 | 296 | | |
305 | | - | |
306 | | - | |
307 | 297 | | |
308 | 298 | | |
309 | 299 | | |
| |||
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 89 | + | |
92 | 90 | | |
93 | | - | |
| 91 | + | |
94 | 92 | | |
95 | 93 | | |
96 | | - | |
| 94 | + | |
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
| |||
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
110 | | - | |
| 108 | + | |
111 | 109 | | |
112 | 110 | | |
113 | 111 | | |
| |||
Lines changed: 16 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 132 | + | |
135 | 133 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 134 | + | |
139 | 135 | | |
140 | 136 | | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
144 | 140 | | |
145 | | - | |
| 141 | + | |
146 | 142 | | |
147 | 143 | | |
148 | 144 | | |
| |||
172 | 168 | | |
173 | 169 | | |
174 | 170 | | |
175 | | - | |
| 171 | + | |
176 | 172 | | |
177 | 173 | | |
178 | 174 | | |
| |||
203 | 199 | | |
204 | 200 | | |
205 | 201 | | |
206 | | - | |
207 | | - | |
208 | | - | |
| 202 | + | |
209 | 203 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 204 | + | |
213 | 205 | | |
214 | 206 | | |
215 | 207 | | |
216 | | - | |
| 208 | + | |
217 | 209 | | |
218 | 210 | | |
219 | 211 | | |
220 | | - | |
| 212 | + | |
221 | 213 | | |
222 | 214 | | |
223 | 215 | | |
| |||
241 | 233 | | |
242 | 234 | | |
243 | 235 | | |
244 | | - | |
| 236 | + | |
245 | 237 | | |
246 | 238 | | |
247 | 239 | | |
248 | 240 | | |
249 | | - | |
| 241 | + | |
250 | 242 | | |
251 | 243 | | |
252 | 244 | | |
| |||
288 | 280 | | |
289 | 281 | | |
290 | 282 | | |
291 | | - | |
| 283 | + | |
292 | 284 | | |
293 | 285 | | |
294 | 286 | | |
295 | 287 | | |
296 | | - | |
| 288 | + | |
297 | 289 | | |
298 | 290 | | |
299 | 291 | | |
| |||
330 | 322 | | |
331 | 323 | | |
332 | 324 | | |
333 | | - | |
334 | | - | |
335 | | - | |
| 325 | + | |
336 | 326 | | |
337 | | - | |
338 | | - | |
339 | | - | |
| 327 | + | |
340 | 328 | | |
341 | 329 | | |
342 | 330 | | |
343 | | - | |
| 331 | + | |
344 | 332 | | |
345 | 333 | | |
346 | 334 | | |
347 | | - | |
| 335 | + | |
348 | 336 | | |
349 | 337 | | |
350 | 338 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
375 | | - | |
376 | | - | |
| 374 | + | |
377 | 375 | | |
378 | 376 | | |
379 | 377 | | |
| |||
0 commit comments