GeezerVison is showing github.com — Permanently removed component stacks from scheduling profiler data (#… · react/react@9b35dd2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/SchedulingProfiler.js +9-52Lines changed: 9 additions & 52 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,13 +11,9 @@ import type {Lane, Lanes} from './ReactFiberLane'; | 11 | 11 | import type {Fiber} from './ReactInternalTypes'; | 12 | 12 | import type {Wakeable} from 'shared/ReactTypes'; | 13 | 13 |
| 14 | | -import { | 15 | | - enableSchedulingProfiler, | 16 | | - enableSchedulingProfilerComponentStacks, | 17 | | -} from 'shared/ReactFeatureFlags'; | | 14 | +import {enableSchedulingProfiler} from 'shared/ReactFeatureFlags'; | 18 | 15 | import ReactVersion from 'shared/ReactVersion'; | 19 | 16 | import getComponentName from 'shared/getComponentName'; | 20 | | -import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack'; | 21 | 17 |
| 22 | 18 | /** | 23 | 19 | * If performance exists and supports the subset of the User Timing API that we | @@ -65,51 +61,16 @@ function getWakeableID(wakeable: Wakeable): number { | 65 | 61 | return ((wakeableIDs.get(wakeable): any): number); | 66 | 62 | } | 67 | 63 |
| 68 | | -let getComponentStackByFiber = function getComponentStackByFiberDisabled( | 69 | | - fiber: Fiber, | 70 | | -): string { | 71 | | - return ''; | 72 | | -}; | 73 | | - | 74 | | -if (enableSchedulingProfilerComponentStacks) { | 75 | | - // $FlowFixMe: Flow cannot handle polymorphic WeakMaps | 76 | | - const cachedFiberStacks: WeakMap<Fiber, string> = new PossiblyWeakMap(); | 77 | | - getComponentStackByFiber = function cacheFirstGetComponentStackByFiber( | 78 | | - fiber: Fiber, | 79 | | - ): string { | 80 | | - if (cachedFiberStacks.has(fiber)) { | 81 | | - return ((cachedFiberStacks.get(fiber): any): string); | 82 | | - } else { | 83 | | - const alternate = fiber.alternate; | 84 | | - if (alternate !== null && cachedFiberStacks.has(alternate)) { | 85 | | - return ((cachedFiberStacks.get(alternate): any): string); | 86 | | - } | 87 | | - } | 88 | | - // TODO (brian) Generate and store temporary ID so DevTools can match up a component stack later. | 89 | | - const componentStack = getStackByFiberInDevAndProd(fiber) || ''; | 90 | | - cachedFiberStacks.set(fiber, componentStack); | 91 | | - return componentStack; | 92 | | - }; | 93 | | -} | 94 | | - | 95 | 64 | export function markComponentSuspended(fiber: Fiber, wakeable: Wakeable): void { | 96 | 65 | if (enableSchedulingProfiler) { | 97 | 66 | if (supportsUserTiming) { | 98 | 67 | const id = getWakeableID(wakeable); | 99 | 68 | const componentName = getComponentName(fiber.type) || 'Unknown'; | 100 | | - const componentStack = getComponentStackByFiber(fiber); | 101 | | - performance.mark( | 102 | | - `--suspense-suspend-${id}-${componentName}-${componentStack}`, | 103 | | - ); | | 69 | + // TODO Add component stack id | | 70 | + performance.mark(`--suspense-suspend-${id}-${componentName}`); | 104 | 71 | wakeable.then( | 105 | | - () => | 106 | | - performance.mark( | 107 | | - `--suspense-resolved-${id}-${componentName}-${componentStack}`, | 108 | | - ), | 109 | | - () => | 110 | | - performance.mark( | 111 | | - `--suspense-rejected-${id}-${componentName}-${componentStack}`, | 112 | | - ), | | 72 | + () => performance.mark(`--suspense-resolved-${id}-${componentName}`), | | 73 | + () => performance.mark(`--suspense-rejected-${id}-${componentName}`), | 113 | 74 | ); | 114 | 75 | } | 115 | 76 | } | @@ -183,11 +144,9 @@ export function markForceUpdateScheduled(fiber: Fiber, lane: Lane): void { | 183 | 144 | if (enableSchedulingProfiler) { | 184 | 145 | if (supportsUserTiming) { | 185 | 146 | const componentName = getComponentName(fiber.type) || 'Unknown'; | 186 | | - const componentStack = getComponentStackByFiber(fiber); | | 147 | + // TODO Add component stack id | 187 | 148 | performance.mark( | 188 | | - `--schedule-forced-update-${formatLanes( | 189 | | - lane, | 190 | | - )}-${componentName}-${componentStack}`, | | 149 | + `--schedule-forced-update-${formatLanes(lane)}-${componentName}`, | 191 | 150 | ); | 192 | 151 | } | 193 | 152 | } | @@ -197,11 +156,9 @@ export function markStateUpdateScheduled(fiber: Fiber, lane: Lane): void { | 197 | 156 | if (enableSchedulingProfiler) { | 198 | 157 | if (supportsUserTiming) { | 199 | 158 | const componentName = getComponentName(fiber.type) || 'Unknown'; | 200 | | - const componentStack = getComponentStackByFiber(fiber); | | 159 | + // TODO Add component stack id | 201 | 160 | performance.mark( | 202 | | - `--schedule-state-update-${formatLanes( | 203 | | - lane, | 204 | | - )}-${componentName}-${componentStack}`, | | 161 | + `--schedule-state-update-${formatLanes(lane)}-${componentName}`, | 205 | 162 | ); | 206 | 163 | } | 207 | 164 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/SchedulingProfiler-test.internal.js +24-105Lines changed: 24 additions & 105 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 |
| 13 | 13 | import ReactVersion from 'shared/ReactVersion'; | 14 | 14 |
| 15 | | -function normalizeCodeLocInfo(str) { | 16 | | - return ( | 17 | | - str && | 18 | | - str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function(m, name) { | 19 | | - return '\n in ' + name + ' (at **)'; | 20 | | - }) | 21 | | - ); | 22 | | -} | 23 | | - | 24 | | -// TODO (enableSchedulingProfilerComponentStacks) Clean this up once the feature flag has been removed. | 25 | | -function toggleComponentStacks(mark) { | 26 | | - let expectedMark = mark; | 27 | | - gate(({enableSchedulingProfilerComponentStacks}) => { | 28 | | - if (!enableSchedulingProfilerComponentStacks) { | 29 | | - const index = mark.indexOf('\n '); | 30 | | - if (index >= 0) { | 31 | | - expectedMark = mark.substr(0, index); | 32 | | - } | 33 | | - } | 34 | | - }); | 35 | | - return expectedMark; | 36 | | -} | 37 | | - | 38 | 15 | describe('SchedulingProfiler', () => { | 39 | 16 | let React; | 40 | 17 | let ReactTestRenderer; | @@ -162,9 +139,7 @@ describe('SchedulingProfiler', () => { | 162 | 139 | `--react-init-${ReactVersion}`, | 163 | 140 | '--schedule-render-1', | 164 | 141 | '--render-start-1', | 165 | | - toggleComponentStacks( | 166 | | - '--suspense-suspend-0-Example-\n at Example\n at Suspense', | 167 | | - ), | | 142 | + '--suspense-suspend-0-Example', | 168 | 143 | '--render-stop', | 169 | 144 | '--commit-start-1', | 170 | 145 | '--layout-effects-start-1', | @@ -175,11 +150,7 @@ describe('SchedulingProfiler', () => { | 175 | 150 | marks.splice(0); | 176 | 151 |
| 177 | 152 | await fakeSuspensePromise; | 178 | | - expect(marks).toEqual([ | 179 | | - toggleComponentStacks( | 180 | | - '--suspense-resolved-0-Example-\n at Example\n at Suspense', | 181 | | - ), | 182 | | - ]); | | 153 | + expect(marks).toEqual(['--suspense-resolved-0-Example']); | 183 | 154 | }); | 184 | 155 |
| 185 | 156 | // @gate enableSchedulingProfiler | @@ -199,9 +170,7 @@ describe('SchedulingProfiler', () => { | 199 | 170 | `--react-init-${ReactVersion}`, | 200 | 171 | '--schedule-render-1', | 201 | 172 | '--render-start-1', | 202 | | - toggleComponentStacks( | 203 | | - '--suspense-suspend-0-Example-\n at Example\n at Suspense', | 204 | | - ), | | 173 | + '--suspense-suspend-0-Example', | 205 | 174 | '--render-stop', | 206 | 175 | '--commit-start-1', | 207 | 176 | '--layout-effects-start-1', | @@ -212,11 +181,7 @@ describe('SchedulingProfiler', () => { | 212 | 181 | marks.splice(0); | 213 | 182 |
| 214 | 183 | await expect(fakeSuspensePromise).rejects.toThrow(); | 215 | | - expect(marks).toEqual([ | 216 | | - toggleComponentStacks( | 217 | | - '--suspense-rejected-0-Example-\n at Example\n at Suspense', | 218 | | - ), | 219 | | - ]); | | 184 | + expect(marks).toEqual(['--suspense-rejected-0-Example']); | 220 | 185 | }); | 221 | 186 |
| 222 | 187 | // @gate enableSchedulingProfiler | @@ -244,9 +209,7 @@ describe('SchedulingProfiler', () => { | 244 | 209 |
| 245 | 210 | expect(marks).toEqual([ | 246 | 211 | '--render-start-512', | 247 | | - toggleComponentStacks( | 248 | | - '--suspense-suspend-0-Example-\n at Example\n at Suspense', | 249 | | - ), | | 212 | + '--suspense-suspend-0-Example', | 250 | 213 | '--render-stop', | 251 | 214 | '--commit-start-512', | 252 | 215 | '--layout-effects-start-512', | @@ -257,11 +220,7 @@ describe('SchedulingProfiler', () => { | 257 | 220 | marks.splice(0); | 258 | 221 |
| 259 | 222 | await fakeSuspensePromise; | 260 | | - expect(marks).toEqual([ | 261 | | - toggleComponentStacks( | 262 | | - '--suspense-resolved-0-Example-\n at Example\n at Suspense', | 263 | | - ), | 264 | | - ]); | | 223 | + expect(marks).toEqual(['--suspense-resolved-0-Example']); | 265 | 224 | }); | 266 | 225 |
| 267 | 226 | // @gate enableSchedulingProfiler | @@ -289,9 +248,7 @@ describe('SchedulingProfiler', () => { | 289 | 248 |
| 290 | 249 | expect(marks).toEqual([ | 291 | 250 | '--render-start-512', | 292 | | - toggleComponentStacks( | 293 | | - '--suspense-suspend-0-Example-\n at Example\n at Suspense', | 294 | | - ), | | 251 | + '--suspense-suspend-0-Example', | 295 | 252 | '--render-stop', | 296 | 253 | '--commit-start-512', | 297 | 254 | '--layout-effects-start-512', | @@ -302,11 +259,7 @@ describe('SchedulingProfiler', () => { | 302 | 259 | marks.splice(0); | 303 | 260 |
| 304 | 261 | await expect(fakeSuspensePromise).rejects.toThrow(); | 305 | | - expect(marks).toEqual([ | 306 | | - toggleComponentStacks( | 307 | | - '--suspense-rejected-0-Example-\n at Example\n at Suspense', | 308 | | - ), | 309 | | - ]); | | 262 | + expect(marks).toEqual(['--suspense-rejected-0-Example']); | 310 | 263 | }); | 311 | 264 |
| 312 | 265 | // @gate enableSchedulingProfiler | @@ -332,14 +285,12 @@ describe('SchedulingProfiler', () => { | 332 | 285 |
| 333 | 286 | expect(Scheduler).toFlushUntilNextPaint([]); | 334 | 287 |
| 335 | | - expect(marks.map(normalizeCodeLocInfo)).toEqual([ | | 288 | + expect(marks).toEqual([ | 336 | 289 | '--render-start-512', | 337 | 290 | '--render-stop', | 338 | 291 | '--commit-start-512', | 339 | 292 | '--layout-effects-start-512', | 340 | | - toggleComponentStacks( | 341 | | - '--schedule-state-update-1-Example-\n in Example (at **)', | 342 | | - ), | | 293 | + '--schedule-state-update-1-Example', | 343 | 294 | '--layout-effects-stop', | 344 | 295 | '--render-start-1', | 345 | 296 | '--render-stop', | @@ -371,14 +322,12 @@ describe('SchedulingProfiler', () => { | 371 | 322 |
| 372 | 323 | expect(Scheduler).toFlushUntilNextPaint([]); | 373 | 324 |
| 374 | | - expect(marks.map(normalizeCodeLocInfo)).toEqual([ | | 325 | + expect(marks).toEqual([ | 375 | 326 | '--render-start-512', | 376 | 327 | '--render-stop', | 377 | 328 | '--commit-start-512', | 378 | 329 | '--layout-effects-start-512', | 379 | | - toggleComponentStacks( | 380 | | - '--schedule-forced-update-1-Example-\n in Example (at **)', | 381 | | - ), | | 330 | + '--schedule-forced-update-1-Example', | 382 | 331 | '--layout-effects-stop', | 383 | 332 | '--render-start-1', | 384 | 333 | '--render-stop', | @@ -415,16 +364,8 @@ describe('SchedulingProfiler', () => { | 415 | 364 |
| 416 | 365 | gate(({old}) => | 417 | 366 | old | 418 | | - ? expect(marks.map(normalizeCodeLocInfo)).toContain( | 419 | | - toggleComponentStacks( | 420 | | - '--schedule-state-update-1024-Example-\n in Example (at **)', | 421 | | - ), | 422 | | - ) | 423 | | - : expect(marks.map(normalizeCodeLocInfo)).toContain( | 424 | | - toggleComponentStacks( | 425 | | - '--schedule-state-update-512-Example-\n in Example (at **)', | 426 | | - ), | 427 | | - ), | | 367 | + ? expect(marks).toContain('--schedule-state-update-1024-Example') | | 368 | + : expect(marks).toContain('--schedule-state-update-512-Example'), | 428 | 369 | ); | 429 | 370 | }); | 430 | 371 |
| @@ -455,16 +396,8 @@ describe('SchedulingProfiler', () => { | 455 | 396 |
| 456 | 397 | gate(({old}) => | 457 | 398 | old | 458 | | - ? expect(marks.map(normalizeCodeLocInfo)).toContain( | 459 | | - toggleComponentStacks( | 460 | | - '--schedule-forced-update-1024-Example-\n in Example (at **)', | 461 | | - ), | 462 | | - ) | 463 | | - : expect(marks.map(normalizeCodeLocInfo)).toContain( | 464 | | - toggleComponentStacks( | 465 | | - '--schedule-forced-update-512-Example-\n in Example (at **)', | 466 | | - ), | 467 | | - ), | | 399 | + ? expect(marks).toContain('--schedule-forced-update-1024-Example') | | 400 | + : expect(marks).toContain('--schedule-forced-update-512-Example'), | 468 | 401 | ); | 469 | 402 | }); | 470 | 403 |
| @@ -489,14 +422,12 @@ describe('SchedulingProfiler', () => { | 489 | 422 |
| 490 | 423 | expect(Scheduler).toFlushUntilNextPaint([]); | 491 | 424 |
| 492 | | - expect(marks.map(normalizeCodeLocInfo)).toEqual([ | | 425 | + expect(marks).toEqual([ | 493 | 426 | '--render-start-512', | 494 | 427 | '--render-stop', | 495 | 428 | '--commit-start-512', | 496 | 429 | '--layout-effects-start-512', | 497 | | - toggleComponentStacks( | 498 | | - '--schedule-state-update-1-Example-\n in Example (at **)', | 499 | | - ), | | 430 | + '--schedule-state-update-1-Example', | 500 | 431 | '--layout-effects-stop', | 501 | 432 | '--render-start-1', | 502 | 433 | '--render-stop', | @@ -522,7 +453,7 @@ describe('SchedulingProfiler', () => { | 522 | 453 |
| 523 | 454 | gate(({old}) => { | 524 | 455 | if (old) { | 525 | | - expect(marks.map(normalizeCodeLocInfo)).toEqual([ | | 456 | + expect(marks).toEqual([ | 526 | 457 | `--react-init-${ReactVersion}`, | 527 | 458 | '--schedule-render-512', | 528 | 459 | '--render-start-512', | @@ -532,17 +463,15 @@ describe('SchedulingProfiler', () => { | 532 | 463 | '--layout-effects-stop', | 533 | 464 | '--commit-stop', | 534 | 465 | '--passive-effects-start-512', | 535 | | - toggleComponentStacks( | 536 | | - '--schedule-state-update-1024-Example-\n in Example (at **)', | 537 | | - ), | | 466 | + '--schedule-state-update-1024-Example', | 538 | 467 | '--passive-effects-stop', | 539 | 468 | '--render-start-1024', | 540 | 469 | '--render-stop', | 541 | 470 | '--commit-start-1024', | 542 | 471 | '--commit-stop', | 543 | 472 | ]); | 544 | 473 | } else { | 545 | | - expect(marks.map(normalizeCodeLocInfo)).toEqual([ | | 474 | + expect(marks).toEqual([ | 546 | 475 | `--react-init-${ReactVersion}`, | 547 | 476 | '--schedule-render-512', | 548 | 477 | '--render-start-512', | @@ -552,9 +481,7 @@ describe('SchedulingProfiler', () => { | 552 | 481 | '--layout-effects-stop', | 553 | 482 | '--commit-stop', | 554 | 483 | '--passive-effects-start-512', | 555 | | - toggleComponentStacks( | 556 | | - '--schedule-state-update-1024-Example-\n in Example (at **)', | 557 | | - ), | | 484 | + '--schedule-state-update-1024-Example', | 558 | 485 | '--passive-effects-stop', | 559 | 486 | '--render-start-1024', | 560 | 487 | '--render-stop', | @@ -583,16 +510,8 @@ describe('SchedulingProfiler', () => { | 583 | 510 |
| 584 | 511 | gate(({old}) => | 585 | 512 | old | 586 | | - ? expect(marks.map(normalizeCodeLocInfo)).toContain( | 587 | | - toggleComponentStacks( | 588 | | - '--schedule-state-update-1024-Example-\n in Example (at **)', | 589 | | - ), | 590 | | - ) | 591 | | - : expect(marks.map(normalizeCodeLocInfo)).toContain( | 592 | | - toggleComponentStacks( | 593 | | - '--schedule-state-update-512-Example-\n in Example (at **)', | 594 | | - ), | 595 | | - ), | | 513 | + ? expect(marks).toContain('--schedule-state-update-1024-Example') | | 514 | + : expect(marks).toContain('--schedule-state-update-512-Example'), | 596 | 515 | ); | 597 | 516 | }); | 598 | 517 | }); |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/ReactFeatureFlags.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,6 @@ export const enableDebugTracing = false; | 18 | 18 | // Adds user timing marks for e.g. state updates, suspense, and work loop stuff, | 19 | 19 | // for an experimental scheduling profiler tool. | 20 | 20 | export const enableSchedulingProfiler = __PROFILE__ && __EXPERIMENTAL__; | 21 | | -export const enableSchedulingProfilerComponentStacks = false; | 22 | 21 |
| 23 | 22 | // Helps identify side effects in render-phase lifecycle hooks and setState | 24 | 23 | // reducers by double invoking them in Strict Mode. | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-fb.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,6 @@ import typeof * as ExportsType from './ReactFeatureFlags.native-fb'; | 13 | 13 | // The rest of the flags are static for better dead code elimination. | 14 | 14 | export const enableDebugTracing = false; | 15 | 15 | export const enableSchedulingProfiler = false; | 16 | | -export const enableSchedulingProfilerComponentStacks = false; | 17 | 16 | export const enableProfilerTimer = __PROFILE__; | 18 | 17 | export const enableProfilerCommitHooks = false; | 19 | 18 | export const enableSchedulerTracing = __PROFILE__; | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-oss.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,6 @@ import typeof * as ExportsType from './ReactFeatureFlags.native-oss'; | 13 | 13 | export const debugRenderPhaseSideEffectsForStrictMode = false; | 14 | 14 | export const enableDebugTracing = false; | 15 | 15 | export const enableSchedulingProfiler = false; | 16 | | -export const enableSchedulingProfilerComponentStacks = false; | 17 | 16 | export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__; | 18 | 17 | export const warnAboutDeprecatedLifecycles = true; | 19 | 18 | export const enableProfilerTimer = __PROFILE__; | |
|