Skip to content

Commit a2485b7

Browse files
committed
[Fiber] Profiler - Use two separate functions instead of branch by flag (#30957)
Nit: I don't trust flags in hot code. While it can take somewhat longer to compile two functions and JIT them. After that they don't need to check branches. Also makes it clearer the purpose. DiffTrain build for [3d95c43](3d95c43)
1 parent c8d8c3e commit a2485b7

34 files changed

+369
-262
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6774caa37973e3e26d60f100971e5e785fd12235
1+
3d95c43b8967d4dda1ec9a22f0d9ea4999fee8b8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6774caa37973e3e26d60f100971e5e785fd12235
1+
3d95c43b8967d4dda1ec9a22f0d9ea4999fee8b8

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ __DEV__ &&
20012001
exports.useTransition = function () {
20022002
return resolveDispatcher().useTransition();
20032003
};
2004-
exports.version = "19.0.0-www-classic-6774caa3-20240913";
2004+
exports.version = "19.0.0-www-classic-3d95c43b-20240913";
20052005
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
20062006
"function" ===
20072007
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ __DEV__ &&
19811981
exports.useTransition = function () {
19821982
return resolveDispatcher().useTransition();
19831983
};
1984-
exports.version = "19.0.0-www-modern-6774caa3-20240913";
1984+
exports.version = "19.0.0-www-modern-3d95c43b-20240913";
19851985
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19861986
"function" ===
19871987
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-classic-6774caa3-20240913";
668+
exports.version = "19.0.0-www-classic-3d95c43b-20240913";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-modern-6774caa3-20240913";
668+
exports.version = "19.0.0-www-modern-3d95c43b-20240913";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-classic-6774caa3-20240913";
672+
exports.version = "19.0.0-www-classic-3d95c43b-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-modern-6774caa3-20240913";
672+
exports.version = "19.0.0-www-modern-3d95c43b-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5435,11 +5435,18 @@ __DEV__ &&
54355435
profilerStartTime = now();
54365436
0 > fiber.actualStartTime && (fiber.actualStartTime = profilerStartTime);
54375437
}
5438-
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
5438+
function stopProfilerTimerIfRunningAndRecordDuration(fiber) {
5439+
if (0 <= profilerStartTime) {
5440+
var elapsedTime = now() - profilerStartTime;
5441+
fiber.actualDuration += elapsedTime;
5442+
fiber.selfBaseDuration = elapsedTime;
5443+
profilerStartTime = -1;
5444+
}
5445+
}
5446+
function stopProfilerTimerIfRunningAndRecordIncompleteDuration(fiber) {
54395447
if (0 <= profilerStartTime) {
54405448
var elapsedTime = now() - profilerStartTime;
54415449
fiber.actualDuration += elapsedTime;
5442-
overrideBaseTime && (fiber.selfBaseDuration = elapsedTime);
54435450
profilerStartTime = -1;
54445451
}
54455452
}
@@ -12975,7 +12982,7 @@ __DEV__ &&
1297512982
);
1297612983
else if (
1297712984
(JSCompiler_temp.mode & 2 &&
12978-
stopProfilerTimerIfRunningAndRecordDelta(JSCompiler_temp, !0),
12985+
stopProfilerTimerIfRunningAndRecordDuration(JSCompiler_temp),
1297912986
enableSchedulingProfiler)
1298012987
)
1298112988
switch ((markComponentRenderStopped(), workInProgressSuspendedReason)) {
@@ -13292,7 +13299,7 @@ __DEV__ &&
1329213299
unitOfWork,
1329313300
entangledRenderLanes
1329413301
)),
13295-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
13302+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork))
1329613303
: (current = runWithFiberInDEV(
1329713304
unitOfWork,
1329813305
beginWork,
@@ -13371,7 +13378,7 @@ __DEV__ &&
1337113378
(current = beginWork(current, unitOfWork, entangledRenderLanes));
1337213379
}
1337313380
isProfilingMode &&
13374-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0);
13381+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork);
1337513382
return current;
1337613383
}
1337713384
function throwAndUnwindWorkLoop(
@@ -13466,7 +13473,9 @@ __DEV__ &&
1346613473
completedWork,
1346713474
entangledRenderLanes
1346813475
)),
13469-
stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1));
13476+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(
13477+
completedWork
13478+
));
1347013479
if (null !== current) {
1347113480
workInProgress = current;
1347213481
return;
@@ -13490,7 +13499,7 @@ __DEV__ &&
1349013499
return;
1349113500
}
1349213501
if (0 !== (unitOfWork.mode & 2)) {
13493-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !1);
13502+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(unitOfWork);
1349413503
next = unitOfWork.actualDuration;
1349513504
for (var child = unitOfWork.child; null !== child; )
1349613505
(next += child.actualDuration), (child = child.sibling);
@@ -17112,11 +17121,11 @@ __DEV__ &&
1711217121
(function () {
1711317122
var internals = {
1711417123
bundleType: 1,
17115-
version: "19.0.0-www-classic-6774caa3-20240913",
17124+
version: "19.0.0-www-classic-3d95c43b-20240913",
1711617125
rendererPackageName: "react-art",
1711717126
currentDispatcherRef: ReactSharedInternals,
1711817127
findFiberByHostInstance: getInstanceFromNode,
17119-
reconcilerVersion: "19.0.0-www-classic-6774caa3-20240913"
17128+
reconcilerVersion: "19.0.0-www-classic-3d95c43b-20240913"
1712017129
};
1712117130
internals.overrideHookState = overrideHookState;
1712217131
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -17150,7 +17159,7 @@ __DEV__ &&
1715017159
exports.Shape = Shape;
1715117160
exports.Surface = Surface;
1715217161
exports.Text = Text;
17153-
exports.version = "19.0.0-www-classic-6774caa3-20240913";
17162+
exports.version = "19.0.0-www-classic-3d95c43b-20240913";
1715417163
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1715517164
"function" ===
1715617165
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5311,11 +5311,18 @@ __DEV__ &&
53115311
profilerStartTime = now();
53125312
0 > fiber.actualStartTime && (fiber.actualStartTime = profilerStartTime);
53135313
}
5314-
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
5314+
function stopProfilerTimerIfRunningAndRecordDuration(fiber) {
5315+
if (0 <= profilerStartTime) {
5316+
var elapsedTime = now() - profilerStartTime;
5317+
fiber.actualDuration += elapsedTime;
5318+
fiber.selfBaseDuration = elapsedTime;
5319+
profilerStartTime = -1;
5320+
}
5321+
}
5322+
function stopProfilerTimerIfRunningAndRecordIncompleteDuration(fiber) {
53155323
if (0 <= profilerStartTime) {
53165324
var elapsedTime = now() - profilerStartTime;
53175325
fiber.actualDuration += elapsedTime;
5318-
overrideBaseTime && (fiber.selfBaseDuration = elapsedTime);
53195326
profilerStartTime = -1;
53205327
}
53215328
}
@@ -12523,7 +12530,7 @@ __DEV__ &&
1252312530
);
1252412531
else if (
1252512532
(JSCompiler_temp.mode & 2 &&
12526-
stopProfilerTimerIfRunningAndRecordDelta(JSCompiler_temp, !0),
12533+
stopProfilerTimerIfRunningAndRecordDuration(JSCompiler_temp),
1252712534
enableSchedulingProfiler)
1252812535
)
1252912536
switch ((markComponentRenderStopped(), workInProgressSuspendedReason)) {
@@ -12840,7 +12847,7 @@ __DEV__ &&
1284012847
unitOfWork,
1284112848
entangledRenderLanes
1284212849
)),
12843-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
12850+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork))
1284412851
: (current = runWithFiberInDEV(
1284512852
unitOfWork,
1284612853
beginWork,
@@ -12915,7 +12922,7 @@ __DEV__ &&
1291512922
(current = beginWork(current, unitOfWork, entangledRenderLanes));
1291612923
}
1291712924
isProfilingMode &&
12918-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0);
12925+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork);
1291912926
return current;
1292012927
}
1292112928
function throwAndUnwindWorkLoop(
@@ -13010,7 +13017,9 @@ __DEV__ &&
1301013017
completedWork,
1301113018
entangledRenderLanes
1301213019
)),
13013-
stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1));
13020+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(
13021+
completedWork
13022+
));
1301413023
if (null !== current) {
1301513024
workInProgress = current;
1301613025
return;
@@ -13034,7 +13043,7 @@ __DEV__ &&
1303413043
return;
1303513044
}
1303613045
if (0 !== (unitOfWork.mode & 2)) {
13037-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !1);
13046+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(unitOfWork);
1303813047
next = unitOfWork.actualDuration;
1303913048
for (var child = unitOfWork.child; null !== child; )
1304013049
(next += child.actualDuration), (child = child.sibling);
@@ -16558,11 +16567,11 @@ __DEV__ &&
1655816567
(function () {
1655916568
var internals = {
1656016569
bundleType: 1,
16561-
version: "19.0.0-www-modern-6774caa3-20240913",
16570+
version: "19.0.0-www-modern-3d95c43b-20240913",
1656216571
rendererPackageName: "react-art",
1656316572
currentDispatcherRef: ReactSharedInternals,
1656416573
findFiberByHostInstance: getInstanceFromNode,
16565-
reconcilerVersion: "19.0.0-www-modern-6774caa3-20240913"
16574+
reconcilerVersion: "19.0.0-www-modern-3d95c43b-20240913"
1656616575
};
1656716576
internals.overrideHookState = overrideHookState;
1656816577
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16596,7 +16605,7 @@ __DEV__ &&
1659616605
exports.Shape = Shape;
1659716606
exports.Surface = Surface;
1659816607
exports.Text = Text;
16599-
exports.version = "19.0.0-www-modern-6774caa3-20240913";
16608+
exports.version = "19.0.0-www-modern-3d95c43b-20240913";
1660016609
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1660116610
"function" ===
1660216611
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)