[all-commits] [llvm/llvm-project] cef9b9: [CSSPGO] Report zero-count probe in profile instea...

Hongtao Yu via All-commits all-commits at lists.llvm.org
Wed Jun 16 11:46:14 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cef9b96b01b75fedea5e91ece776228f4088ba78
      https://github.com/llvm/llvm-project/commit/cef9b96b01b75fedea5e91ece776228f4088ba78
  Author: Hongtao Yu <hoy at fb.com>
  Date:   2021-06-16 (Wed, 16 Jun 2021)

  Changed paths:
    M llvm/include/llvm/ProfileData/SampleProf.h
    M llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
    M llvm/lib/ProfileData/SampleProf.cpp
    M llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-inline.prof
    M llvm/test/tools/llvm-profgen/fname-canonicalization.test
    M llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test
    M llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
    M llvm/test/tools/llvm-profgen/merge-cold-profile.test
    M llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
    M llvm/test/tools/llvm-profgen/truncated-pseudoprobe.test
    M llvm/tools/llvm-profgen/ProfileGenerator.cpp

  Log Message:
  -----------
  [CSSPGO] Report zero-count probe in profile instead of dangling probes.

Previously dangling samples were represented by INT64_MAX in sample profile while probes never executed were not reported. This was based on an observation that dangling probes were only at a smaller portion than zero-count probes. However, with compiler optimizations, dangling probes end up becoming at large portion of all probes in general and reporting them does not make sense from profile size point of view. This change flips sample reporting by reporting zero-count probes instead. This enabled dangling probe to be represented by none (missing entry in profile). This has a couple benefits:

1. Reducing sample profile size in optimize mode, even when the number of non-executed probes outperform the number of dangling probes, since INT64_MAX takes more space over 0 to encode.

2. Binary size savings. No need to encode dangling probe anymore, since missing probes are treated as dangling in the profile reader.

3. Reducing compiler work to track dangling probes. However, for probes that are real dead and removed, we still need the compiler to identify them so that they can be reported as zero-count, instead of mistreated as dangling probes.

4. Improving counts quality by respecting the counts already collected on the non-dangling copy of a probe. A probe, when duplicated, gets two copies at runtime. If one of them is dangling while the other is not, merging the two probes at profile generation time will cause the real samples collected on the non-dangling one to be discarded. Not reporting the dangling counterpart will keep the real samples.

5. Better readability.

6. Be consistent with non-CS dwarf line number based profile. Zero counts are trusted by the compiler counts inferencer while missing counts will be inferred by the compiler.

Note that the current patch does include any work for #3. There will be follow-up changes.

For #1, I've seen for a large Facebook service, the text profile is reduced by 7%. For extbinary profile, the size of  LBRProfileSection is reduced by 35%.

For #4, I have seen general counts quality for SPEC2017 is improved by 10%.

Reviewed By: wenlei, wlei, wmi

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




More information about the All-commits mailing list