Page MenuHomePhabricator

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

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



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

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