Revert D88863291: Add performance track for React Native renderer

Differential Revision:
D88863291

Original commit changeset: 6401d7e45b46

Original Phabricator Diff: D88863291

fbshipit-source-id: f3c6e4a6b256cec1dcf135df217d583ee01bf1ff
This commit is contained in:
Matthew Pearcy authored and meta-codesync[bot] committed 2026-03-06 07:55:28 -08:00
1 parent c0f2f63ce1
commit 7d45ea8134
5 files changed
+62 -126

No files matched your search

+1 -1
View File
@@ -456,7 +456,7 @@ let reactFabric = RNTarget(
"components/virtualview",
"components/root/tests",
],
dependencies: [.reactNativeDependencies, .reactJsiExecutor, .rctTypesafety, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .reactRendererDebug, .reactGraphics, .yoga, .reactJsInspectorTracing],
dependencies: [.reactNativeDependencies, .reactJsiExecutor, .rctTypesafety, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .reactRendererDebug, .reactGraphics, .yoga],
sources: ["animated", "animationbackend", "animations", "attributedstring", "core", "componentregistry", "componentregistry/native", "components/root", "components/view", "components/view/platform/cxx", "components/scrollview", "components/scrollview/platform/cxx", "components/scrollview/platform/ios", "components/legacyviewmanagerinterop", "components/legacyviewmanagerinterop/platform/ios", "dom", "scheduler", "mounting", "observers/events", "observers/intersection", "telemetry", "consistency", "leakchecker", "uimanager", "uimanager/consistency", "viewtransition"]
)
@@ -21,7 +21,6 @@ import com.facebook.react.fabric.FabricUIManager
import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem
import com.facebook.react.fabric.mounting.mountitems.MountItem
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.tracing.PerformanceTracer
import com.facebook.systrace.Systrace
import java.util.Queue
import java.util.concurrent.ConcurrentLinkedQueue
@@ -202,16 +201,9 @@ internal class MountItemDispatcher(
"MountItemDispatcher::mountViews viewCommandMountItems",
)
PerformanceTracer.trace(
"view commands",
"Renderer",
"⚛ Native",
{ ->
for (command in commands) {
dispatchViewCommand(command)
}
},
)
for (command in commands) {
dispatchViewCommand(command)
}
Systrace.endSection(Systrace.TRACE_TAG_REACT)
}
@@ -223,21 +215,12 @@ internal class MountItemDispatcher(
Systrace.TRACE_TAG_REACT,
"MountItemDispatcher::mountViews preMountItems",
)
PerformanceTracer.trace(
"premount",
"Renderer",
"⚛ Native",
{ ->
for (preMountItem in preMountItems) {
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(preMountItem, "dispatchMountItems: Executing preMountItem")
}
executeOrEnqueue(preMountItem)
}
},
)
for (preMountItem in preMountItems) {
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(preMountItem, "dispatchMountItems: Executing preMountItem")
}
executeOrEnqueue(preMountItem)
}
Systrace.endSection(Systrace.TRACE_TAG_REACT)
}
@@ -246,56 +229,44 @@ internal class MountItemDispatcher(
Systrace.TRACE_TAG_REACT,
"MountItemDispatcher::mountViews mountItems to execute",
)
val batchedExecutionStartTime = SystemClock.uptimeMillis()
PerformanceTracer.trace(
"mount",
"Renderer",
"⚛ Native",
{ ->
val batchedExecutionStartTime = SystemClock.uptimeMillis()
for (mountItem in items) {
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(mountItem, "dispatchMountItems: Executing mountItem")
}
for (mountItem in items) {
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(mountItem, "dispatchMountItems: Executing mountItem")
}
val command = mountItem as? DispatchCommandMountItem
if (command != null) {
dispatchViewCommand(command)
continue
}
val command = mountItem as? DispatchCommandMountItem
if (command != null) {
dispatchViewCommand(command)
continue
}
try {
executeOrEnqueue(mountItem)
} catch (e: Throwable) {
// If there's an exception, we want to log diagnostics in prod and rethrow.
FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e)
for (m in items) {
if (m === mountItem) {
// We want to mark the mount item that caused exception
FLog.e(
TAG,
"dispatchMountItems: mountItem: next mountItem triggered exception!",
)
}
printMountItem(m, "dispatchMountItems: mountItem")
}
if (mountItem.getSurfaceId() != View.NO_ID) {
mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
}
if (ReactIgnorableMountingException.isIgnorable(e)) {
ReactSoftExceptionLogger.logSoftException(TAG, e)
} else {
throw e
}
}
try {
executeOrEnqueue(mountItem)
} catch (e: Throwable) {
// If there's an exception, we want to log diagnostics in prod and rethrow.
FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e)
for (m in items) {
if (m === mountItem) {
// We want to mark the mount item that caused exception
FLog.e(TAG, "dispatchMountItems: mountItem: next mountItem triggered exception!")
}
batchedExecutionTime += SystemClock.uptimeMillis() - batchedExecutionStartTime
},
)
printMountItem(m, "dispatchMountItems: mountItem")
}
if (mountItem.getSurfaceId() != View.NO_ID) {
mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
}
if (ReactIgnorableMountingException.isIgnorable(e)) {
ReactSoftExceptionLogger.logSoftException(TAG, e)
} else {
throw e
}
}
}
batchedExecutionTime += SystemClock.uptimeMillis() - batchedExecutionStartTime
Systrace.endSection(Systrace.TRACE_TAG_REACT)
}
@@ -326,34 +297,26 @@ internal class MountItemDispatcher(
private fun dispatchPreMountItemsImpl(deadline: Long) {
Systrace.beginSection(Systrace.TRACE_TAG_REACT, "MountItemDispatcher::premountViews")
PerformanceTracer.trace(
"premount",
"Renderer",
"⚛ Native",
{ ->
// dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems
// from
// reentering during dispatchPreMountItems
inDispatch = true
// dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems from
// reentering during dispatchPreMountItems
inDispatch = true
try {
while (true) {
if (System.nanoTime() > deadline) {
break
}
try {
while (true) {
if (System.nanoTime() > deadline) {
break
}
// If list is empty, `poll` will return null, or var will never be set
val preMountItemToDispatch = preMountItems.poll() ?: break
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(preMountItemToDispatch, "dispatchPreMountItems")
}
executeOrEnqueue(preMountItemToDispatch)
}
} finally {
inDispatch = false
}
},
)
// If list is empty, `poll` will return null, or var will never be set
val preMountItemToDispatch = preMountItems.poll() ?: break
if (ReactNativeFeatureFlags.enableFabricLogs()) {
printMountItem(preMountItemToDispatch, "dispatchPreMountItems")
}
executeOrEnqueue(preMountItemToDispatch)
}
} finally {
inDispatch = false
}
Systrace.endSection(Systrace.TRACE_TAG_REACT)
}
@@ -173,7 +173,6 @@ Pod::Spec.new do |s|
end
s.subspec "mounting" do |ss|
ss.dependency "React-jsinspectortracing"
ss.source_files = podspec_sources("react/renderer/mounting/**/*.{m,mm,cpp,h}", "react/renderer/mounting/**/*.h")
ss.exclude_files = "react/renderer/mounting/tests"
ss.header_dir = "react/renderer/mounting"
@@ -22,7 +22,6 @@ target_link_libraries(react_renderer_mounting
glog
glog_init
jsi
jsinspector_tracing
react_debug
react_renderer_core
react_renderer_debug
@@ -8,7 +8,6 @@
#include "ShadowTree.h"
#include <cxxreact/TraceSection.h>
#include <jsinspector-modern/tracing/PerformanceTracerSection.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/components/root/RootComponentDescriptor.h>
#include <react/renderer/components/view/ViewShadowNode.h>
@@ -25,19 +24,6 @@ namespace facebook::react {
namespace {
const int MAX_COMMIT_ATTEMPTS_BEFORE_LOCKING = 3;
std::string getShadowTreeCommitSourceName(ShadowTreeCommitSource source) {
switch (source) {
case ShadowTreeCommitSource::Unknown:
return "Unknown";
case ShadowTreeCommitSource::React:
return "React";
case ShadowTreeCommitSource::AnimationEndSync:
return "AnimationEndSync";
case ShadowTreeCommitSource::ReactRevisionMerge:
return "ReactRevisionMerge";
}
}
} // namespace
using CommitStatus = ShadowTree::CommitStatus;
@@ -330,13 +316,6 @@ CommitStatus ShadowTree::tryCommit(
const ShadowTreeCommitTransaction& transaction,
const CommitOptions& commitOptions) const {
TraceSection s("ShadowTree::commit");
jsinspector_modern::tracing::PerformanceTracerSection s1(
"commit",
"Renderer",
"⚛ Native",
nullptr,
"source",
getShadowTreeCommitSourceName(commitOptions.source));
auto isReactBranch = ReactNativeFeatureFlags::enableFabricCommitBranching() &&
commitOptions.source == CommitSource::React;
@@ -403,11 +382,7 @@ CommitStatus ShadowTree::tryCommit(
telemetry.willLayout();
telemetry.setAsThreadLocal();
{
jsinspector_modern::tracing::PerformanceTracerSection s2(
"layout", "Renderer", "⚛ Native");
newRootShadowNode->layoutIfNeeded(&affectedLayoutableNodes);
}
newRootShadowNode->layoutIfNeeded(&affectedLayoutableNodes);
telemetry.unsetAsThreadLocal();
telemetry.didLayout(static_cast<int>(affectedLayoutableNodes.size()));