[PATCH] D147287: [InstrProf] Temporal Profiling

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 09:52:50 PDT 2023


ellis created this revision.
Herald added subscribers: Enna1, wenlei, jdoerfert, mgrang, hiraditya.
Herald added a project: All.
ellis edited the summary of this revision.
ellis added reviewers: phosek, xur, MaskRay, kyulee, wenlei, gulfem, snehasish.
Herald added a subscriber: wlei.
ellis published this revision for review.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

As described in [0], this extends IRPGO to support //Temporal Profiling//.

When `-pgo-temporal-instrumentation` is used we add the `llvm.instrprof.timestamp()` intrinsic to the entry of functions which in turn gets lowered to a call to the compiler-rt function `INSTR_PROF_PROFILE_SET_TIMESTAMP()`. A new field in the `llvm_prf_cnts` section stores each function's timestamp. Then in `llvm-profdata merge` we convert these function timestamps into a //function trace// and add it to the indexed profile.

Since these traces could significantly increase the profile size, we've added `-max-trace-length` and `-trace-reservoir-size` to limit the length of a trace and the number of traces in a profile, respectively.

In a future diff we plan to use these traces to construct an optimized function order to reduce the number of page faults during startup.

[0] https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147287

Files:
  compiler-rt/include/profile/InstrProfData.inc
  compiler-rt/lib/profile/InstrProfiling.c
  compiler-rt/test/profile/instrprof-timestamp.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/ProfileData/InstrProfWriter.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/InstrProfWriter.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Instrumentation/InstrProfiling/timestamp-coverage.ll
  llvm/test/Instrumentation/InstrProfiling/timestamp.ll
  llvm/test/Transforms/PGOProfile/timestamp.ll
  llvm/test/tools/llvm-profdata/merge-traces.proftext
  llvm/test/tools/llvm-profdata/read-traces.proftext
  llvm/test/tools/llvm-profdata/trace-limit.proftext
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147287.509865.patch
Type: text/x-patch
Size: 54063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230403/403b4b25/attachment.bin>


More information about the llvm-commits mailing list