This is an archive of the discontinued LLVM Phabricator instance.

profi - a flow-based profile inference algorithm: Part III (out of 3)
ClosedPublic

Authored by spupyrev on Sep 17 2021, 9:56 AM.

Details

Summary

This is a continuation of D109860 and D109903.

An important challenge for profile inference is caused by the fact that the
sample profile is collected on a fully optimized binary, while the block and
edge frequencies are consumed on an early stage of the compilation that operates
with a non-optimized IR. As a result, some of the basic blocks may not have
associated sample counts, and it is up to the algorithm to deduce missing
frequencies. The problem is illustrated in the figure where three basic
blocks are not present in the optimized binary and hence, receive no samples
during profiling.

We found that it is beneficial to treat all such blocks equally. Otherwise the
compiler may decide that some blocks are “cold” and apply undesirable
optimizations (e.g., hot-cold splitting) regressing the performance. Therefore,
we want to distribute the counts evenly along the blocks with missing samples.
This is achieved by a post-processing step that identifies "dangling" subgraphs
consisting of basic blocks with no sampled counts; once the subgraphs are
found, we rebalance the flow so as every branch probability is 50:50 within the
subgraphs.

Our experiments indicate up to 1% performance win using the optimization on
some binaries and a significant improvement in the quality of profile counts
(when compared to ground-truth instrumentation-based counts)

Diff Detail

Event Timeline

spupyrev created this revision.Sep 17 2021, 9:56 AM
spupyrev requested review of this revision.Sep 17 2021, 9:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2021, 9:56 AM
spupyrev edited the summary of this revision. (Show Details)Sep 17 2021, 10:06 AM
spupyrev added reviewers: wenlei, hoy, wlei, davidxl, wmi, xur, rajeshwarv.
spupyrev updated this revision to Diff 373640.Sep 20 2021, 10:12 AM

adding a test for non-probe-based profile

hoy added inline comments.Dec 1 2021, 5:19 PM
llvm/lib/Transforms/Utils/SampleProfileInference.cpp
466

This is called "UnknownWeight" now?

spupyrev marked an inline comment as done.Dec 2 2021, 11:07 AM
hoy accepted this revision.Dec 2 2021, 11:28 AM
This revision is now accepted and ready to land.Dec 2 2021, 11:28 AM
This revision was landed with ongoing or failed builds.Dec 2 2021, 12:01 PM
This revision was automatically updated to reflect the committed changes.