Commit f8da331d authored by Benjamin Woodruff's avatar Benjamin Woodruff

Remove default `const I: usize = 0` from AutoMap/AutoSet and reorder before H

The default `const I: usize = 0` parameter is a footgun because there's
almost always a better value. This removes the default and reorders `I`
before `H` so callers can write `AutoMap<K, V, 1>` without specifying
the hasher.

Each callsite now uses the largest `I` that doesn't increase struct size
on the stack: `I = floor(16 / sizeof((K, V)))`. This also fixes some
existing suboptimal values (e.g. cell_counters I=8→2, TaskIdSet I=2→4).
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 7bce97d6
......@@ -17,11 +17,11 @@ use crate::AutoMap;
decode_bounds = "K: Decode<__Context> + Hash + Eq, H: BuildHasher + Default",
borrow_decode_bounds = "K: Decode<__Context> + Hash + Eq, H: BuildHasher + Default"
)]
pub struct AutoSet<K, H = BuildHasherDefault<FxHasher>, const I: usize = 0> {
map: AutoMap<K, (), H, I>,
pub struct AutoSet<K, const I: usize, H = BuildHasherDefault<FxHasher>> {
map: AutoMap<K, (), I, H>,
}
impl<K, H, const I: usize> Default for AutoSet<K, H, I> {
impl<K, const I: usize, H> Default for AutoSet<K, I, H> {
fn default() -> Self {
Self {
map: Default::default(),
......@@ -29,13 +29,13 @@ impl<K, H, const I: usize> Default for AutoSet<K, H, I> {
}
}
impl<K: Debug, H, const I: usize> Debug for AutoSet<K, H, I> {
impl<K: Debug, const I: usize, H> Debug for AutoSet<K, I, H> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_set().entries(self.iter()).finish()
}
}
impl<K> AutoSet<K, BuildHasherDefault<FxHasher>, 0> {
impl<K> AutoSet<K, 0> {
/// see [HashSet::new](https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.new)
pub const fn new() -> Self {
Self {
......@@ -51,7 +51,7 @@ impl<K> AutoSet<K, BuildHasherDefault<FxHasher>, 0> {
}
}
impl<K, H: BuildHasher, const I: usize> AutoSet<K, H, I> {
impl<K, const I: usize, H: BuildHasher> AutoSet<K, I, H> {
/// see [HashSet::with_hasher](https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.with_hasher)
pub const fn with_hasher() -> Self {
Self {
......@@ -72,7 +72,7 @@ impl<K, H: BuildHasher, const I: usize> AutoSet<K, H, I> {
}
}
impl<K: Hash + Eq, H: BuildHasher + Default, const I: usize> AutoSet<K, H, I> {
impl<K: Hash + Eq, const I: usize, H: BuildHasher + Default> AutoSet<K, I, H> {
/// see [HashSet::insert](https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.insert)
pub fn insert(&mut self, key: K) -> bool {
self.map.insert(key, ()).is_none()
......@@ -99,7 +99,7 @@ impl<K: Hash + Eq, H: BuildHasher + Default, const I: usize> AutoSet<K, H, I> {
}
}
impl<K, H, const I: usize> AutoSet<K, H, I> {
impl<K, const I: usize, H> AutoSet<K, I, H> {
/// see [HashSet::len](https://doc.rust-lang.org/std/collections/hash_set/struct.HashSet.html#method.len)
pub fn len(&self) -> usize {
self.map.len()
......@@ -116,7 +116,7 @@ impl<K, H, const I: usize> AutoSet<K, H, I> {
}
}
impl<K, H, const I: usize> IntoIterator for AutoSet<K, H, I> {
impl<K, const I: usize, H> IntoIterator for AutoSet<K, I, H> {
type Item = K;
type IntoIter = IntoIter<K, I>;
......@@ -125,7 +125,7 @@ impl<K, H, const I: usize> IntoIterator for AutoSet<K, H, I> {
}
}
impl<'a, K, H, const I: usize> IntoIterator for &'a AutoSet<K, H, I> {
impl<'a, K, const I: usize, H> IntoIterator for &'a AutoSet<K, I, H> {
type Item = &'a K;
type IntoIter = Iter<'a, K>;
......@@ -168,7 +168,7 @@ impl<K, const I: usize> Iterator for IntoIter<K, I> {
}
}
impl<K, H, const I: usize> Serialize for AutoSet<K, H, I>
impl<K, const I: usize, H> Serialize for AutoSet<K, I, H>
where
K: Serialize,
H: BuildHasher,
......@@ -178,20 +178,20 @@ where
}
}
impl<'de, K, H, const I: usize> Deserialize<'de> for AutoSet<K, H, I>
impl<'de, K, const I: usize, H> Deserialize<'de> for AutoSet<K, I, H>
where
K: Deserialize<'de> + Hash + Eq,
H: BuildHasher + Default,
{
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
struct AutoSetVisitor<K, H, const I: usize>(PhantomData<AutoSet<K, H, I>>);
struct AutoSetVisitor<K, const I: usize, H>(PhantomData<AutoSet<K, I, H>>);
impl<'de, K, H, const I: usize> serde::de::Visitor<'de> for AutoSetVisitor<K, H, I>
impl<'de, K, const I: usize, H> serde::de::Visitor<'de> for AutoSetVisitor<K, I, H>
where
K: Deserialize<'de> + Hash + Eq,
H: BuildHasher + Default,
{
type Value = AutoSet<K, H, I>;
type Value = AutoSet<K, I, H>;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("a set")
......@@ -217,21 +217,21 @@ where
}
}
impl<K: Eq + Hash, H: BuildHasher, const I: usize> PartialEq for AutoSet<K, H, I> {
impl<K: Eq + Hash, const I: usize, H: BuildHasher> PartialEq for AutoSet<K, I, H> {
fn eq(&self, other: &Self) -> bool {
self.map == other.map
}
}
impl<K: Eq + Hash, H: BuildHasher, const I: usize> Eq for AutoSet<K, H, I> {}
impl<K: Eq + Hash, const I: usize, H: BuildHasher> Eq for AutoSet<K, I, H> {}
impl<K: Eq + Hash, SH: BuildHasher + Default, const I: usize> Hash for AutoSet<K, SH, I> {
impl<K: Eq + Hash, const I: usize, SH: BuildHasher + Default> Hash for AutoSet<K, I, SH> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.map.hash(state);
}
}
impl<K, H, const I: usize> FromIterator<K> for AutoSet<K, H, I>
impl<K, const I: usize, H> FromIterator<K> for AutoSet<K, I, H>
where
K: Hash + Eq,
H: BuildHasher + Default,
......@@ -243,7 +243,7 @@ where
}
}
impl<K, H, const N: usize, const I: usize> From<[K; N]> for AutoSet<K, H, I>
impl<K, const I: usize, H, const N: usize> From<[K; N]> for AutoSet<K, I, H>
where
K: Hash + Eq,
H: BuildHasher + Default,
......@@ -253,7 +253,7 @@ where
}
}
impl<K, H, const I: usize> ShrinkToFit for AutoSet<K, H, I>
impl<K, const I: usize, H> ShrinkToFit for AutoSet<K, I, H>
where
K: Eq + Hash,
H: BuildHasher + Default,
......
use std::{
hash::{BuildHasherDefault, Hash},
hash::Hash,
ops::{Add, AddAssign, Sub},
};
......@@ -10,9 +10,8 @@ use bincode::{
enc::Encoder,
error::{DecodeError, EncodeError},
};
use rustc_hash::FxHasher;
type InnerMap<K, V> = AutoMap<K, V, BuildHasherDefault<FxHasher>, 1>;
type InnerMap<K, V> = AutoMap<K, V, 1>;
/// A map optimized for reference counting, backed by AutoMap.
///
......
......@@ -7,7 +7,6 @@ use std::{
borrow::Cow,
fmt::{self, Write},
future::Future,
hash::BuildHasherDefault,
mem::take,
pin::Pin,
sync::{
......@@ -21,7 +20,7 @@ use anyhow::{Context, Result, bail};
use auto_hash_map::{AutoMap, AutoSet};
use indexmap::IndexSet;
use parking_lot::{Condvar, Mutex};
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{SmallVec, smallvec};
use tokio::time::{Duration, Instant};
use tracing::{Span, trace_span};
......@@ -1785,7 +1784,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
fn invalidate_tasks_set(
&self,
tasks: &AutoSet<TaskId, BuildHasherDefault<FxHasher>, 2>,
tasks: &AutoSet<TaskId, 4>,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) {
if !self.should_track_dependencies() {
......@@ -1971,7 +1970,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
&self,
task_id: TaskId,
result: Result<RawVc, TurboTasksExecutionError>,
cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>,
cell_counters: &AutoMap<ValueTypeId, u32, 2>,
#[cfg(feature = "verify_determinism")] stateful: bool,
has_invalidator: bool,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
......@@ -2105,7 +2104,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
#[cfg(feature = "trace_task_details")] span: &Span,
task_id: TaskId,
result: Result<RawVc, TurboTasksExecutionError>,
cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>,
cell_counters: &AutoMap<ValueTypeId, u32, 2>,
#[cfg(feature = "verify_determinism")] stateful: bool,
has_invalidator: bool,
) -> Option<TaskExecutionCompletePrepareResult> {
......@@ -2546,9 +2545,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
is_now_immutable: bool,
) -> (
bool,
Option<
auto_hash_map::AutoMap<CellId, InProgressCellState, BuildHasherDefault<FxHasher>, 1>,
>,
Option<auto_hash_map::AutoMap<CellId, InProgressCellState, 1>>,
) {
let mut task = ctx.task(task_id, TaskDataCategory::All);
let Some(in_progress) = task.take_in_progress() else {
......@@ -2711,7 +2708,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
&self,
ctx: &mut impl ExecuteContext<'_>,
task_id: TaskId,
cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>,
cell_counters: &AutoMap<ValueTypeId, u32, 2>,
is_error: bool,
) -> Vec<SharedReference> {
let mut task = ctx.task(task_id, TaskDataCategory::All);
......@@ -2926,7 +2923,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
collectible_type: TraitTypeId,
reader_id: Option<TaskId>,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) -> AutoMap<RawVc, i32, BuildHasherDefault<FxHasher>, 1> {
) -> AutoMap<RawVc, i32, 0> {
let mut ctx = self.execute_context(turbo_tasks);
let mut collectibles = AutoMap::default();
{
......@@ -3478,7 +3475,7 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
fn invalidate_tasks_set(
&self,
tasks: &AutoSet<TaskId, BuildHasherDefault<FxHasher>, 2>,
tasks: &AutoSet<TaskId, 4>,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) {
self.0.invalidate_tasks_set(tasks, turbo_tasks);
......@@ -3510,7 +3507,7 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
&self,
task_id: TaskId,
result: Result<RawVc, TurboTasksExecutionError>,
cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>,
cell_counters: &AutoMap<ValueTypeId, u32, 2>,
#[cfg(feature = "verify_determinism")] stateful: bool,
has_invalidator: bool,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
......@@ -3576,7 +3573,7 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
collectible_type: TraitTypeId,
reader: Option<TaskId>,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) -> AutoMap<RawVc, i32, BuildHasherDefault<FxHasher>, 1> {
) -> AutoMap<RawVc, i32, 0> {
self.0
.read_task_collectibles(task_id, collectible_type, reader, turbo_tasks)
}
......
......@@ -38,11 +38,10 @@ use crate::{
/// Auto-set storage for small sets of keys with unit values.
/// Optimized for small collections (< 8 items use SmallVec inline).
type AutoSet<K> = auto_hash_map::AutoSet<K, std::hash::BuildHasherDefault<rustc_hash::FxHasher>, 1>;
type AutoSet<K> = auto_hash_map::AutoSet<K, 1>;
/// Auto-map storage for key-value pairs.
type AutoMap<K, V> =
auto_hash_map::AutoMap<K, V, std::hash::BuildHasherDefault<rustc_hash::FxHasher>, 1>;
type AutoMap<K, V> = auto_hash_map::AutoMap<K, V, 1>;
/// The complete task storage schema.
///
......
......@@ -163,7 +163,7 @@ async fn taking_collectibles_with_resolve() {
}
#[turbo_tasks::value(transparent)]
struct Collectibles(AutoSet<ResolvedVc<Box<dyn ValueToString>>>);
struct Collectibles(AutoSet<ResolvedVc<Box<dyn ValueToString>>, 1>);
#[turbo_tasks::function(operation)]
async fn my_collecting_function() -> Result<Vc<Thing>> {
......
......@@ -50,7 +50,7 @@ impl FileSystem for EmbeddedFileSystem {
(_, None) => return Ok(RawDirectoryContent::NotFound.cell()),
};
let mut converted_entries = AutoMap::new();
let mut converted_entries = AutoMap::default();
for e in dir.entries() {
let entry_name: RcStr = e
.path()
......
......@@ -2662,12 +2662,12 @@ impl From<&RawDirectoryEntry> for FileSystemEntryType {
pub enum RawDirectoryContent {
// The entry keys are the directory relative file names
// e.g. for `/bar/foo`, it will be `foo`
Entries(AutoMap<RcStr, RawDirectoryEntry>),
Entries(AutoMap<RcStr, RawDirectoryEntry, 1>),
NotFound,
}
impl RawDirectoryContent {
pub fn new(entries: AutoMap<RcStr, RawDirectoryEntry>) -> Vc<Self> {
pub fn new(entries: AutoMap<RcStr, RawDirectoryEntry, 1>) -> Vc<Self> {
Self::cell(RawDirectoryContent::Entries(entries))
}
......@@ -2679,12 +2679,12 @@ impl RawDirectoryContent {
#[turbo_tasks::value]
#[derive(Debug)]
pub enum DirectoryContent {
Entries(AutoMap<RcStr, DirectoryEntry>),
Entries(AutoMap<RcStr, DirectoryEntry, 0>),
NotFound,
}
impl DirectoryContent {
pub fn new(entries: AutoMap<RcStr, DirectoryEntry>) -> Vc<Self> {
pub fn new(entries: AutoMap<RcStr, DirectoryEntry, 0>) -> Vc<Self> {
Self::cell(DirectoryContent::Entries(entries))
}
......@@ -2803,7 +2803,7 @@ async fn get_type(path: FileSystemPath) -> Result<Vc<FileSystemEntryType>> {
async fn realpath_with_links(path: FileSystemPath) -> Result<Vc<RealPathResult>> {
let mut current_path = path;
let mut symlinks: IndexSet<FileSystemPath> = IndexSet::new();
let mut visited: AutoSet<RcStr> = AutoSet::new();
let mut visited: AutoSet<RcStr, 2> = AutoSet::default();
let mut error = RealPathResultError::TooManySymlinks;
// Pick some arbitrary symlink depth limit... similar to the ELOOP logic for realpath(3).
// SYMLOOP_MAX is 40 for Linux: https://unix.stackexchange.com/q/721724
......
......@@ -3,7 +3,7 @@ use std::{
error::Error,
fmt::{self, Debug, Display},
future::Future,
hash::{BuildHasherDefault, Hash},
hash::Hash,
pin::Pin,
sync::Arc,
};
......@@ -17,7 +17,6 @@ use bincode::{
error::{DecodeError, EncodeError},
impl_borrow_decode,
};
use rustc_hash::FxHasher;
use smallvec::SmallVec;
use tracing::Span;
use turbo_bincode::{
......@@ -286,7 +285,7 @@ impl TryFrom<CellContent> for SharedReference {
}
}
pub type TaskCollectiblesMap = AutoMap<RawVc, i32, BuildHasherDefault<FxHasher>, 1>;
pub type TaskCollectiblesMap = AutoMap<RawVc, i32, 0>;
// Structurally and functionally similar to Cow<&'static, str> but explicitly notes the importance
// of non-static strings potentially containing PII (Personal Identifiable Information).
......@@ -507,7 +506,7 @@ pub trait Backend: Sync + Send {
&self,
task: TaskId,
result: Result<RawVc, TurboTasksExecutionError>,
cell_counters: &AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>,
cell_counters: &AutoMap<ValueTypeId, u32, 2>,
#[cfg(feature = "verify_determinism")] stateful: bool,
has_invalidator: bool,
turbo_tasks: &dyn TurboTasksBackendApi<Self>,
......
......@@ -5,6 +5,6 @@ use crate::{ResolvedVc, VcValueTrait};
/// Implemented on `OperationVc` and `RawVc`.
pub trait CollectiblesSource {
fn drop_collectibles<T: VcValueTrait>(self);
fn take_collectibles<T: VcValueTrait>(self) -> AutoSet<ResolvedVc<T>>;
fn peek_collectibles<T: VcValueTrait>(self) -> AutoSet<ResolvedVc<T>>;
fn take_collectibles<T: VcValueTrait>(self) -> AutoSet<ResolvedVc<T>, 1>;
fn peek_collectibles<T: VcValueTrait>(self) -> AutoSet<ResolvedVc<T>, 1>;
}
......@@ -191,7 +191,7 @@ where
}
}
impl<K> ValueDebugFormat for AutoSet<K>
impl<K, const I: usize> ValueDebugFormat for AutoSet<K, I>
where
K: ValueDebugFormat,
{
......@@ -259,7 +259,7 @@ where
}
}
impl<K, V> ValueDebugFormat for AutoMap<K, V>
impl<K, V, const I: usize> ValueDebugFormat for AutoMap<K, V, I>
where
K: Debug,
V: ValueDebugFormat,
......
......@@ -211,7 +211,7 @@ pub fn emit_effect(effect: impl Effect) {
/// apply_effects(operation).await?;
/// ```
pub async fn apply_effects(source: impl CollectiblesSource) -> Result<()> {
let effects: AutoSet<ResolvedVc<Box<dyn EffectCollectible>>> = source.take_collectibles();
let effects: AutoSet<ResolvedVc<Box<dyn EffectCollectible>>, 1> = source.take_collectibles();
if effects.is_empty() {
return Ok(());
}
......@@ -254,7 +254,7 @@ pub async fn apply_effects(source: impl CollectiblesSource) -> Result<()> {
/// result_with_effects.effects.apply().await?;
/// ```
pub async fn get_effects(source: impl CollectiblesSource) -> Result<Effects> {
let effects: AutoSet<ResolvedVc<Box<dyn EffectCollectible>>> = source.take_collectibles();
let effects: AutoSet<ResolvedVc<Box<dyn EffectCollectible>>, 1> = source.take_collectibles();
let effects = effects
.into_iter()
.map(|effect| async move {
......
......@@ -394,7 +394,7 @@ pub use turbo_tasks_macros::task_storage;
#[rustfmt::skip]
pub use turbo_tasks_macros::TaskInput;
pub type TaskIdSet = AutoSet<TaskId, BuildHasherDefault<FxHasher>, 2>;
pub type TaskIdSet = AutoSet<TaskId, 4>;
pub mod test_helpers {
pub use super::manager::{current_task_for_testing, with_turbo_tasks_for_testing};
......
......@@ -2,7 +2,7 @@ use std::{
cmp::Reverse,
fmt::{Debug, Display},
future::Future,
hash::{BuildHasher, BuildHasherDefault},
hash::BuildHasher,
mem::take,
pin::Pin,
sync::{
......@@ -17,7 +17,7 @@ use auto_hash_map::AutoMap;
use bincode::{Decode, Encode};
use either::Either;
use futures::stream::FuturesUnordered;
use rustc_hash::{FxBuildHasher, FxHasher};
use rustc_hash::FxBuildHasher;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use tokio::{select, sync::mpsc::Receiver, task_local};
......@@ -535,7 +535,7 @@ struct CurrentTaskState {
/// When a task is re-executed, the cell count may not match the existing cell vec length.
///
/// This is taken (and becomes `None`) during teardown of a task.
cell_counters: Option<AutoMap<ValueTypeId, u32, BuildHasherDefault<FxHasher>, 8>>,
cell_counters: Option<AutoMap<ValueTypeId, u32, 2>>,
/// Local tasks created while this global task has been running. Indexed by `LocalTaskId`.
local_tasks: Vec<LocalTask>,
......
......@@ -52,13 +52,13 @@ macro_rules! impl_auto_marker_trait {
unsafe impl<T: $trait, const N: usize> $trait for [T; N] {}
unsafe impl<T: $trait> $trait for [T] {}
unsafe impl<T: $trait, S> $trait for ::std::collections::HashSet<T, S> {}
unsafe impl<T: $trait, S, const I: usize> $trait for ::auto_hash_map::AutoSet<T, S, I> {}
unsafe impl<T: $trait, const I: usize, S> $trait for ::auto_hash_map::AutoSet<T, I, S> {}
unsafe impl<T: $trait> $trait for ::std::collections::BTreeSet<T> {}
unsafe impl<T: $trait, S> $trait for ::indexmap::IndexSet<T, S> {}
unsafe impl<T: $trait> $trait for ::turbo_frozenmap::FrozenSet<T> {}
unsafe impl<K: $trait, V: $trait, S> $trait for ::std::collections::HashMap<K, V, S> {}
unsafe impl<K: $trait, V: $trait, S, const I: usize> $trait
for ::auto_hash_map::AutoMap<K, V, S, I> {}
unsafe impl<K: $trait, V: $trait, const I: usize, S> $trait
for ::auto_hash_map::AutoMap<K, V, I, S> {}
unsafe impl<K: $trait, V: $trait> $trait for ::std::collections::BTreeMap<K, V> {}
unsafe impl<K: $trait, V: $trait, S> $trait for ::indexmap::IndexMap<K, V, S> {}
unsafe impl<K: $trait, V: $trait> $trait for ::turbo_frozenmap::FrozenMap<K, V> {}
......
......@@ -255,7 +255,7 @@ impl RawVc {
/// This implementation of `CollectiblesSource` assumes that `self` is a `RawVc::TaskOutput`.
impl CollectiblesSource for RawVc {
fn peek_collectibles<T: VcValueTrait + ?Sized>(self) -> AutoSet<ResolvedVc<T>> {
fn peek_collectibles<T: VcValueTrait + ?Sized>(self) -> AutoSet<ResolvedVc<T>, 1> {
let RawVc::TaskOutput(task_id) = self else {
panic!(
"<RawVc as CollectiblesSource>::peek_collectibles() must only be called on a \
......@@ -269,7 +269,7 @@ impl CollectiblesSource for RawVc {
.collect()
}
fn take_collectibles<T: VcValueTrait + ?Sized>(self) -> AutoSet<ResolvedVc<T>> {
fn take_collectibles<T: VcValueTrait + ?Sized>(self) -> AutoSet<ResolvedVc<T>, 1> {
let RawVc::TaskOutput(task_id) = self else {
panic!(
"<RawVc as CollectiblesSource>::take_collectibles() must only be called on a \
......
......@@ -19,14 +19,14 @@ use crate::{
#[derive(Encode, Decode)]
struct StateInner<T> {
value: T,
invalidators: AutoSet<Invalidator>,
invalidators: AutoSet<Invalidator, 4>,
}
impl<T> StateInner<T> {
pub fn new(value: T) -> Self {
Self {
value,
invalidators: AutoSet::new(),
invalidators: AutoSet::default(),
}
}
......
......@@ -189,7 +189,7 @@ impl<T: TraceRawVcs, S> TraceRawVcs for HashSet<T, S> {
}
}
impl<T: TraceRawVcs, S, const I: usize> TraceRawVcs for AutoSet<T, S, I> {
impl<T: TraceRawVcs, const I: usize, S> TraceRawVcs for AutoSet<T, I, S> {
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext) {
for item in self.iter() {
TraceRawVcs::trace_raw_vcs(item, trace_context);
......@@ -230,7 +230,7 @@ impl<K: TraceRawVcs, V: TraceRawVcs, S> TraceRawVcs for HashMap<K, V, S> {
}
}
impl<K: TraceRawVcs, V: TraceRawVcs, S, const I: usize> TraceRawVcs for AutoMap<K, V, S, I> {
impl<K: TraceRawVcs, V: TraceRawVcs, const I: usize, S> TraceRawVcs for AutoMap<K, V, I, S> {
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext) {
for (key, value) in self.iter() {
TraceRawVcs::trace_raw_vcs(key, trace_context);
......
......@@ -238,11 +238,11 @@ where
self.node.node.drop_collectibles::<Vt>();
}
fn take_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>> {
fn take_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>, 1> {
self.node.node.take_collectibles()
}
fn peek_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>> {
fn peek_collectibles<Vt: VcValueTrait>(self) -> AutoSet<ResolvedVc<Vt>, 1> {
self.node.node.peek_collectibles()
}
}
......
......@@ -474,7 +474,7 @@ pub struct ChunkItems(pub Vec<ResolvedVc<Box<dyn ChunkItem>>>);
#[turbo_tasks::value]
pub struct AsyncModuleInfo {
pub referenced_async_modules: AutoSet<ResolvedVc<Box<dyn Module>>>,
pub referenced_async_modules: AutoSet<ResolvedVc<Box<dyn Module>>, 1>,
}
#[turbo_tasks::value_impl]
......
......@@ -114,5 +114,5 @@ where
#[derive(Debug)]
#[turbo_tasks::value]
pub struct CapturedDiagnostics {
pub diagnostics: AutoSet<ResolvedVc<Box<dyn Diagnostic>>>,
pub diagnostics: AutoSet<ResolvedVc<Box<dyn Diagnostic>>, 1>,
}
......@@ -203,7 +203,7 @@ pub trait ImportTracer {
#[turbo_tasks::value]
#[derive(Debug)]
pub struct DelegatingImportTracer {
delegates: AutoSet<ResolvedVc<Box<dyn ImportTracer>>>,
delegates: AutoSet<ResolvedVc<Box<dyn ImportTracer>>, 1>,
}
impl DelegatingImportTracer {
......@@ -409,7 +409,7 @@ impl IssueFilter {
#[turbo_tasks::value(shared)]
#[derive(Debug)]
pub struct CapturedIssues {
issues: AutoSet<ResolvedVc<Box<dyn Issue>>>,
issues: AutoSet<ResolvedVc<Box<dyn Issue>>, 1>,
tracer: ResolvedVc<DelegatingImportTracer>,
}
......
......@@ -312,7 +312,7 @@ pub enum ModuleExportUsageInfo {
/// Only the side effects are needed, no exports is used.
#[default]
Evaluation,
Exports(AutoSet<RcStr>),
Exports(AutoSet<RcStr, 2>),
All,
}
......
......@@ -79,14 +79,14 @@ pub async fn process_request_with_content_source(
issue_reporter: Vc<Box<dyn IssueReporter>>,
) -> Result<(
Response<hyper::Body>,
AutoSet<ResolvedVc<Box<dyn ContentSourceSideEffect>>>,
AutoSet<ResolvedVc<Box<dyn ContentSourceSideEffect>>, 1>,
)> {
let original_path = request.uri().path().to_string();
let request = http_request_to_source_request(request).await?;
let result_op = get_from_source_operation(source, TransientInstance::new(request));
let resolved_result = result_op.resolve_strongly_consistent().await?;
apply_effects(result_op).await?;
let side_effects: AutoSet<ResolvedVc<Box<dyn ContentSourceSideEffect>>> =
let side_effects: AutoSet<ResolvedVc<Box<dyn ContentSourceSideEffect>>, 1> =
result_op.peek_collectibles();
handle_issues(
result_op,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment