Skip to content

Commit baaa97f

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 commit 3d95c43.
1 parent b42180d commit baaa97f

File tree

14 files changed

+134
-87
lines changed

14 files changed

+134
-87
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-d3d4d3a4-20240913
1+
19.0.0-native-fb-3d95c43b-20240913

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<2d89a3e686f85aa5ee5696aad303b4b0>>
10+
* @generated SignedSource<<e4eab5c04819ff525ec966db4c05e91a>>
1111
*/
1212

1313
"use strict";
@@ -5032,11 +5032,18 @@ __DEV__ &&
50325032
profilerStartTime = now();
50335033
0 > fiber.actualStartTime && (fiber.actualStartTime = profilerStartTime);
50345034
}
5035-
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
5035+
function stopProfilerTimerIfRunningAndRecordDuration(fiber) {
5036+
if (0 <= profilerStartTime) {
5037+
var elapsedTime = now() - profilerStartTime;
5038+
fiber.actualDuration += elapsedTime;
5039+
fiber.selfBaseDuration = elapsedTime;
5040+
profilerStartTime = -1;
5041+
}
5042+
}
5043+
function stopProfilerTimerIfRunningAndRecordIncompleteDuration(fiber) {
50365044
if (0 <= profilerStartTime) {
50375045
var elapsedTime = now() - profilerStartTime;
50385046
fiber.actualDuration += elapsedTime;
5039-
overrideBaseTime && (fiber.selfBaseDuration = elapsedTime);
50405047
profilerStartTime = -1;
50415048
}
50425049
}
@@ -11149,7 +11156,7 @@ __DEV__ &&
1114911156
else
1115011157
switch (
1115111158
(handler.mode & 2 &&
11152-
stopProfilerTimerIfRunningAndRecordDelta(handler, !0),
11159+
stopProfilerTimerIfRunningAndRecordDuration(handler),
1115311160
markComponentRenderStopped(),
1115411161
workInProgressSuspendedReason)
1115511162
) {
@@ -11426,7 +11433,7 @@ __DEV__ &&
1142611433
unitOfWork,
1142711434
entangledRenderLanes
1142811435
)),
11429-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
11436+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork))
1143011437
: (current = runWithFiberInDEV(
1143111438
unitOfWork,
1143211439
beginWork,
@@ -11485,7 +11492,7 @@ __DEV__ &&
1148511492
(current = beginWork(current, unitOfWork, entangledRenderLanes));
1148611493
}
1148711494
isProfilingMode &&
11488-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0);
11495+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork);
1148911496
return current;
1149011497
}
1149111498
function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) {
@@ -11555,7 +11562,9 @@ __DEV__ &&
1155511562
completedWork,
1155611563
entangledRenderLanes
1155711564
)),
11558-
stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1));
11565+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(
11566+
completedWork
11567+
));
1155911568
if (null !== current) {
1156011569
workInProgress = current;
1156111570
return;
@@ -11579,7 +11588,7 @@ __DEV__ &&
1157911588
return;
1158011589
}
1158111590
if (0 !== (unitOfWork.mode & 2)) {
11582-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !1);
11591+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(unitOfWork);
1158311592
next = unitOfWork.actualDuration;
1158411593
for (var child = unitOfWork.child; null !== child; )
1158511594
(next += child.actualDuration), (child = child.sibling);
@@ -15124,11 +15133,11 @@ __DEV__ &&
1512415133
(function () {
1512515134
var internals = {
1512615135
bundleType: 1,
15127-
version: "19.0.0-native-fb-d3d4d3a4-20240913",
15136+
version: "19.0.0-native-fb-3d95c43b-20240913",
1512815137
rendererPackageName: "react-test-renderer",
1512915138
currentDispatcherRef: ReactSharedInternals,
1513015139
findFiberByHostInstance: getInstanceFromNode,
15131-
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913"
15140+
reconcilerVersion: "19.0.0-native-fb-3d95c43b-20240913"
1513215141
};
1513315142
internals.overrideHookState = overrideHookState;
1513415143
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -15273,5 +15282,5 @@ __DEV__ &&
1527315282
flushSyncWorkAcrossRoots_impl(0, !0));
1527415283
}
1527515284
};
15276-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
15285+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";
1527715286
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<4f55ec78358c8ebecf4eaa369cc81849>>
10+
* @generated SignedSource<<1bf2ef454808c04dbe363a5699c9a59f>>
1111
*/
1212

1313
"use strict";
@@ -9486,14 +9486,14 @@ function wrapFiber(fiber) {
94869486
}
94879487
var internals$jscomp$inline_1266 = {
94889488
bundleType: 0,
9489-
version: "19.0.0-native-fb-d3d4d3a4-20240913",
9489+
version: "19.0.0-native-fb-3d95c43b-20240913",
94909490
rendererPackageName: "react-test-renderer",
94919491
currentDispatcherRef: ReactSharedInternals,
94929492
findFiberByHostInstance: function (mockNode) {
94939493
mockNode = nodeToInstanceMap.get(mockNode);
94949494
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
94959495
},
9496-
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913"
9496+
reconcilerVersion: "19.0.0-native-fb-3d95c43b-20240913"
94979497
};
94989498
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
94999499
var hook$jscomp$inline_1267 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -9629,4 +9629,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
96299629
flushSyncWorkAcrossRoots_impl(0, !0));
96309630
}
96319631
};
9632-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
9632+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b264040d9a17e92d86c094ff1ead550e>>
10+
* @generated SignedSource<<2929f47cce484593e96e4514ec4d434b>>
1111
*/
1212

1313
"use strict";
@@ -3660,11 +3660,18 @@ function startProfilerTimer(fiber) {
36603660
profilerStartTime = now();
36613661
0 > fiber.actualStartTime && (fiber.actualStartTime = profilerStartTime);
36623662
}
3663-
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
3663+
function stopProfilerTimerIfRunningAndRecordDuration(fiber) {
3664+
if (0 <= profilerStartTime) {
3665+
var elapsedTime = now() - profilerStartTime;
3666+
fiber.actualDuration += elapsedTime;
3667+
fiber.selfBaseDuration = elapsedTime;
3668+
profilerStartTime = -1;
3669+
}
3670+
}
3671+
function stopProfilerTimerIfRunningAndRecordIncompleteDuration(fiber) {
36643672
if (0 <= profilerStartTime) {
36653673
var elapsedTime = now() - profilerStartTime;
36663674
fiber.actualDuration += elapsedTime;
3667-
overrideBaseTime && (fiber.selfBaseDuration = elapsedTime);
36683675
profilerStartTime = -1;
36693676
}
36703677
}
@@ -8603,8 +8610,7 @@ function handleThrow(root, thrownValue) {
86038610
);
86048611
else
86058612
switch (
8606-
(handler.mode & 2 &&
8607-
stopProfilerTimerIfRunningAndRecordDelta(handler, !0),
8613+
(handler.mode & 2 && stopProfilerTimerIfRunningAndRecordDuration(handler),
86088614
markComponentRenderStopped(),
86098615
workInProgressSuspendedReason)
86108616
) {
@@ -8830,7 +8836,7 @@ function performUnitOfWork(unitOfWork) {
88308836
0 !== (unitOfWork.mode & 2)
88318837
? (startProfilerTimer(unitOfWork),
88328838
(current = beginWork(current, unitOfWork, entangledRenderLanes)),
8833-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
8839+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork))
88348840
: (current = beginWork(current, unitOfWork, entangledRenderLanes));
88358841
unitOfWork.memoizedProps = unitOfWork.pendingProps;
88368842
null === current
@@ -8878,7 +8884,7 @@ function replaySuspendedUnitOfWork(unitOfWork) {
88788884
resetWorkInProgress(next, entangledRenderLanes)),
88798885
(current = beginWork(current, next, entangledRenderLanes));
88808886
}
8881-
isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(next, !0);
8887+
isProfilingMode && stopProfilerTimerIfRunningAndRecordDuration(next);
88828888
next = current;
88838889
unitOfWork.memoizedProps = unitOfWork.pendingProps;
88848890
null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
@@ -8937,7 +8943,7 @@ function completeUnitOfWork(unitOfWork) {
89378943
? (current = completeWork(current, completedWork, entangledRenderLanes))
89388944
: (startProfilerTimer(completedWork),
89398945
(current = completeWork(current, completedWork, entangledRenderLanes)),
8940-
stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1));
8946+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(completedWork));
89418947
if (null !== current) {
89428948
workInProgress = current;
89438949
return;
@@ -8960,7 +8966,7 @@ function unwindUnitOfWork(unitOfWork, skipSiblings) {
89608966
return;
89618967
}
89628968
if (0 !== (unitOfWork.mode & 2)) {
8963-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !1);
8969+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(unitOfWork);
89648970
next = unitOfWork.actualDuration;
89658971
for (var child = unitOfWork.child; null !== child; )
89668972
(next += child.actualDuration), (child = child.sibling);
@@ -10074,14 +10080,14 @@ function wrapFiber(fiber) {
1007410080
}
1007510081
var internals$jscomp$inline_1141 = {
1007610082
bundleType: 0,
10077-
version: "19.0.0-native-fb-d3d4d3a4-20240913",
10083+
version: "19.0.0-native-fb-3d95c43b-20240913",
1007810084
rendererPackageName: "react-test-renderer",
1007910085
currentDispatcherRef: ReactSharedInternals,
1008010086
findFiberByHostInstance: function (mockNode) {
1008110087
mockNode = nodeToInstanceMap.get(mockNode);
1008210088
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
1008310089
},
10084-
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913",
10090+
reconcilerVersion: "19.0.0-native-fb-3d95c43b-20240913",
1008510091
getLaneLabelMap: function () {
1008610092
for (
1008710093
var map = new Map(), lane = 1, index$138 = 0;
@@ -10232,4 +10238,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
1023210238
flushSyncWorkAcrossRoots_impl(0, !0));
1023310239
}
1023410240
};
10235-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
10241+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<598e1a1554be705744125c5f6e86546f>>
10+
* @generated SignedSource<<151f049853714f91fd46ef5a8978deb0>>
1111
*/
1212

1313
"use strict";
@@ -1705,7 +1705,7 @@ __DEV__ &&
17051705
exports.useTransition = function () {
17061706
return resolveDispatcher().useTransition();
17071707
};
1708-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
1708+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";
17091709
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17101710
"function" ===
17111711
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b8568e853b095ed822fa12f152e3121e>>
10+
* @generated SignedSource<<304b6c7b540179b069a45ff09f35dbe5>>
1111
*/
1212

1313
"use strict";
@@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
580580
exports.useTransition = function () {
581581
return ReactSharedInternals.H.useTransition();
582582
};
583-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
583+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<92d8fbd56fb11e8c6a3aad4c04d6df3c>>
10+
* @generated SignedSource<<09bffda39d917b825e992af0d48176ef>>
1111
*/
1212

1313
"use strict";
@@ -584,7 +584,7 @@ exports.useSyncExternalStore = function (
584584
exports.useTransition = function () {
585585
return ReactSharedInternals.H.useTransition();
586586
};
587-
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
587+
exports.version = "19.0.0-native-fb-3d95c43b-20240913";
588588
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
589589
"function" ===
590590
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d3d4d3a46b014ab0f6edc443c19fcdba09105f20
1+
3d95c43b8967d4dda1ec9a22f0d9ea4999fee8b8

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d23230a057fe994a91ecee3cb9cf7716>>
10+
* @generated SignedSource<<f22f4e59e1c8c1bd2c19eba25b7b92e9>>
1111
*/
1212

1313
"use strict";
@@ -5918,11 +5918,18 @@ __DEV__ &&
59185918
profilerStartTime = now();
59195919
0 > fiber.actualStartTime && (fiber.actualStartTime = profilerStartTime);
59205920
}
5921-
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
5921+
function stopProfilerTimerIfRunningAndRecordDuration(fiber) {
5922+
if (0 <= profilerStartTime) {
5923+
var elapsedTime = now() - profilerStartTime;
5924+
fiber.actualDuration += elapsedTime;
5925+
fiber.selfBaseDuration = elapsedTime;
5926+
profilerStartTime = -1;
5927+
}
5928+
}
5929+
function stopProfilerTimerIfRunningAndRecordIncompleteDuration(fiber) {
59225930
if (0 <= profilerStartTime) {
59235931
var elapsedTime = now() - profilerStartTime;
59245932
fiber.actualDuration += elapsedTime;
5925-
overrideBaseTime && (fiber.selfBaseDuration = elapsedTime);
59265933
profilerStartTime = -1;
59275934
}
59285935
}
@@ -12297,7 +12304,7 @@ __DEV__ &&
1229712304
else
1229812305
switch (
1229912306
(JSCompiler_temp.mode & 2 &&
12300-
stopProfilerTimerIfRunningAndRecordDelta(JSCompiler_temp, !0),
12307+
stopProfilerTimerIfRunningAndRecordDuration(JSCompiler_temp),
1230112308
markComponentRenderStopped(),
1230212309
workInProgressSuspendedReason)
1230312310
) {
@@ -12606,7 +12613,7 @@ __DEV__ &&
1260612613
unitOfWork,
1260712614
entangledRenderLanes
1260812615
)),
12609-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0))
12616+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork))
1261012617
: (current = runWithFiberInDEV(
1261112618
unitOfWork,
1261212619
beginWork,
@@ -12665,7 +12672,7 @@ __DEV__ &&
1266512672
(current = beginWork(current, unitOfWork, entangledRenderLanes));
1266612673
}
1266712674
isProfilingMode &&
12668-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0);
12675+
stopProfilerTimerIfRunningAndRecordDuration(unitOfWork);
1266912676
return current;
1267012677
}
1267112678
function throwAndUnwindWorkLoop(
@@ -12760,7 +12767,9 @@ __DEV__ &&
1276012767
completedWork,
1276112768
entangledRenderLanes
1276212769
)),
12763-
stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1));
12770+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(
12771+
completedWork
12772+
));
1276412773
if (null !== current) {
1276512774
workInProgress = current;
1276612775
return;
@@ -12784,7 +12793,7 @@ __DEV__ &&
1278412793
return;
1278512794
}
1278612795
if (0 !== (unitOfWork.mode & 2)) {
12787-
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !1);
12796+
stopProfilerTimerIfRunningAndRecordIncompleteDuration(unitOfWork);
1278812797
next = unitOfWork.actualDuration;
1278912798
for (var child = unitOfWork.child; null !== child; )
1279012799
(next += child.actualDuration), (child = child.sibling);
@@ -17173,11 +17182,11 @@ __DEV__ &&
1717317182
(function () {
1717417183
var internals = {
1717517184
bundleType: 1,
17176-
version: "19.0.0-native-fb-d3d4d3a4-20240913",
17185+
version: "19.0.0-native-fb-3d95c43b-20240913",
1717717186
rendererPackageName: "react-native-renderer",
1717817187
currentDispatcherRef: ReactSharedInternals,
1717917188
findFiberByHostInstance: getInstanceFromNode,
17180-
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913"
17189+
reconcilerVersion: "19.0.0-native-fb-3d95c43b-20240913"
1718117190
};
1718217191
null !== extraDevToolsConfig &&
1718317192
(internals.rendererConfig = extraDevToolsConfig);

0 commit comments

Comments
 (0)