[all-commits] [llvm/llvm-project] d6a058: [SampleFDO] Compute and report profile staleness m...

ictwanglei via All-commits all-commits at lists.llvm.org
Wed Oct 26 21:08:28 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d6a0585dd1b8cc82e827e3218fe3b077d33c3ed1
      https://github.com/llvm/llvm-project/commit/d6a0585dd1b8cc82e827e3218fe3b077d33c3ed1
  Author: wlei <wlei at fb.com>
  Date:   2022-10-26 (Wed, 26 Oct 2022)

  Changed paths:
    M llvm/include/llvm/ProfileData/SampleProf.h
    M llvm/lib/Transforms/IPO/SampleProfile.cpp
    A llvm/test/Transforms/SampleProfile/Inputs/profile-mismatch.prof
    A llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-profile-mismatch.prof
    A llvm/test/Transforms/SampleProfile/profile-mismatch.ll
    A llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll

  Log Message:
  -----------
  [SampleFDO] Compute and report profile staleness metrics

When a profile is stale and profile mismatch could happen, the mismatched samples are discarded, so we'd like to compute the mismatch metrics to quantify how stale the profile is, which will suggest user to refresh the profile if the number is high.

Two sets of metrics are introduced here:

 - (Num_of_mismatched_funchash/Total_profiled_funchash), (Samples_of_mismached_func_hash / Samples_of_profiled_function) : Here it leverages the FunctionSamples's checksums attribute which is a feature of pseudo probe. When the source code CFG changes, the function checksums will be different, later sample loader will discard the whole functions' samples, this metrics can show the percentage of samples are discarded due to this.
 -  (Num_of_mismatched_callsite/Total_profiled_callsite), (Samples_of_mismached_callsite / Samples_of_profiled_callsite) : This shows how many mismatching for the callsite location as callsite location mismatch will affect the inlining which is highly correlated with the performance. It goes through all the callsite location in the IR and profile, use the call target name to match, report the num of samples in the profile that doesn't match a IR callsite.

This is implemented in a new class(SampleProfileMatcher) and under a switch("--report-profile-staleness"), we plan to extend it with a fuzzy profile matching feature in the future.

Reviewed By: hoy, wenlei, davidxl

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




More information about the All-commits mailing list