mstange / samply

Command-line sampling profiler for macOS and Linux
Apache License 2.0
2.04k stars 49 forks source link

Only request elevation once #175

Closed mstange closed 2 months ago

mstange commented 2 months ago

The UAC prompt when stopping the profiler is very annoying.

This PR adds a helper process that only needs to be elevated once and which launches both xperf processes. In the future we'll be able to use this helper process to implement more of what xperf is doing at the moment.

I got a bit carried away during the implementation. There's probably a simpler implementation hiding in there. The current implementation uses no less than four lock files, and two more files for the actual IPC messages, all stored in a TempDir.

mstange commented 2 months ago

I got a bit carried away during the implementation. There's probably a simpler implementation hiding in there. The current implementation uses no less than four lock files, and two more files for the actual IPC messages, all stored in a TempDir.

I decided to stick with the somewhat over-engineered implementation. It's not just the helper process that needs to block on receiving the "stop" message from the parent; the parent also needs to wait for the helper process to tell it when xperf has started, so that it doesn't launch the recorded process too early. And any errors from the helper process need to be propagated to the parent.