[all-commits] [llvm/llvm-project] 93a2c2: profi - a flow-based profile inference algorithm: ...

Hongtao Yu via All-commits all-commits at lists.llvm.org
Thu Dec 2 12:01:45 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93a2c2919f7339bd9e942ef69ebbf0883a2ef727
      https://github.com/llvm/llvm-project/commit/93a2c2919f7339bd9e942ef69ebbf0883a2ef727
  Author: spupyrev <spupyrev at fb.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/SampleProfileInference.cpp
    A llvm/test/Transforms/SampleProfile/Inputs/profile-inference-noprobes.prof
    A llvm/test/Transforms/SampleProfile/Inputs/profile-inference-rebalance.prof
    A llvm/test/Transforms/SampleProfile/profile-inference-noprobes.ll
    A llvm/test/Transforms/SampleProfile/profile-inference-rebalance.ll
    M llvm/test/Transforms/SampleProfile/profile-inference.ll

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

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)

{F19093045}

Reviewed By: hoy

Differential Revision: https://reviews.llvm.org/D109980




More information about the All-commits mailing list