Add perfetto tracing to host tooling#2502
Conversation
e958a29 to
8330f27
Compare
19542bf to
6e9eaf0
Compare
1d90f66 to
1727b13
Compare
|
This needs a couple upstream changes to Perfetto but generally ready for a first look. |
Databean
left a comment
There was a problem hiding this comment.
Not finished reviewing, but I'll leave the comments I have so far.
Bug: b/378560215 This would be useful for google/android-cuttlefish#2502 where we could eliminate most of https://github.com/google/android-cuttlefish/pull/2502/changes#diff-d28a094890e585d0e9bec027b845e31c3c15ebd9c2262dd814dd6e7537ab2af8 when using the c library via `dlopen()` and we do not want to directly depend on the library itself.
7be473c to
7e57fd5
Compare
Databean
left a comment
There was a problem hiding this comment.
Sorry, still not finished: I haven't fully reviewed TracingState, but have looked at everything else.
c7146ac to
fc5b377
Compare
google#2502 was incorrect. The previous behavior was to prefer `--gpu_mode=gfxstream` over `--gpu_mode=guest_swiftshader` prior to the Jolt changes. Bug: b/513229182
| return *sCached; | ||
| } | ||
|
|
||
| uint64_t GetThreadId() { return gettid(); } |
There was a problem hiding this comment.
Sorry to flip from my earlier comment on this, but I saw that the internal libc may not include gettid: b/456374254
Example cvd create trace: https://ui.perfetto.dev/#!/?s=b1b38a42593f61ee34c230f344e62f8c883ec747 Example cvd fetch trace: https://ui.perfetto.dev/#!/?s=cd5028170d015f9dd026228c7fd7dd81027b680e Perfetto uses a shared memory buffer between producer processes and the traced consumer daemon. `fork()` is problematic for this as the parent and child processes would end up clobbering each other when the shared memory buffer is inherited by the child. To prevent this, we introduce a "perfetto forwarder" (see TracingSession) that runs in the top level `cvd` process and that forwards trace events from child processes. Bug: b/378560215
Databean
left a comment
There was a problem hiding this comment.
Sorry, lost track of this change.
| sigset_t set; | ||
| sigemptyset(&set); | ||
| sigaddset(&set, SIGTERM); | ||
| CF_EXPECT_EQ(pthread_sigmask(SIG_BLOCK, &set, nullptr), 0, |
There was a problem hiding this comment.
The example for pthread_sigmask includes the comment
/* Block SIGQUIT and SIGUSR1; other threads created by main()
will inherit a copy of the signal mask. */Should the pthread_sigmask call be made before TracingServer::StartBlocking launches additional threads, so the threads have a chance to inherit the altered mask?
| shutting_down_ = true; | ||
| } | ||
|
|
||
| socket_->Shutdown(SHUT_RDWR); |
Example cvd create trace:
https://ui.perfetto.dev/#!/?s=b1b38a42593f61ee34c230f344e62f8c883ec747
Example cvd fetch trace:
https://ui.perfetto.dev/#!/?s=cd5028170d015f9dd026228c7fd7dd81027b680e