[PATCH] D145171: [FSAFDO] Improve FS discriminator encoding

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 10:11:49 PST 2023


xur created this revision.
xur added reviewers: hoy, wenlei, shenhan.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
xur requested review of this revision.
Herald added a project: LLVM.

This change improves FS discriminators in the following ways:
(1) use call-stack debug information in the discriminator hash:
the same (src/line) DILs can now have different hash if they
come from different call-stacks. This reduces the hash conflicts.
(2) use BB size in the hash: this helps to detect mismatch.
(3) don't generate the FS discriminator for meta instructions
(i.e.  instructions not emitted). This reduces the number
discriminators conflicts (for the case we run out of discriminator
bits for that pass).

These improvements should bring better performance for FSAFDO
and they should be used by default. But this change creates
incompatible FS discriminators. For the iterative profile users,
they might see an performance drop in the first release with
this change (due to the fact that the profiles have the old
discriminators and the compiler uses the new discriminator).
We have measured that this is not more than 1.5% on several
benchmarks. Note the degradation should be gone in the second
release and one should expect a performance gain over the binary
without this change.

One possible solution to the iterative profile issue would be
separating discriminators for profile-use and the ones emitted to
the binary. This would require a mechanism to allow two sets of
discriminators to be maintained and then phasing out the first
approach. This is too much churn in the compiler and the
performance implications do not seem to be worth the effort.

Instead, we put the changes under an option so iterative profile
users can do a gradual rollout of this change. I will make the
option default value to true in a later patch and eventually
purge this option from the code base.


https://reviews.llvm.org/D145171

Files:
  llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
  llvm/lib/CodeGen/MIRFSDiscriminator.cpp
  llvm/lib/CodeGen/MIRSampleProfile.cpp
  llvm/test/CodeGen/X86/Inputs/fsloader_v1.afdo
  llvm/test/CodeGen/X86/fsafdo_test1.ll
  llvm/test/CodeGen/X86/fsafdo_test2.ll
  llvm/test/CodeGen/X86/fsafdo_test3.ll
  llvm/test/CodeGen/X86/fsafdo_test4.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145171.501911.patch
Type: text/x-patch
Size: 19470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230302/33b9332e/attachment.bin>


More information about the llvm-commits mailing list