diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-03 21:11:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-03 21:11:36 +0100 |
| commit | d6f94a683c6419a19bc9a9e2718fff5875a3595f (patch) | |
| tree | 5a72f44705baa3e752c18dc6200bed5dcfe10e1c /compiler/rustc_data_structures/src/vec_cache.rs | |
| parent | f180013800a5dad0aab488ea7cc81ecda1d81fc0 (diff) | |
| parent | 623d6e8ca423e37daf435136da32697e3cdd605b (diff) | |
| download | rust-d6f94a683c6419a19bc9a9e2718fff5875a3595f.tar.gz rust-d6f94a683c6419a19bc9a9e2718fff5875a3595f.zip | |
Rollup merge of #136484 - Zalathar:query-cache-notes, r=jieyouxu
Notes on types/traits used for in-memory query caching When the word "cache" appears in the context of the query system, it often isn't obvious whether that is referring to the in-memory query cache or the on-disk incremental cache. For these types, we can assure the reader that they are for in-memory caching.
Diffstat (limited to 'compiler/rustc_data_structures/src/vec_cache.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/vec_cache.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/vec_cache.rs b/compiler/rustc_data_structures/src/vec_cache.rs index eb251b587c8..2ff60ab7f36 100644 --- a/compiler/rustc_data_structures/src/vec_cache.rs +++ b/compiler/rustc_data_structures/src/vec_cache.rs @@ -206,6 +206,19 @@ impl SlotIndex { } } +/// 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. +/// +/// [#124780]: https://github.com/rust-lang/rust/pull/124780 pub struct VecCache<K: Idx, V, I> { // Entries per bucket: // Bucket 0: 4096 2^12 |
