[PATCH] D133083: [support] Allow TimeProfiler tracing across threads
Mark Shields via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 20:07:30 PDT 2022
mbs-modular created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mbs-modular requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This change allows a TimeProfiler profiling entry to be created
on one thread and finished on another. This was triggered by a use
case where we needed to trace the scheduling delay for work items
ultimately handled by independent worker threads.
The clock is changed to std::chrono::high_resolution_clock, both for
its increased precision (our work items can be in the us range), but
also for its cross-thread consistency (all threads see the same clock).
As a pleasant side effect it is now possible to pay for the cost of
constructing a profiling entry with a possibly expensive detail string
outside of the critical section we wish to trace. I think we could do
better with shifting the cost of constructing detail strings to the final
trace writing phase, given the API already supports providing detail
strings via a callback. But I've not audited the code to check if
detail closures could have their lifetimes safely extended so dramatically.
Could not find unit tests, please let me know if I missed them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133083
Files:
llvm/include/llvm/Support/TimeProfiler.h
llvm/lib/Support/TimeProfiler.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133083.457161.patch
Type: text/x-patch
Size: 15692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220901/fca781f6/attachment.bin>
More information about the llvm-commits
mailing list