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

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 09:42:47 PDT 2021


hoy created this revision.
Herald added a subscriber: wenlei.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 both INT64_MAX and 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 zoer 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 sibling of the danling probe. A probe, when duplicate, 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 disgarded. Not reporting the dangling counterpart will keep the real samples.

5. Better readability.

6. Be consistent with non-probe profile.

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%.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104129

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104129.351480.patch
Type: text/x-patch
Size: 8149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/5ebb32b2/attachment.bin>


More information about the llvm-commits mailing list