diff options
author | Wei Mi <wmi@google.com> | 2020-07-08 15:19:44 -0700 |
---|---|---|
committer | Wei Mi <wmi@google.com> | 2020-07-27 20:17:40 -0700 |
commit | a23f62343cb79a3306fa64545db1d61c2d76b9ca (patch) | |
tree | 8f6dcf7a8c865338265e1cd5a9fb4379210aed17 /llvm/docs/CommandGuide/llvm-profdata.rst | |
parent | 23d6525cbdc9de7cbfe7640d1e9e4f25a0c5dd85 (diff) | |
download | llvm-a23f62343cb79a3306fa64545db1d61c2d76b9ca.zip llvm-a23f62343cb79a3306fa64545db1d61c2d76b9ca.tar.gz llvm-a23f62343cb79a3306fa64545db1d61c2d76b9ca.tar.bz2 |
Supplement instr profile with sample profile.
PGO profile is usually more precise than sample profile. However, PGO profile
needs to be collected from loadtest and loadtest may not be representative
enough to the production workload. Sample profile collected from production
can be used as a supplement -- for functions cold in loadtest but warm/hot
in production, we can scale up the related function in PGO profile if the
function is warm or hot in sample profile.
The implementation contains changes in compiler side and llvm-profdata side.
Given an instr profile and a sample profile, for a function cold in PGO
profile but warm/hot in sample profile, llvm-profdata will either mark
all the counters in the profile to be -1 or scale up the max count in the
function to be above hot threshold, depending on the zero counter ratio in
the profile. The assumption is if there are too many counters being zero
in the function profile, the profile is more likely to cause harm than good,
then llvm-profdata will mark all the counters to be -1 indicating the
function is hot but the profile is unaccountable. In compiler side, if a
function profile with all -1 counters is seen, the function entry count will
be set to be above hot threshold but its internal profile will be dropped.
In the long run, it may be useful to let compiler support using PGO profile
and sample profile at the same time, but that requires more careful design
and more substantial changes to make two profiles work seamlessly. The patch
here serves as a simple intermediate solution.
Differential Revision: https://reviews.llvm.org/D81981
Diffstat (limited to 'llvm/docs/CommandGuide/llvm-profdata.rst')
-rw-r--r-- | llvm/docs/CommandGuide/llvm-profdata.rst | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/docs/CommandGuide/llvm-profdata.rst b/llvm/docs/CommandGuide/llvm-profdata.rst index 13a66dc..6472320 100644 --- a/llvm/docs/CommandGuide/llvm-profdata.rst +++ b/llvm/docs/CommandGuide/llvm-profdata.rst @@ -161,6 +161,30 @@ OPTIONS coverage for the optimized target. This option can only be used with sample-based profile in extbinary format. +.. option:: -supplement-instr-with-sample=path_to_sample_profile + + Supplement an instrumentation profile with sample profile. The sample profile + is the input of the flag. Output will be in instrumentation format (only works + with -instr). + +.. option:: -zero-counter-threshold=threshold_float_number + + For the function which is cold in instr profile but hot in sample profile, if + the ratio of the number of zero counters divided by the the total number of + counters is above the threshold, the profile of the function will be regarded + as being harmful for performance and will be dropped. + +.. option:: -instr-prof-cold-threshold=threshold_int_number + + User specified cold threshold for instr profile which will override the cold + threshold got from profile summary. + +.. option:: -suppl-min-size-threshold=threshold_int_number + + If the size of a function is smaller than the threshold, assume it can be + inlined by PGO early inliner and it will not be adjusted based on sample + profile. + EXAMPLES ^^^^^^^^ Basic Usage |