VecCache in rustc_data_structures::vec_cache - Rust (original) (raw)

pub struct VecCache<K: Idx, V, I> {
    buckets: [AtomicPtr<Slot<V>>; 21],
    present: [AtomicPtr<Slot<()>>; 21],
    len: AtomicUsize,
    key: PhantomData<(K, I)>,
}

Expand description

In-memory cache for queries whose keys are densely-numbered IDs (e.g CrateNum, LocalDefId), and can therefore be used as indices into a dense vector of cached values.

(As of #124780 the underlying storage is not an actual Vec, but rather a series of increasingly-large buckets, for improved performance when the parallel frontend is using multiple threads.)

Each entry in the cache stores the query’s return value (V), and also an associated index (I), which in practice is a DepNodeIndex used for query dependency tracking.

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 344 bytes