google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.73k stars 341 forks source link

feature request: Let tracebox (in autostart mode) pick the same producer / consumer socket names as standalone `traced` #850

Closed q-p closed 1 month ago

q-p commented 1 month ago

If you run a system trace with an application that uses the perfetto SDK, it finds the separately started traced by default, since they pick the same names for the relevant sockets. Everything works fine. (On my RHEL8 system, these were /tmp/perfetto-producer and /tmp/perfetto-producer. I do not have write access to /run.)

But when running tracebox in the very convenient autostart mode (where it launches traced and traced_probes for you), then it picks distinct names, leading to the SDK-using application not being able to connect to the traced launched by tracebox. (On my RHEL8 system, traced reports @traced-p-NUMBER and @traced-c-NUMBER.)

For my use case (essentially wanting to record SDK track_events as well as memory usage) it would be convenient to have an option for tracebox to pick the same defaults as a standalone traced invocation would, so it's easier to set up a matching pair.

As a work-around, I can set PERFETTO_CONSUMER_SOCK_NAME / PERFETTO_PRODUCER_SOCK_NAME environment variables as appropriate for either of the invocations so they can find each other.

LalitMaganti commented 1 month ago

For context for those reading it, @q-p and I debugging this on Discord. I think the correct solution here is to add some option to tracebox to use the default system sockets. I was thinking a command line option like --system or similar.

Thanks for filing!

primiano commented 1 month ago

Yeah i'm supportive of --system-sockets or something similar. The reason why this is done this way is really android: in android there is no chance that the sideloaded traced can take over the default /dev/socket/traced-{consumer,producer} because that requires the union of root + complicated SELinux shenanigans. I wanted something that works out-of-the-box hence the abstract sockets being used.

LalitMaganti commented 1 month ago

https://r.android.com/3194924 should fix this.