Skip to content

Commit fcf3c8c

Browse files
rshestfacebook-github-bot
authored andcommitted
Rename SystraceSection to TraceSection (#48383)
Summary: Pull Request resolved: #48383 ## Changelog: [Internal] - This changes the name of `SystraceSection` class to `TraceSection`, the purpose being to make it Systrace/FBSystrace agnostic (and that it can be mapped to e.g. Perfetto instead). It changes all the internal callsites to the RN code code, and also adds a shim include, `<cxxreact/SystraceSection.h`, for backward compatibility with the external callers for now (which will be addressed separately). Reviewed By: javache Differential Revision: D67621914 fbshipit-source-id: 337c63c45a7b075c6e00cfca67ecc06c298c94c0
1 parent 4a667e1 commit fcf3c8c

37 files changed

+352
-330
lines changed

packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import <React/RCTFollyConvert.h>
1515
#import <React/RCTLog.h>
1616
#import <React/RCTUtils.h>
17-
#import <cxxreact/SystraceSection.h>
17+
#import <cxxreact/TraceSection.h>
1818
#import <react/renderer/components/root/RootShadowNode.h>
1919
#import <react/renderer/core/LayoutableShadowNode.h>
2020
#import <react/renderer/core/RawProps.h>
@@ -45,7 +45,7 @@ static void RCTPerformMountInstructions(
4545
RCTMountingTransactionObserverCoordinator &observerCoordinator,
4646
SurfaceId surfaceId)
4747
{
48-
SystraceSection s("RCTPerformMountInstructions");
48+
TraceSection s("RCTPerformMountInstructions");
4949

5050
for (const auto &mutation : mutations) {
5151
switch (mutation.type) {
@@ -232,7 +232,7 @@ - (void)sendAccessibilityEvent:(ReactTag)reactTag eventType:(NSString *)eventTyp
232232

233233
- (void)initiateTransaction:(const MountingCoordinator &)mountingCoordinator
234234
{
235-
SystraceSection s("-[RCTMountingManager initiateTransaction:]");
235+
TraceSection s("-[RCTMountingManager initiateTransaction:]");
236236
RCTAssertMainQueue();
237237

238238
if (_transactionInFlight) {
@@ -250,7 +250,7 @@ - (void)initiateTransaction:(const MountingCoordinator &)mountingCoordinator
250250

251251
- (void)performTransaction:(const MountingCoordinator &)mountingCoordinator
252252
{
253-
SystraceSection s("-[RCTMountingManager performTransaction:]");
253+
TraceSection s("-[RCTMountingManager performTransaction:]");
254254
RCTAssertMainQueue();
255255

256256
auto surfaceId = mountingCoordinator.getSurfaceId();

packages/react-native/React/Fabric/RCTScheduler.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#import "RCTScheduler.h"
99

10-
#import <cxxreact/SystraceSection.h>
10+
#import <cxxreact/TraceSection.h>
1111
#import <react/featureflags/ReactNativeFeatureFlags.h>
1212
#import <react/renderer/animations/LayoutAnimationDriver.h>
1313
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "MountItem.h"
1212
#include "StateWrapperImpl.h"
1313

14-
#include <cxxreact/SystraceSection.h>
14+
#include <cxxreact/TraceSection.h>
1515
#include <react/featureflags/ReactNativeFeatureFlags.h>
1616
#include <react/jni/ReadableNativeMap.h>
1717
#include <react/renderer/components/scrollview/ScrollViewProps.h>
@@ -446,7 +446,7 @@ inline void writeUpdateOverflowInsetMountItem(
446446

447447
void FabricMountingManager::executeMount(
448448
const MountingTransaction& transaction) {
449-
SystraceSection section("FabricMountingManager::executeMount");
449+
TraceSection section("FabricMountingManager::executeMount");
450450

451451
std::scoped_lock lock(commitMutex_);
452452
auto finishTransactionStartTime = telemetryTimePointNow();
@@ -939,7 +939,7 @@ void FabricMountingManager::maybePreallocateShadowNode(
939939

940940
void FabricMountingManager::preallocateShadowView(
941941
const ShadowView& shadowView) {
942-
SystraceSection section("FabricMountingManager::preallocateShadowView");
942+
TraceSection section("FabricMountingManager::preallocateShadowView");
943943

944944
{
945945
std::lock_guard lock(allocatedViewsMutex_);

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "EventEmitterWrapper.h"
1414
#include "FabricMountingManager.h"
1515

16-
#include <cxxreact/SystraceSection.h>
16+
#include <cxxreact/TraceSection.h>
1717
#include <fbjni/fbjni.h>
1818
#include <glog/logging.h>
1919
#include <jsi/JSIDynamic.h>
@@ -135,7 +135,7 @@ void FabricUIManagerBinding::startSurfaceWithSurfaceHandler(
135135
jint surfaceId,
136136
jni::alias_ref<SurfaceHandlerBinding::jhybridobject> surfaceHandlerBinding,
137137
jboolean isMountable) {
138-
SystraceSection s("FabricUIManagerBinding::startSurfaceWithSurfaceHandler");
138+
TraceSection s("FabricUIManagerBinding::startSurfaceWithSurfaceHandler");
139139
if (enableFabricLogs_) {
140140
LOG(WARNING)
141141
<< "FabricUIManagerBinding::startSurfaceWithSurfaceHandler() was called (address: "
@@ -180,7 +180,7 @@ void FabricUIManagerBinding::startSurface(
180180
jint surfaceId,
181181
jni::alias_ref<jstring> moduleName,
182182
NativeMap* initialProps) {
183-
SystraceSection s("FabricUIManagerBinding::startSurface");
183+
TraceSection s("FabricUIManagerBinding::startSurface");
184184

185185
if (enableFabricLogs_) {
186186
LOG(WARNING)
@@ -235,7 +235,7 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
235235
jfloat offsetY,
236236
jboolean isRTL,
237237
jboolean doLeftAndRightSwapInRTL) {
238-
SystraceSection s("FabricUIManagerBinding::startSurfaceWithConstraints");
238+
TraceSection s("FabricUIManagerBinding::startSurfaceWithConstraints");
239239

240240
if (enableFabricLogs_) {
241241
LOG(WARNING)
@@ -293,7 +293,7 @@ void FabricUIManagerBinding::startSurfaceWithConstraints(
293293

294294
// Used by non-bridgeless+Fabric
295295
void FabricUIManagerBinding::stopSurface(jint surfaceId) {
296-
SystraceSection s("FabricUIManagerBinding::stopSurface");
296+
TraceSection s("FabricUIManagerBinding::stopSurface");
297297
if (enableFabricLogs_) {
298298
LOG(WARNING)
299299
<< "FabricUIManagerBinding::stopSurface() was called (address: " << this
@@ -336,7 +336,7 @@ void FabricUIManagerBinding::stopSurface(jint surfaceId) {
336336
void FabricUIManagerBinding::stopSurfaceWithSurfaceHandler(
337337
jni::alias_ref<SurfaceHandlerBinding::jhybridobject>
338338
surfaceHandlerBinding) {
339-
SystraceSection s("FabricUIManagerBinding::stopSurfaceWithSurfaceHandler");
339+
TraceSection s("FabricUIManagerBinding::stopSurfaceWithSurfaceHandler");
340340
const auto& surfaceHandler =
341341
surfaceHandlerBinding->cthis()->getSurfaceHandler();
342342
if (enableFabricLogs_) {
@@ -377,7 +377,7 @@ void FabricUIManagerBinding::setConstraints(
377377
jfloat offsetY,
378378
jboolean isRTL,
379379
jboolean doLeftAndRightSwapInRTL) {
380-
SystraceSection s("FabricUIManagerBinding::setConstraints");
380+
TraceSection s("FabricUIManagerBinding::setConstraints");
381381

382382
auto scheduler = getScheduler();
383383
if (!scheduler) {
@@ -425,7 +425,7 @@ void FabricUIManagerBinding::installFabricUIManager(
425425
jni::alias_ref<JFabricUIManager::javaobject> javaUIManager,
426426
EventBeatManager* eventBeatManager,
427427
ComponentFactory* componentsRegistry) {
428-
SystraceSection s("FabricUIManagerBinding::installFabricUIManager");
428+
TraceSection s("FabricUIManagerBinding::installFabricUIManager");
429429

430430
enableFabricLogs_ = ReactNativeFeatureFlags::enableFabricLogs();
431431

packages/react-native/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <cxxreact/JSBigString.h>
1111
#include <cxxreact/ModuleRegistry.h>
12-
#include <cxxreact/SystraceSection.h>
12+
#include <cxxreact/TraceSection.h>
1313
#include <fb/assert.h>
1414
#include <folly/json.h>
1515

@@ -53,7 +53,7 @@ void ProxyExecutor::initializeRuntime() {
5353
folly::dynamic nativeModuleConfig = folly::dynamic::array;
5454

5555
{
56-
SystraceSection s("collectNativeModuleDescriptions");
56+
TraceSection s("collectNativeModuleDescriptions");
5757
auto moduleRegistry = m_delegate->getModuleRegistry();
5858
for (const auto& name : moduleRegistry->moduleNames()) {
5959
auto config = moduleRegistry->getConfig(name);
@@ -65,7 +65,7 @@ void ProxyExecutor::initializeRuntime() {
6565
"remoteModuleConfig", std::move(nativeModuleConfig));
6666

6767
{
68-
SystraceSection t("setGlobalVariable");
68+
TraceSection t("setGlobalVariable");
6969
setGlobalVariable(
7070
"__fbBatchedBridgeConfig",
7171
std::make_unique<JSBigStdString>(folly::toJson(config)));

packages/react-native/ReactCommon/cxxreact/CxxNativeModule.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "JsArgumentHelpers.h"
1616
#include "MessageQueueThread.h"
17-
#include "SystraceSection.h"
17+
#include "TraceSection.h"
1818

1919
#include <logger/react_native_log.h>
2020

@@ -188,7 +188,7 @@ void CxxNativeModule::invoke(
188188
// mhorowitz #7128529: convert C++ exceptions to Java
189189

190190
const auto& moduleName = name_;
191-
SystraceSection s(
191+
TraceSection s(
192192
"CxxMethodCallQueue", "module", moduleName, "method", method.name);
193193
messageQueueThread_->runOnQueue([method,
194194
moduleName,
@@ -203,7 +203,7 @@ void CxxNativeModule::invoke(
203203
#else
204204
(void)(callId);
205205
#endif
206-
SystraceSection s(
206+
TraceSection s(
207207
"CxxMethodCallDispatch", "module", moduleName, "method", method.name);
208208
try {
209209
method.func(std::move(params), first, second);

packages/react-native/ReactCommon/cxxreact/Instance.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "NativeToJsBridge.h"
1717
#include "RAMBundleRegistry.h"
1818
#include "RecoverableError.h"
19-
#include "SystraceSection.h"
19+
#include "TraceSection.h"
2020

2121
#include <cxxreact/JSIndexedRAMBundle.h>
2222
#include <folly/json.h>
@@ -133,7 +133,7 @@ void Instance::loadBundle(
133133
std::unique_ptr<const JSBigString> string,
134134
std::string sourceURL) {
135135
callback_->incrementPendingJSCalls();
136-
SystraceSection s("Instance::loadBundle", "sourceURL", sourceURL);
136+
TraceSection s("Instance::loadBundle", "sourceURL", sourceURL);
137137
nativeToJsBridge_->loadBundle(
138138
std::move(bundleRegistry), std::move(string), std::move(sourceURL));
139139
}
@@ -145,14 +145,14 @@ void Instance::loadBundleSync(
145145
std::unique_lock<std::mutex> lock(m_syncMutex);
146146
m_syncCV.wait(lock, [this] { return m_syncReady; });
147147

148-
SystraceSection s("Instance::loadBundleSync", "sourceURL", sourceURL);
148+
TraceSection s("Instance::loadBundleSync", "sourceURL", sourceURL);
149149
nativeToJsBridge_->loadBundleSync(
150150
std::move(bundleRegistry), std::move(string), std::move(sourceURL));
151151
}
152152

153153
void Instance::setSourceURL(std::string sourceURL) {
154154
callback_->incrementPendingJSCalls();
155-
SystraceSection s("Instance::setSourceURL", "sourceURL", sourceURL);
155+
TraceSection s("Instance::setSourceURL", "sourceURL", sourceURL);
156156

157157
nativeToJsBridge_->loadBundle(nullptr, nullptr, std::move(sourceURL));
158158
}
@@ -161,7 +161,7 @@ void Instance::loadScriptFromString(
161161
std::unique_ptr<const JSBigString> string,
162162
std::string sourceURL,
163163
bool loadSynchronously) {
164-
SystraceSection s("Instance::loadScriptFromString", "sourceURL", sourceURL);
164+
TraceSection s("Instance::loadScriptFromString", "sourceURL", sourceURL);
165165
if (loadSynchronously) {
166166
loadBundleSync(nullptr, std::move(string), std::move(sourceURL));
167167
} else {
@@ -241,7 +241,7 @@ void Instance::callJSFunction(
241241
}
242242

243243
void Instance::callJSCallback(uint64_t callbackId, folly::dynamic&& params) {
244-
SystraceSection s("Instance::callJSCallback");
244+
TraceSection s("Instance::callJSCallback");
245245
callback_->incrementPendingJSCalls();
246246
nativeToJsBridge_->invokeCallback((double)callbackId, std::move(params));
247247
}

packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
1212

1313
#include "NativeModule.h"
14-
#include "SystraceSection.h"
14+
#include "TraceSection.h"
1515

1616
namespace facebook::react {
1717

@@ -46,7 +46,7 @@ void ModuleRegistry::updateModuleNamesFromIndex(size_t index) {
4646

4747
void ModuleRegistry::registerModules(
4848
std::vector<std::unique_ptr<NativeModule>> modules) {
49-
SystraceSection s_("ModuleRegistry::registerModules");
49+
TraceSection s_("ModuleRegistry::registerModules");
5050
// Noop if there are no NativeModules to add
5151
if (modules.empty()) {
5252
return;
@@ -81,7 +81,7 @@ void ModuleRegistry::registerModules(
8181
}
8282

8383
std::vector<std::string> ModuleRegistry::moduleNames() {
84-
SystraceSection s_("ModuleRegistry::moduleNames");
84+
TraceSection s_("ModuleRegistry::moduleNames");
8585
std::vector<std::string> names;
8686
for (size_t i = 0; i < modules_.size(); i++) {
8787
std::string name = normalizeName(modules_[i]->getName());
@@ -92,7 +92,7 @@ std::vector<std::string> ModuleRegistry::moduleNames() {
9292
}
9393

9494
std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
95-
SystraceSection s("ModuleRegistry::getConfig", "module", name);
95+
TraceSection s("ModuleRegistry::getConfig", "module", name);
9696

9797
// Initialize modulesByName_
9898
if (modulesByName_.empty() && !modules_.empty()) {
@@ -144,7 +144,7 @@ std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
144144
folly::dynamic config = folly::dynamic::array(name);
145145

146146
{
147-
SystraceSection s_("ModuleRegistry::getConstants", "module", name);
147+
TraceSection s_("ModuleRegistry::getConstants", "module", name);
148148
/**
149149
* In the case that there are constants, we'll initialize the NativeModule,
150150
* and signal moduleJSRequireEndingStart. Otherwise, we'll simply signal the
@@ -155,7 +155,7 @@ std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
155155
}
156156

157157
{
158-
SystraceSection s_("ModuleRegistry::getMethods", "module", name);
158+
TraceSection s_("ModuleRegistry::getMethods", "module", name);
159159
std::vector<MethodDescriptor> methods = module->getMethods();
160160

161161
folly::dynamic methodNames = folly::dynamic::array;

packages/react-native/ReactCommon/cxxreact/NativeToJsBridge.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "ModuleRegistry.h"
2222
#include "MoveWrapper.h"
2323
#include "RAMBundleRegistry.h"
24-
#include "SystraceSection.h"
24+
#include "TraceSection.h"
2525

2626
#include <memory>
2727

@@ -194,7 +194,7 @@ void NativeToJsBridge::callFunction(
194194
#ifdef WITH_FBSYSTRACE
195195
FbSystraceAsyncFlow::end(
196196
TRACE_TAG_REACT_CXX_BRIDGE, "JSCall", systraceCookie);
197-
SystraceSection s(
197+
TraceSection s(
198198
"NativeToJsBridge::callFunction", "module", module, "method", method);
199199
#else
200200
(void)(systraceCookie);
@@ -229,7 +229,7 @@ void NativeToJsBridge::invokeCallback(
229229
#ifdef WITH_FBSYSTRACE
230230
FbSystraceAsyncFlow::end(
231231
TRACE_TAG_REACT_CXX_BRIDGE, "<callback>", systraceCookie);
232-
SystraceSection s("NativeToJsBridge::invokeCallback");
232+
TraceSection s("NativeToJsBridge::invokeCallback");
233233
#else
234234
(void)(systraceCookie);
235235
#endif

0 commit comments

Comments
 (0)