[PATCH] D81981: [PGO] Supplement PGO profile with Sample profile

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 10:25:27 PDT 2020


wmi marked an inline comment as done.
wmi added a comment.

> I think this feature should be decoupled from the version change -- since this is an approximate anyway. One way to do this is to use max count or total count as a reference point and compute the scale factor.

If it is uncoupled from the version change, for function with counter values not being 0 in instr profile, it is ok to scale all the counter values by a scale factor based on max count or total count. For function with all counter values being 0, we cannot uniformly scale up all the counter values because that will mess up the branch probability inside of the function.  We want to set the entry BB counter to a hot value only so compiler can use static heuristic to compute the branch probability inside of the function. That is why entry BB counter is needed in this feature.



================
Comment at: llvm/tools/llvm-profdata/llvm-profdata.cpp:446
+    // counters as 0.
+    ProfRecord->Counts[0] = SampleEntryCount * ScaleFactor;
+    return;
----------------
davidxl wrote:
> when there is no scaling, setting instr count with sample count does not make sense. Perhaps just set it to be above cold threshold.
Maybe I can make scalefactor an option, and requires user to provide either -scalefactor or -base-scale-function, so that user won't accidentally leave scalefactor to be 1.

In this way, I can make sample profile to be the input of the option -supplement-instr-with-sample=, so I can remove the input profile ordering logic.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81981/new/

https://reviews.llvm.org/D81981





More information about the llvm-commits mailing list