[llvm] [llvm-profgen] Improve sample profile density (PR #92144)
Lei Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed May 22 14:10:27 PDT 2024
================
@@ -768,9 +748,89 @@ void ProfileGenerator::populateBoundarySamplesForAllFunctions(
}
}
+// Note taht ideally the size should be the number of function's instruction.
+// However, for probe-based profile, we don't have the accurate instruction
+// count for each probe, Instead, the probe sample is the samples count for the
+// block, which is equivelant to total_instruction_samples/num_instruction in
+// one block. Hence, we use the number of probe as a proxy for the function's
+// size.
+void ProfileGeneratorBase::calculateBodySamplesAndSize(
+ const FunctionSamples &FSamples, uint64_t &TotalBodySamples,
----------------
wlei-llvm wrote:
It should be no difference for probe-based profile. But very different to line-number based (AutoFDO) profile, in which the entry is the max of the counts in the same line, however, the total_samples is a sum of all the counts in the same line, so the `getTotalSamples` is much bigger than sum of each entry. In this case, if we adjust to use the binary instruction size, it also should be good (use `getTotalSamples`/ binary_size)
Or How about we diverged the function size calculation:
For pseudo-probe, we use the way in this version.
for line-number, we use the binary size.
https://github.com/llvm/llvm-project/pull/92144
More information about the llvm-commits
mailing list