[all-commits] [llvm/llvm-project] c2e08a: [llvm-profgen] Compute and show profile density

ictwanglei via All-commits all-commits at lists.llvm.org
Tue Nov 30 00:00:32 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c2e08aba1afd5a69dbe74b03ce6f463d45102222
      https://github.com/llvm/llvm-project/commit/c2e08aba1afd5a69dbe74b03ce6f463d45102222
  Author: wlei <wlei at fb.com>
  Date:   2021-11-29 (Mon, 29 Nov 2021)

  Changed paths:
    A llvm/test/tools/llvm-profgen/Inputs/profile-density-cs.raw.prof
    A llvm/test/tools/llvm-profgen/Inputs/profile-density.raw.prof
    A llvm/test/tools/llvm-profgen/profile-density.test
    M llvm/tools/llvm-profgen/ProfileGenerator.cpp
    M llvm/tools/llvm-profgen/ProfileGenerator.h
    M llvm/tools/llvm-profgen/ProfiledBinary.h

  Log Message:
  -----------
  [llvm-profgen] Compute and show profile density

AutoFDO performance is sensitive to profile density, i.e., the amount of samples in the profile relative to the program size, because profiles with insufficient samples could be inaccurate due to statistical noise and thus hurt AutoFDO performance. A previous investigation showed that AutoFDO performed better on MySQL with increased amount of samples. Therefore, we implement a profile-density computation feature to give hints about profile density to users and the compiler.

We define the density of a profile Prof as follows:

- For each function A in the profile, density(A) = total_samples(A) / sizeof(A).
- density(Prof) = min(density(A)) for all functions A that are warm (defined below).

A function is considered warm if its total-samples is within top N percent of the profile. For implementation, we reuse the `ProfileSummaryBuilder::getHotCountThreshold(..)` as threshold which can be set by percent(`--profile-summary-cutoff-hot`) or by value(`--profile-summary-hot-count`).

We also introduce `--hot-function-density-threshold` to set hot function density threshold and will give suggestion if profile density is below it which implies we should increase samples.

This also applies for CS profile with all profiles merged into base.

Reviewed By: hoy, wenlei

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




More information about the All-commits mailing list