-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
PTHREAD_TRACE_PATH=trace.proto LD_PRELOAD=pthread_trace.so perf record program
This racily produces garbage results because both perf and program run pthread tracing, writing to the same file. We could open with O_EXCL to detect and report an error in this case (better than silently producing garbage data), but the combination of flags we are using means that the file needs to be deleted first, which is annoying.
Some other possibilities:
- If we could use a system-wide atomic to track which buffer to write next in the file, then this might actually work: you'd get pthread_trace data from both
perfandprogram. It would probably require some better method of getting thread IDs. - I think
pthread_tracewould be better as an executable that accepts a program (and arguments) to run in a child process (likeperf). Not sure how to do this with theLD_PRELOAD-like behavior.
Somehow the combination of perf and pthread_trace really impacts program performance, so this isn't something that people should do anyways. But when working on pthread_trace it is useful to be able to profile it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels