Skip to main content

PgoPass

Struct PgoPass 

Source
pub struct PgoPass {
    pub config: PgoConfig,
    pub profile: ProfileData,
}
Expand description

The profile-guided optimisation pass.

Consumes a ProfileData snapshot and a PgoConfig, then answers per-site queries such as “should I inline this callee?” and produces a bulk OptAction recommendation list via PgoPass::optimize_call_sites.

Fields§

§config: PgoConfig§profile: ProfileData

Implementations§

Source§

impl PgoPass

Source

pub fn new(config: PgoConfig) -> Self

Create a new PgoPass with the given configuration and an empty profile.

Source

pub fn load_profile(&mut self, data: ProfileData)

Replace the current profile with data.

Source

pub fn should_inline(&self, func_name: &str, size_estimate: usize) -> bool

Return true when func_name should be inlined at a call site whose callee has an estimated IR size of size_estimate nodes.

Inlining is enabled when:

  • config.inline_hot is set, AND
  • func_name is hot (exceeds the threshold), AND
  • size_estimate <= config.max_inline_size.
Source

pub fn should_specialize(&self, func_name: &str) -> bool

Return true when a specialised clone of func_name should be generated.

Specialisation is enabled when:

  • config.specialize_hot is set, AND
  • func_name is hot.
Source

pub fn optimize_call_sites( &self, functions: &[(String, usize)], ) -> Vec<OptAction>

Produce a list of OptAction recommendations for a collection of (function_name, size_estimate) pairs representing call sites.

The index of each entry in functions is used as the call_site discriminant for Specialize actions.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.