Skip to content

Commit 8a6508c

Browse files
Benoit Girardfacebook-github-bot
authored andcommitted
Increase the buffer size and try kStall to avoid dropping samples (facebook#45111)
Summary: Pull Request resolved: facebook#45111 Spent time debugging this issue today: https://fb.workplace.com/groups/1700234700326965/posts/2197109080639522 The problem is described here: https://perfetto.dev/docs/concepts/buffers But basically we're writing too much data, too fast and the traced process can't read it fast enough. Perfetto is doing data drop. This diff tries to use the `kStall` mode. It doesn't seem to do much but I'll leave it in for now because it shouldn't hurt too much. It's designed for our use case. The main fix comes from increasing the buffer size to 20MB. Since it's not on by default I think it's fine to have a really large buffer for now to unblock tracing. Reviewed By: javache Differential Revision: D58832598 fbshipit-source-id: 101b364e2e9e28aa6a041ded1df82d5fec1f42e1
1 parent 34cd195 commit 8a6508c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class HermesPerfettoDataSource
2727
dsd.set_name("com.facebook.hermes.profiler");
2828
HermesPerfettoDataSource::Register(dsd);
2929
}
30+
31+
constexpr static perfetto::BufferExhaustedPolicy kBufferExhaustedPolicy =
32+
perfetto::BufferExhaustedPolicy::kStall;
3033
};
3134

3235
PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(HermesPerfettoDataSource);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ std::once_flag perfettoInit;
1717
void initializePerfetto() {
1818
std::call_once(perfettoInit, []() {
1919
perfetto::TracingInitArgs args;
20+
// Raise the size of the shared memory buffer. Since this
21+
// is only used in tracing build, large buffers are okay
22+
// for now.
23+
args.shmem_size_hint_kb = 20 * 1024;
2024
args.backends |= perfetto::kSystemBackend;
2125
args.use_monotonic_clock = true;
2226
perfetto::Tracing::Initialize(args);

0 commit comments

Comments
 (0)