Skip to content

Commit

Permalink
Increase the buffer size and try kStall to avoid dropping samples (#4…
Browse files Browse the repository at this point in the history
…5111)

Summary:
Pull Request resolved: #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
  • Loading branch information
Benoit Girard authored and facebook-github-bot committed Jun 21, 2024
1 parent 34cd195 commit 8a6508c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class HermesPerfettoDataSource
dsd.set_name("com.facebook.hermes.profiler");
HermesPerfettoDataSource::Register(dsd);
}

constexpr static perfetto::BufferExhaustedPolicy kBufferExhaustedPolicy =
perfetto::BufferExhaustedPolicy::kStall;
};

PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(HermesPerfettoDataSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ std::once_flag perfettoInit;
void initializePerfetto() {
std::call_once(perfettoInit, []() {
perfetto::TracingInitArgs args;
// Raise the size of the shared memory buffer. Since this
// is only used in tracing build, large buffers are okay
// for now.
args.shmem_size_hint_kb = 20 * 1024;
args.backends |= perfetto::kSystemBackend;
args.use_monotonic_clock = true;
perfetto::Tracing::Initialize(args);
Expand Down

0 comments on commit 8a6508c

Please sign in to comment.