[all-commits] [llvm/llvm-project] b03490: [ctxprof] Capture sampling info for context roots ...

Mircea Trofin via All-commits all-commits at lists.llvm.org
Fri Mar 14 21:10:43 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b034905c821884c59a8d882a1714b7a06bbbf6f3
      https://github.com/llvm/llvm-project/commit/b034905c821884c59a8d882a1714b7a06bbbf6f3
  Author: Mircea Trofin <mtrofin at google.com>
  Date:   2025-03-14 (Fri, 14 Mar 2025)

  Changed paths:
    M compiler-rt/lib/ctx_profile/CtxInstrContextNode.h
    M compiler-rt/lib/ctx_profile/CtxInstrProfiling.cpp
    M compiler-rt/lib/ctx_profile/CtxInstrProfiling.h
    M compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp
    M compiler-rt/test/ctx_profile/TestCases/generate-context.cpp
    M llvm/include/llvm/ProfileData/CtxInstrContextNode.h
    M llvm/include/llvm/ProfileData/PGOCtxProfReader.h
    M llvm/include/llvm/ProfileData/PGOCtxProfWriter.h
    M llvm/lib/ProfileData/PGOCtxProfReader.cpp
    M llvm/lib/ProfileData/PGOCtxProfWriter.cpp
    M llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp
    M llvm/test/Analysis/CtxProfAnalysis/flatten-and-annotate.ll
    M llvm/test/Analysis/CtxProfAnalysis/flatten-check-path.ll
    M llvm/test/Analysis/CtxProfAnalysis/flatten-icp.ll
    M llvm/test/Analysis/CtxProfAnalysis/flatten-zero-path.ll
    M llvm/test/Analysis/CtxProfAnalysis/full-cycle.ll
    M llvm/test/Analysis/CtxProfAnalysis/handle-select.ll
    M llvm/test/Analysis/CtxProfAnalysis/inline.ll
    M llvm/test/Analysis/CtxProfAnalysis/load-unapplicable.ll
    M llvm/test/Analysis/CtxProfAnalysis/load.ll
    M llvm/test/ThinLTO/X86/ctxprof.ll
    M llvm/test/Transforms/EliminateAvailableExternally/transform-to-local.ll
    A llvm/test/tools/llvm-ctxprof-util/Inputs/invalid-no-entrycount.yaml
    M llvm/test/tools/llvm-ctxprof-util/Inputs/valid-ctx-only.yaml
    M llvm/test/tools/llvm-ctxprof-util/Inputs/valid-flat-first.yaml
    M llvm/test/tools/llvm-ctxprof-util/Inputs/valid.yaml
    M llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util-negative.test
    M llvm/test/tools/llvm-ctxprof-util/llvm-ctxprof-util.test
    M llvm/unittests/ProfileData/PGOCtxProfReaderWriterTest.cpp
    M llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp

  Log Message:
  -----------
  [ctxprof] Capture sampling info for context roots (#131201)

When we collect a contextual profile, we sample the threads entering its root and only collect on one at a time (see `ContextRoot::Taken`). If we want to compare profiles between contextual profiles, and/or flat profiles, we have a problem: we don't know how to compare the counter values relative to each other. To that end, we add `ContextRoot::TotalEntries`, which is incremented every time a root is entered and serves as multiplier for the counter values collected under that root.

We expose this in the profile and leave the normalization to the user of the profile, for a few reasons:

* it's only needed if reasoning about all profiles in aggregate.
* the goal, in compiler_rt, is to flush out the profile as quickly as possible, and performing multiplications adds an overhead that may not even be necessary if the consumer of the profile doesn't care about combining profiles
* the information itself may be interesting as an indication of relative sampling of various contexts.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list