Skip to main content

Profile

Struct Profile 

Source
pub struct Profile {
    pub requested: bool,
    pub path: Option<String>,
    pub dir: Option<String>,
    pub absolute: bool,
    pub correction: bool,
    pub partial_training: bool,
}
Expand description

What the profile reading half of the -fprofile family asked for.

A profile is a count per edge, gathered by running a build of the program that was instrumented to count, and read back on a second compilation so that the optimizer knows which way each branch actually went. It is worth more than any single optimization, because almost everything the optimizer decides is a guess about a frequency that the counts simply state.

Nothing here reads one yet, so this is recorded rather than acted on, and the family splits in two rather than being taken or refused as a whole. The half recorded here is the half that only costs speed when it is ignored: a build that asks to read a profile and is not read one gets the program it would have got anyway, which is what section 4.1 means by a hint about speed. The other half writes files, and that half is refused by the driver rather than landing here, on the same reading -gsplit-dwarf gets: a program instrumented by -fprofile-generate writes a .gcda when it runs and -ftest-coverage writes a .gcno beside the object, and ignoring either means a build waits for a file that never arrives and then quietly optimizes against no counts at all.

gcc’s own measurement is the argument for the split. -fprofile-use on a file with no counts beside it produces an object byte for byte identical to the one no flag produces, and warns; the same file under -fprofile-generate grows from 71 bytes of code to 375 with 296 bytes of counters beside it. So one half of the family is already a no-op in gcc when there is nothing to read, and the other half is never one.

Fields§

§requested: bool

Whether the last of -fprofile-use and -fno-profile-use on the command line was the first of the two.

§path: Option<String>

Where to read the counts from, from -fprofile-use=<path>, where None means beside the object the way gcc looks when nobody says. A directory or a file, which is gcc’s rule and is not something this can tell apart without looking at the filesystem.

§dir: Option<String>

Where the whole family’s files live, from -fprofile-dir=. Separate from path because gcc keeps them separate: this one moves the counts for the generating half as well.

§absolute: bool

Whether the path recorded in those files is made absolute, from -fprofile-abs-path. It is what a build with several object directories under one source tree needs so that two files of the same name do not land on one set of counts.

§correction: bool

Whether counts that do not add up are repaired rather than refused, from -fprofile-correction. A program that forked or was killed while it ran leaves counts that no single execution could have produced, and this says to make the best of them.

§partial_training: bool

Whether the parts of the program the training run never reached are optimized as if they were cold rather than as if nothing were known about them, from -fprofile-partial-training.

Trait Implementations§

Source§

impl Clone for Profile

Source§

fn clone(&self) -> Profile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Profile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Profile

Source§

fn default() -> Profile

Returns the “default value” for a type. Read more
Source§

impl Eq for Profile

Source§

impl PartialEq for Profile

Source§

fn eq(&self, other: &Profile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Profile

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.