LLVM 22.0.0git
llvm::sampleprof::DefaultFunctionPruningStrategy Class Reference

#include "llvm/ProfileData/SampleProfWriter.h"

Inheritance diagram for llvm::sampleprof::DefaultFunctionPruningStrategy:
[legend]

Public Member Functions

 DefaultFunctionPruningStrategy (SampleProfileMap &ProfileMap, size_t OutputSizeLimit)
void Erase (size_t CurrentOutputSize) override
 In this default implementation, functions with fewest samples are dropped first.
Public Member Functions inherited from llvm::sampleprof::FunctionPruningStrategy
 FunctionPruningStrategy (SampleProfileMap &ProfileMap, size_t OutputSizeLimit)
 ProfileMap A reference to the original profile map.
virtual ~FunctionPruningStrategy ()=default

Additional Inherited Members

Protected Attributes inherited from llvm::sampleprof::FunctionPruningStrategy
SampleProfileMapProfileMap
size_t OutputSizeLimit

Detailed Description

Definition at line 69 of file SampleProfWriter.h.

Constructor & Destructor Documentation

◆ DefaultFunctionPruningStrategy()

Member Function Documentation

◆ Erase()

void DefaultFunctionPruningStrategy::Erase ( size_t CurrentOutputSize)
overridevirtual

In this default implementation, functions with fewest samples are dropped first.

Since the exact size of the output cannot be easily calculated due to compression, we use a heuristic to remove as many functions as necessary but not too many, aiming to minimize the number of write iterations. Empirically, functions with larger total sample count contain linearly more sample entries, meaning it takes linearly more space to write them. The cumulative length is therefore quadratic if all functions are sorted by total sample count. TODO: Find better heuristic.

Implements llvm::sampleprof::FunctionPruningStrategy.

Definition at line 76 of file SampleProfWriter.cpp.

References assert(), D(), llvm::drop_begin(), llvm::sampleprof::FunctionPruningStrategy::OutputSizeLimit, llvm::sampleprof::FunctionPruningStrategy::ProfileMap, and round().


The documentation for this class was generated from the following files: