You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 perf and program. It would probably require some better method of getting thread IDs.
I think pthread_trace would be better as an executable that accepts a program (and arguments) to run in a child process (like perf). Not sure how to do this with the LD_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.
The text was updated successfully, but these errors were encountered:
This racily produces garbage results because both
perf
andprogram
run pthread tracing, writing to the same file. We could open withO_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:
perf
andprogram
. It would probably require some better method of getting thread IDs.pthread_trace
would 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
andpthread_trace
really impacts program performance, so this isn't something that people should do anyways. But when working onpthread_trace
it is useful to be able to profile it.The text was updated successfully, but these errors were encountered: