Skip to main content

Cache

Struct Cache 

Source
pub struct Cache { /* private fields */ }
Expand description

A store rooted at a project.

Implementations§

Source§

impl Cache

Source

pub fn open(root: &Path, opts: Options) -> Option<Self>

None when the caller turned caching off, or when this build cannot identify itself well enough to be sure an entry is its own.

Source

pub fn stats(&self) -> Stats

What this run has done with the store so far.

Source

pub fn mode(&self) -> Mode

The grain this store was opened with. A caller that decides between a per-module walk and a whole-run lookup asks the store rather than re-reading the flags, so the two cannot disagree.

Source

pub fn lookup_all( &self, keys: &[Key], run: &Key, files: usize, ) -> Vec<Option<Module>>

What each file in the walk reported last time; None where it has to be checked.

Under WholeRun this is all-or-nothing by construction: one entry covers the walk, so a single changed input means every module is checked.

Source

pub fn lookup(&self, key: &Key) -> Option<Module>

What the module reported last time, if every input and probe still matches.

Source

pub fn store_module( &self, key: &Key, file: &Path, extra_inputs: &[PathBuf], dirs: &[PathBuf], module: &Module, )

Record what one module reported. Best-effort: a store that cannot be written leaves the next run to do the work again, which is slow rather than wrong.

Source

pub fn store_run( &self, key: &Key, files: &[PathBuf], extra_inputs: &[PathBuf], dirs: &[PathBuf], modules: &[Module], )

Record the whole walk as one entry. Its inputs are the union of every module’s, so any edit anywhere misses — which is the behaviour this mode is chosen for.

Source

pub fn sweep(&self, keep: &[Key], files: usize)

Drop entries this run did not use, once the store has outgrown what the project warrants.

Nothing else removes an entry. The key covers the paths as written, the lint selection and the working directory, so every distinct way of invoking the check leaves a full set of module entries behind — a lint flag tried once doubles the store permanently, and a deleted module’s entry is never read again. htl check sees the whole graph in one process, which is what lets this be exact about the orphans rather than sampling the way ccache has to.

Two passes. Entries whose recorded inputs have all gone describe modules that no longer exist, and go first. If the store is still over, the oldest go until it fits.

This uses mtimes, and #3’s rule against them still holds. That rule is about invalidation, where trusting a timestamp means replaying a stale result and reporting something untrue. Dropping an entry that was still good costs the check it would have skipped and nothing else. The two questions deserve different tools.

“Oldest” is least recently used: a hit touches its entry, which is what makes the two differ. Without that it would mean least recently written, and the shape run most often — written first — would age out while a shape tried once survived.

Auto Trait Implementations§

§

impl !Freeze for Cache

§

impl !RefUnwindSafe for Cache

§

impl !Sync for Cache

§

impl Send for Cache

§

impl Unpin for Cache

§

impl UnsafeUnpin for Cache

§

impl UnwindSafe for Cache

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

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.