[llvm] [PGO] Sampled instrumentation in PGO to speed up instrumentation binary (PR #69535)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 16:24:32 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;
----------------
snehasish wrote:
This seems more like `firstN of 64K` rather than random sampling. I have a couple of concerns.
1. This seems like it could easily introduce bias.
2. We introduce yet another knob for tuning `sampled-instr-duration`. If it was randomized then we won't have to worry about this knob. A fast random implementation may not be too much increase in overhead compared to this approach.
https://github.com/llvm/llvm-project/pull/69535
More information about the llvm-commits
mailing list