Skip to content

Commit

Permalink
Set profiler values to doubles
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Sep 11, 2024
1 parent d724ba9 commit 87b3818
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
29 changes: 11 additions & 18 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,11 @@ function FiberNode(
// Learn more about this here:
// https://github.com/facebook/react/issues/14365
// https://bugs.chromium.org/p/v8/issues/detail?id=8538
this.actualDuration = Number.NaN;
this.actualStartTime = Number.NaN;
this.selfBaseDuration = Number.NaN;
this.treeBaseDuration = Number.NaN;

// It's okay to replace the initial doubles with smis after initialization.
// This won't trigger the performance cliff mentioned above,
// and it simplifies other profiler code (including DevTools).
this.actualDuration = 0;
this.actualStartTime = -1;
this.selfBaseDuration = 0;
this.treeBaseDuration = 0;

this.actualDuration = -0;
this.actualStartTime = -1.1;
this.selfBaseDuration = -0;
this.treeBaseDuration = -0;
}

if (__DEV__) {
Expand Down Expand Up @@ -286,10 +279,10 @@ function createFiberImplObject(
};

if (enableProfilerTimer) {
fiber.actualDuration = 0;
fiber.actualStartTime = -1;
fiber.selfBaseDuration = 0;
fiber.treeBaseDuration = 0;
fiber.actualDuration = -0;
fiber.actualStartTime = -1.1;
fiber.selfBaseDuration = -0;
fiber.treeBaseDuration = -0;
}

if (__DEV__) {
Expand Down Expand Up @@ -382,8 +375,8 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
// This prevents time from endlessly accumulating in new commits.
// This has the downside of resetting values for different priority renders,
// But works for yielding (the common case) and should support resuming.
workInProgress.actualDuration = 0;
workInProgress.actualStartTime = -1;
workInProgress.actualDuration = -0;
workInProgress.actualStartTime = -1.1;
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -2430,10 +2430,10 @@ function mountSuspenseFallbackChildren(
// final amounts. This seems counterintuitive, since we're intentionally
// not measuring part of the render phase, but this makes it match what we
// do in Concurrent Mode.
primaryChildFragment.actualDuration = 0;
primaryChildFragment.actualStartTime = -1;
primaryChildFragment.selfBaseDuration = 0;
primaryChildFragment.treeBaseDuration = 0;
primaryChildFragment.actualDuration = -0;
primaryChildFragment.actualStartTime = -1.1;
primaryChildFragment.selfBaseDuration = -0;
primaryChildFragment.treeBaseDuration = -0;
}

fallbackChildFragment = createFiberFromFragment(
Expand Down Expand Up @@ -2560,8 +2560,8 @@ function updateSuspenseFallbackChildren(
// final amounts. This seems counterintuitive, since we're intentionally
// not measuring part of the render phase, but this makes it match what we
// do in Concurrent Mode.
primaryChildFragment.actualDuration = 0;
primaryChildFragment.actualStartTime = -1;
primaryChildFragment.actualDuration = -0;
primaryChildFragment.actualStartTime = -1.1;
primaryChildFragment.selfBaseDuration =
currentPrimaryChildFragment.selfBaseDuration;
primaryChildFragment.treeBaseDuration =
Expand Down

0 comments on commit 87b3818

Please sign in to comment.