[PGO] Improve the working set size heuristics under the partial sample PGO.
authorHiroshi Yamauchi <yamauchi@google.com>
Wed, 8 Apr 2020 23:06:25 +0000 (16:06 -0700)
committerHiroshi Yamauchi <yamauchi@google.com>
Mon, 1 Jun 2020 17:29:23 +0000 (10:29 -0700)
commit6c27c61d32fd2951a290c6d4363bd495f6feae96
tree5705eab27cf3722798ee7adfa937f741c220414b
parent20793b2aef1c7589cff1c35194f1463e747cb1a5
[PGO] Improve the working set size heuristics under the partial sample PGO.

Summary:
The working set size heuristics (ProfileSummaryInfo::hasHugeWorkingSetSize)
under the partial sample PGO may not be accurate because the profile is partial
and the number of hot profile counters in the ProfileSummary may not reflect the
actual working set size of the program being compiled.

To improve this, the (approximated) ratio of the the number of profile counters
of the program being compiled to the number of profile counters in the partial
sample profile is computed (which is called the partial profile ratio) and the
working set size of the profile is scaled by this ratio to reflect the working
set size of the program being compiled and used for the working set size
heuristics.

The partial profile ratio is approximated based on the number of the basic
blocks in the program and the NumCounts field in the ProfileSummary and computed
through the thin LTO indexing. This means that there is the limitation that the
scaled working set size is available to the thin LTO post link passes only.

Reviewers: davidxl

Subscribers: mgorny, eraman, hiraditya, steven_wu, dexonsmith, arphaman, dang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79831
llvm/include/llvm/IR/Module.h
llvm/include/llvm/IR/ProfileSummary.h
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/IR/Module.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
llvm/unittests/IR/ModuleTest.cpp