[llvm] [PGO] Sampled instrumentation in PGO to speed up instrumentation binary (PR #69535)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 09:13:17 PDT 2023


================
@@ -412,30 +424,91 @@ PreservedAnalyses InstrProfiling::run(Module &M, ModuleAnalysisManager &AM) {
   return PreservedAnalyses::none();
 }
 
+// Perform instrumentation sampling.
+// We transform:
+//   Increment_Instruction;
+// to:
+//   if (__llvm_profile_sampling__ <= SampleDuration) {
+//     Increment_Instruction;
+//   }
+//   __llvm_profile_sampling__ += 1;
----------------
WenleiHe wrote:

> xur@'s sampling scheme is bursty style which seems less likely to introduce bias compared with every N hits scheme

Why? In general, sampling needs to be evenly distributed to avoid bias. HW sampling doesn't do burst either.  Do you have data and example to illustrate the benefit of bursty sampling? 

The only reason I can see to choose bursty sample is to open up the opportunity for coalescing increments, but that is not done here. 

https://github.com/llvm/llvm-project/pull/69535


More information about the llvm-commits mailing list