Skip to content

Commit 870836f

Browse files
javachefacebook-github-bot
authored andcommitted
Namespace Perfetto usage (#53424)
Summary: Pull Request resolved: #53424 Use the namespaced version of these macros to avoid symbol conflicts when multiple instances of `PERFETTO_DEFINE_CATEGORIES` are in the same binary. The current macro is effectively deprecated: https://github.com/a6f/perfetto_protos/blob/master/CHANGELOG#L691-L696 Changelog: [Internal] Reviewed By: rshest Differential Revision: D80697205 fbshipit-source-id: 713fec4d41137ddd2f025c7e7130dc44c5a3a656
1 parent 42b94fc commit 870836f

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

packages/react-native/ReactCommon/reactperflogger/reactperflogger/FuseboxPerfettoDataSource.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const std::string JS_SAMPLING_TRACK = "JS Sampling";
2727

2828
const int SAMPLING_HZ = 1000;
2929

30-
using perfetto::TrackEvent;
31-
3230
#if defined(__ANDROID__)
3331
std::string getApplicationId() {
3432
pid_t pid = getpid();

packages/react-native/ReactCommon/reactperflogger/reactperflogger/HermesPerfettoDataSource.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const int SAMPLING_HZ = 100;
2323

2424
int64_t hermesDeltaTime = 0;
2525

26-
using perfetto::TrackEvent;
27-
2826
uint64_t hermesToPerfettoTime(int64_t hermesTs) {
2927
if (hermesDeltaTime == 0) {
3028
hermesDeltaTime = TrackEvent::GetTraceTimeNs() -
@@ -113,7 +111,7 @@ void HermesPerfettoDataSource::OnStart(const StartArgs&) {
113111
"react-native",
114112
perfetto::DynamicString{"Profiling Started"},
115113
getPerfettoWebPerfTrackSync("JS Sampling"),
116-
perfetto::TrackEvent::GetTraceTimeNs());
114+
TrackEvent::GetTraceTimeNs());
117115
}
118116

119117
void HermesPerfettoDataSource::OnFlush(const FlushArgs&) {

packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfetto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void initializePerfetto() {
2929
args.backends |= perfetto::kSystemBackend;
3030
args.use_monotonic_clock = true;
3131
perfetto::Tracing::Initialize(args);
32-
perfetto::TrackEvent::Register();
32+
TrackEvent::Register();
3333
});
3434

3535
HermesPerfettoDataSource::RegisterDataSource();
@@ -42,7 +42,7 @@ static perfetto::Track createTrack(const std::string& trackName) {
4242
auto track = perfetto::Track(trackId++);
4343
auto desc = track.Serialize();
4444
desc.set_name(trackName);
45-
perfetto::TrackEvent::SetTrackDescriptor(track, desc);
45+
TrackEvent::SetTrackDescriptor(track, desc);
4646
return track;
4747
}
4848

packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoCategories.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "ReactPerfettoCategories.h"
1111

12-
PERFETTO_TRACK_EVENT_STATIC_STORAGE();
12+
PERFETTO_TRACK_EVENT_STATIC_STORAGE_IN_NAMESPACE(facebook::react);
13+
PERFETTO_USE_CATEGORIES_FROM_NAMESPACE(facebook::react);
1314

1415
#endif

packages/react-native/ReactCommon/reactperflogger/reactperflogger/ReactPerfettoCategories.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
#include <perfetto.h>
1313

14-
PERFETTO_DEFINE_CATEGORIES(
14+
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE(
15+
facebook::react,
1516
perfetto::Category("react-native")
1617
.SetDescription("User timing events from React Native"));
1718

packages/react-native/ReactCxxPlatform/react/profiling/perfetto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void initializePerfetto() {
2323
#endif
2424
args.use_monotonic_clock = true;
2525
perfetto::Tracing::Initialize(args);
26-
perfetto::TrackEvent::Register();
26+
facebook::react::TrackEvent::Register();
2727
});
2828
}
2929

packages/react-native/ReactCxxPlatform/react/profiling/perfetto.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#if WITH_PERFETTO
1919
#include <perfetto.h>
2020

21-
PERFETTO_DEFINE_CATEGORIES(
21+
PERFETTO_DEFINE_CATEGORIES_IN_NAMESPACE(
22+
facebook::react,
2223
perfetto::Category("rncxx").SetDescription("Events from RN/Granite"));
2324

2425
void initializePerfetto();

0 commit comments

Comments
 (0)