[all-commits] [llvm/llvm-project] 244be0: [InstrProf] Temporal Profiling

Ellis Hoag via All-commits all-commits at lists.llvm.org
Tue Apr 11 08:31:06 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 244be0b0de198fbe8a0861bb8f75509f610b57a4
      https://github.com/llvm/llvm-project/commit/244be0b0de198fbe8a0861bb8f75509f610b57a4
  Author: Ellis Hoag <ellis.sparky.hoag at gmail.com>
  Date:   2023-04-11 (Tue, 11 Apr 2023)

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

  Log Message:
  -----------
  [InstrProf] Temporal Profiling

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 //trace// and add it to the indexed profile.

Since these traces could significantly increase the profile size, we've added `-max-temporal-profile-trace-length` and `-temporal-profile-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.

Special thanks to Julian Mestre for helping with reservoir sampling.

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

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D147287




More information about the All-commits mailing list