LLVM 19.0.0git
Public Member Functions | List of all members
llvm::sampleprof::DefaultFunctionPruningStrategy Class Reference

#include "llvm/ProfileData/SampleProfWriter.h"

Inheritance diagram for llvm::sampleprof::DefaultFunctionPruningStrategy:
Inheritance graph

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
virtual void Erase (size_t CurrentOutputSize)=0
 SampleProfileWriter::writeWithSizeLimit() calls this after every write iteration if the output size still exceeds the limit.

Additional Inherited Members

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

Detailed Description

Definition at line 68 of file SampleProfWriter.h.

Constructor & Destructor Documentation

◆ DefaultFunctionPruningStrategy()

DefaultFunctionPruningStrategy::DefaultFunctionPruningStrategy ( SampleProfileMap ProfileMap,
size_t  OutputSizeLimit 

Member Function Documentation

◆ Erase()

void DefaultFunctionPruningStrategy::Erase ( size_t  CurrentOutputSize)

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 78 of file SampleProfWriter.cpp.

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

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