[PATCH] D133083: [support] Allow TimeProfiler tracing across threads

Mark Shields via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 11:52:50 PDT 2022


mbs-modular updated this revision to Diff 461976.
mbs-modular added a comment.

[support] Allow TimeProfiler tracing across threads

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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133083/new/

https://reviews.llvm.org/D133083

Files:
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp
  llvm/unittests/Support/TimeProfilerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133083.461976.patch
Type: text/x-patch
Size: 11026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220921/6ea3c963/attachment.bin>


More information about the llvm-commits mailing list