perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

Feature Request: perfetto option to close any/all tracing sessions

Open auselen opened this issue 1 year ago • 4 comments

I'm running tracebox as traced* (_probe, _perf) and if my workflow is interrupted and a tracing session is not terminated, I don't want to do a killall tracebox since that stops traced* as well. Also finding which tracebox is doing tracing isn't trivial.

Would it be possible if perfetto/tracebox had an option to terminate current tracing sessions? Finer solutions like --querying "TRACING SESSIONS" then terminating with ID could also work, but tbh I just want to make sure when my script runs, there isn't any leftover tracing session from before.

auselen avatar Oct 28 '25 09:10 auselen

You are right, killall tracebox is too broad as all of them have same short name (tracebox).

So please try pkill -f to filter by full command line arguments.

sashwinbalaji@ashwinbalaji:~/Desktop/perfetto$ ps -eo pid,comm,args | grep tracebox
4140490 tracebox        ./out/linux_clang_debug/tracebox traced
4140725 tracebox        ./out/linux_clang_debug/tracebox traced_probes
4151989 tracebox        ./out/linux_clang_debug/tracebox perfetto --txt -c config_pbtxt -o mock.pftrace
4152075 tracebox        ./out/linux_clang_debug/tracebox perfetto --txt -c config_pbtxt -o mock_1.pftrace

sashwinbalaji@ashwinbalaji:~/Desktop/perfetto$ pkill -f "tracebox perfetto"

sashwinbalaji@ashwinbalaji:~/Desktop/perfetto$ ps -eo pid,comm,args | grep tracebox
4140490 tracebox        ./out/linux_clang_debug/tracebox traced
4140725 tracebox        ./out/linux_clang_debug/tracebox traced_probes

sashwinbalaji avatar Oct 28 '25 14:10 sashwinbalaji

Got it, thanks. Feel free to close the issue if you like.

auselen avatar Oct 28 '25 15:10 auselen

Though low in priority but your request is a fair one and we'll like to keep the issue open so we can work on it when time permits.

sashwinbalaji avatar Oct 28 '25 16:10 sashwinbalaji

Honestly this is a bit of a very specific/niche request.

For posterity, today we have (tracebox) perfetto --query which prints all sessions (for the current uid, or all of them if the invoker is root)

We could in theory implement a perfetto --abort SESSION_ID, my fear is that this (1) would be very undiscoverable and niche, (2) would create yet another complicated case in the already-complicated TracingServiceImpl, which I'd prefer to avoid given this feels a bit of a rare thing.

Closing for now

primiano avatar Nov 06 '25 16:11 primiano