We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5843858 commit 8abafd0Copy full SHA for 8abafd0
compiler/rustc_data_structures/src/sharded.rs
@@ -20,6 +20,9 @@ pub const SHARDS: usize = 1 << SHARD_BITS;
20
21
/// An array of cache-line aligned inner locked structures with convenience methods.
22
pub struct Sharded<T> {
23
+ /// This mask is used to ensure that accesses are inbounds of `shards`.
24
+ /// When dynamic thread safety is off, this field is set to 0 causing only
25
+ /// a single shard to be used for greater cache efficiency.
26
#[cfg(parallel_compiler)]
27
mask: usize,
28
shards: [CacheAligned<Lock<T>>; SHARDS],
@@ -56,6 +59,7 @@ impl<T> Sharded<T> {
56
59
57
60
#[inline(always)]
58
61
fn count(&self) -> usize {
62
+ // `self.mask` is always one below the used shard count
63
self.mask() + 1
64
}
65
0 commit comments