Unverified Commit d069c2e1 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] Unify Cell Storage (#92974)

## What

Tightens the value-type persistence API and sets the table for a future eviction policy. Two user-visible changes on the `#[turbo_tasks::value(...)]` macro:

- **`serialization = "none"` → `serialization = "skip"`** — imperative ("skip persisting") instead of descriptive.  Making it clear that it isn't that we are missing a feature but rather that we are choosing to not persist (of course persisting might be impossible but that is generally rare)
- **New `evict = "always" | "last" | "never"` attribute** — replaces the old overloaded `"none"` semantic. Only valid with `serialization = "skip"`. Defaults to `"always"`.

Internally this collapses `persistent_cell_data` + `transient_cell_data` into one `cell_data` map and replaces the old `bincode: Option<(enc, dec)>` field with a four-variant `ValueTypePersistence` enum. Eviction machinery itself is a follow-up PR; this PR just gives each value type a precise, queryable persistence/eviction descriptor.

## Why break out a new parameter?

`serialization = "none"` on canary conflated three different intents:

1. **Cheap recomputable outputs** (SWC ASTs, codegen `Rope`s) — fine to evict, recompute is cheap.
2. **Expensive recomputable outputs** (WASM modules, Node process pools) — re-derivable but costly.
3. **Session-scoped state** (`State<>` cells, `Arc<Mutex<_>>` dedup histories) — can't be recomputed without losing accumulated mutations.

They all produced identical runtime behavior (stored in transient_cell_data), so eviction can't tell them apart. The fix is two orthogonal attributes:

```rust
// A cheap skip — default evict = "always"
#[turbo_tasks::value(serialization = "skip")]
// Expensive recompute — evict last under pressure
#[turbo_tasks::value(serialization = "skip", evict = "last")]
// Session-scoped state — never evict
#[turbo_tasks::value(serialization = "skip", evict = "never")]
```

The macro rejects `evict` on any other `serialization` mode.

## `ValueTypePersistence` enum

Replaces `ValueType.bincode: Option<(enc, dec)>`:

```rust
pub enum ValueTypePersistence {
    Persistable(AnyEncodeFn, AnyDecodeFn<SharedReference>),  // auto, custom
    SkipPersist { expensive: bool },                         // skip (+ evict = last)
    HashOnly,                                                // hash
    SessionStateful,                                         // skip + evict = never
}
```

The existing `"hash"` mode gets its own `HashOnly` variant rather than being folded into `SkipPersist`, which lets the backend gate its hash-writing and hash-comparison paths precisely.

## Unified `cell_data` storage

`persistent_cell_data: AutoMap<CellId, TypedSharedReference>` + `transient_cell_data: AutoMap<CellId, SharedReference>` collapse into `cell_data: CellData`. `CellData` is a newtype over `AutoMap<CellId, SharedReference>` with a custom bincode impl that filters non-`Persistable` entries at encode time. This removes the `is_serializable_cell_content: bool` parameter that was threading through ~14 read/write call sites.

Uses `SharedReference` instead of `TypedSharedReference` — `CellId` already carries the `ValueTypeId`.

## Annotation sweep

All prior `serialization = "none"` sites move to either `serialization = "skip", evict = "never"` or `serialization = "skip", evict = "last"` based on a per-site audit. Summary:

**`evict = "last"` (6 sites)** — re-derivable but expensive:
- `SwcPluginModule`, `EvaluatePool`, `ChildProcessPool`, `WorkerThreadPool`, `EffectInstance`, `Effects`

**`evict = "never"` (2 sites)** — interior-mutable state accumulated across the session:
- `ConsoleUi` (`Arc<Mutex<SeenIssues>>`), `VersionState` (`State<VersionRef>` with HMR invalidators)

The distinguishing rule: `evict = "never"` only when the value holds interior mutability accumulated across the session. Everything else can be re-derived (possibly expensively) by re-running the producing task.

## Follow-ups (separate PRs)

- Wire an eviction policy that consumes `ValueTypePersistence` — respects `SessionStateful` (never evict), prefers cheap `SkipPersist` over `expensive: true` ones.  Either as part of #91790 or afterwards depending on when things land

<!-- NEXT_JS_LLM_PR -->
parent 162016b9
...@@ -254,7 +254,7 @@ async fn endpoint_write_to_disk_with_apply( ...@@ -254,7 +254,7 @@ async fn endpoint_write_to_disk_with_apply(
endpoint_write_to_disk(*endpoint) endpoint_write_to_disk(*endpoint)
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct WithEffects { struct WithEffects {
output_paths: ReadRef<EndpointOutputPaths>, output_paths: ReadRef<EndpointOutputPaths>,
effects: Effects, effects: Effects,
......
...@@ -15,7 +15,7 @@ use turbopack_core::{ ...@@ -15,7 +15,7 @@ use turbopack_core::{
use crate::next_api::utils::strongly_consistent_catch_collectables; use crate::next_api::utils::strongly_consistent_catch_collectables;
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
pub struct WriteAnalyzeResult { pub struct WriteAnalyzeResult {
pub issues: Arc<Vec<ReadRef<PlainIssue>>>, pub issues: Arc<Vec<ReadRef<PlainIssue>>>,
pub diagnostics: Arc<Vec<ReadRef<PlainDiagnostic>>>, pub diagnostics: Arc<Vec<ReadRef<PlainDiagnostic>>>,
......
...@@ -115,7 +115,7 @@ async fn issue_filter_from_endpoint( ...@@ -115,7 +115,7 @@ async fn issue_filter_from_endpoint(
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct WrittenEndpointWithIssues { struct WrittenEndpointWithIssues {
written: Option<ReadRef<EndpointOutputPaths>>, written: Option<ReadRef<EndpointOutputPaths>>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
...@@ -215,7 +215,7 @@ pub fn endpoint_server_changed_subscribe( ...@@ -215,7 +215,7 @@ pub fn endpoint_server_changed_subscribe(
) )
} }
#[turbo_tasks::value(shared, serialization = "none", eq = "manual")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual")]
struct EndpointIssuesAndDiags { struct EndpointIssuesAndDiags {
changed: Option<ReadRef<Completion>>, changed: Option<ReadRef<Completion>>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
......
...@@ -965,7 +965,7 @@ impl NapiEntrypoints { ...@@ -965,7 +965,7 @@ impl NapiEntrypoints {
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct EntrypointsWithIssues { struct EntrypointsWithIssues {
entrypoints: Option<ReadRef<EntrypointsOperation>>, entrypoints: Option<ReadRef<EntrypointsOperation>>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
...@@ -1000,14 +1000,14 @@ fn project_container_entrypoints_operation( ...@@ -1000,14 +1000,14 @@ fn project_container_entrypoints_operation(
container.entrypoints() container.entrypoints()
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct OperationResult { struct OperationResult {
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
diagnostics: Arc<Vec<ReadRef<PlainDiagnostic>>>, diagnostics: Arc<Vec<ReadRef<PlainDiagnostic>>>,
effects: Arc<Effects>, effects: Arc<Effects>,
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct AllWrittenEntrypointsWithIssues { struct AllWrittenEntrypointsWithIssues {
entrypoints: Option<ReadRef<EntrypointsOperation>>, entrypoints: Option<ReadRef<EntrypointsOperation>>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
...@@ -1800,7 +1800,7 @@ pub fn project_entrypoints_subscribe( ...@@ -1800,7 +1800,7 @@ pub fn project_entrypoints_subscribe(
) )
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct HmrUpdateWithIssues { struct HmrUpdateWithIssues {
update: ReadRef<Update>, update: ReadRef<Update>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
...@@ -1945,7 +1945,7 @@ struct HmrChunkNames { ...@@ -1945,7 +1945,7 @@ struct HmrChunkNames {
pub chunk_names: Vec<RcStr>, pub chunk_names: Vec<RcStr>,
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct HmrChunkNamesWithIssues { struct HmrChunkNamesWithIssues {
chunk_names: ReadRef<Vec<RcStr>>, chunk_names: ReadRef<Vec<RcStr>>,
issues: Arc<Vec<ReadRef<PlainIssue>>>, issues: Arc<Vec<ReadRef<PlainIssue>>>,
......
//! Unified cell storage.
//!
//! Every task cell — whether its value type is bincode-serializable, hash-only,
//! derivable, or non-reconstructible — lives in a single `CellData` map keyed
//! by [`CellId`]. The map's bincode impl decides at encode time which entries
//! to persist, by consulting the global [`ValueType`] registry: entries whose
//! value type has no bincode function are omitted from the serialized output.
//!
//! This replaces the older split of `persistent_cell_data` /
//! `transient_cell_data` fields which routed every cell write through an
//! `is_serializable_cell_content: bool` that threaded through ~14 call sites.
//! By keying the bincode decision on the value type itself, the routing
//! collapses to an unconditional insert.
//!
//! The inner value is stored as [`SharedReference`] rather than
//! [`TypedSharedReference`] because the `CellId` key already carries the
//! [`ValueTypeId`] — duplicating it in each map entry would waste memory.
//! Encode / decode recover the value type from the key.
use std::{
hash::BuildHasherDefault,
ops::{Deref, DerefMut},
};
use auto_hash_map::AutoMap;
use bincode::{
Decode, Encode,
error::{DecodeError, EncodeError},
};
use rustc_hash::FxHasher;
use turbo_bincode::{
TurboBincodeDecode, TurboBincodeDecoder, TurboBincodeEncode, TurboBincodeEncoder,
impl_decode_for_turbo_bincode_decode, impl_encode_for_turbo_bincode_encode,
};
use turbo_tasks::{CellId, SharedReference, ShrinkToFit, ValueTypePersistence, registry};
type InnerMap = AutoMap<CellId, SharedReference, BuildHasherDefault<FxHasher>, 1>;
/// Map of cell id → shared reference, with bincode that filters out entries
/// whose value type has no bincode function.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct CellData(InnerMap);
impl CellData {
pub fn new() -> Self {
Self::default()
}
}
impl Deref for CellData {
type Target = InnerMap;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for CellData {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl ShrinkToFit for CellData {
fn shrink_to_fit(&mut self) {
self.0.shrink_to_fit();
}
}
impl TurboBincodeEncode for CellData {
/// Writes `count-of-persistable-entries` followed by each persistable
/// `(CellId, encoded-value)`. Entries whose value type is `SkipPersist`
/// or `SessionStateful` (no bincode) are skipped; they will be
/// reconstructed on the next task execution after restore.
fn encode(&self, encoder: &mut TurboBincodeEncoder) -> Result<(), EncodeError> {
// First pass: count persistable entries. One extra O(N) iteration over
// the registry — cold path (snapshot time only) and the registry is a
// static array indexed by ValueTypeId, so each lookup is cheap.
let count = self
.0
.iter()
.filter(|(cell, _)| {
matches!(
registry::get_value_type(cell.type_id).persistence,
ValueTypePersistence::Persistable(_, _),
)
})
.count();
count.encode(encoder)?;
// TODO: consider sorting by type_id and delta encoding indices to reduce serialized size
for (cell_id, reference) in self.0.iter() {
let value_type = registry::get_value_type(cell_id.type_id);
let ValueTypePersistence::Persistable(encode_fn, _) = value_type.persistence else {
continue;
};
cell_id.encode(encoder)?;
encode_fn(&*reference.0, encoder)?;
}
Ok(())
}
}
impl<Context> TurboBincodeDecode<Context> for CellData {
/// Reads the count written by [`CellData::encode`] and decodes each
/// `(CellId, SharedReference)` entry by looking up the value type's
/// bincode decode function.
///
/// Missing cell types — or cells whose value type isn't `Persistable` —
/// are a decode error: the encoder filters them out, so they should not
/// appear on the wire.
fn decode(decoder: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> {
let count = usize::decode(decoder)?;
let mut map = InnerMap::with_capacity_and_hasher(count, BuildHasherDefault::default());
for _ in 0..count {
let cell = CellId::decode(decoder)?;
let value_type = registry::get_value_type(cell.type_id);
let ValueTypePersistence::Persistable(_, decode_fn) = value_type.persistence else {
return Err(DecodeError::OtherString(format!(
"cell of type {} has no bincode decoder",
value_type.ty.global_name
)));
};
let reference = decode_fn(decoder)?;
map.insert(cell, reference);
}
Ok(Self(map))
}
}
impl_encode_for_turbo_bincode_encode!(CellData);
impl_decode_for_turbo_bincode_decode!(CellData);
mod cell_data;
mod counter_map; mod counter_map;
mod operation; mod operation;
mod storage; mod storage;
...@@ -857,7 +858,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -857,7 +858,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
} }
let ReadCellOptions { let ReadCellOptions {
is_serializable_cell_content,
tracking, tracking,
final_read_hint, final_read_hint,
} = options; } = options;
...@@ -878,9 +878,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -878,9 +878,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
}; };
let content = if final_read_hint { let content = if final_read_hint {
task.remove_cell_data(is_serializable_cell_content, cell) task.remove_cell_data(&cell)
} else { } else {
task.get_cell_data(is_serializable_cell_content, cell) task.get_cell_data(&cell).cloned()
}; };
if let Some(content) = content { if let Some(content) = content {
if tracking.should_track(false) { if tracking.should_track(false) {
...@@ -888,7 +888,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -888,7 +888,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
} }
return Ok(Ok(TypedCellContent( return Ok(Ok(TypedCellContent(
cell.type_id, cell.type_id,
CellContent(Some(content.reference)), CellContent(Some(content)),
))); )));
} }
...@@ -2689,9 +2689,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2689,9 +2689,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
// Note: We do not mark the tasks as dirty here, as these tasks are unused or stale // Note: We do not mark the tasks as dirty here, as these tasks are unused or stale
// anyway and we want to avoid needless re-executions. When the cells become // anyway and we want to avoid needless re-executions. When the cells become
// used again, they are invalidated from the update cell operation. // used again, they are invalidated from the update cell operation.
// Remove cell data for cells that no longer exist let to_remove: Vec<_> = task
let to_remove_persistent: Vec<_> = task .iter_cell_data()
.iter_persistent_cell_data()
.filter_map(|(cell, _)| { .filter_map(|(cell, _)| {
cell_counters cell_counters
.get(&cell.type_id) .get(&cell.type_id)
...@@ -2699,25 +2698,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2699,25 +2698,9 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
.then_some(*cell) .then_some(*cell)
}) })
.collect(); .collect();
removed_cell_data.reserve_exact(to_remove.len());
// Remove transient cell data for cells that no longer exist for cell in to_remove {
let to_remove_transient: Vec<_> = task if let Some(data) = task.remove_cell_data(&cell) {
.iter_transient_cell_data()
.filter_map(|(cell, _)| {
cell_counters
.get(&cell.type_id)
.is_none_or(|start_index| cell.index >= *start_index)
.then_some(*cell)
})
.collect();
removed_cell_data.reserve_exact(to_remove_persistent.len() + to_remove_transient.len());
for cell in to_remove_persistent {
if let Some(data) = task.remove_persistent_cell_data(&cell) {
removed_cell_data.push(data.into_untyped());
}
}
for cell in to_remove_transient {
if let Some(data) = task.remove_transient_cell_data(&cell) {
removed_cell_data.push(data); removed_cell_data.push(data);
} }
} }
...@@ -2904,14 +2887,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -2904,14 +2887,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
&self, &self,
task_id: TaskId, task_id: TaskId,
cell: CellId, cell: CellId,
options: ReadCellOptions,
turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>, turbo_tasks: &dyn TurboTasksBackendApi<TurboTasksBackend<B>>,
) -> Result<TypedCellContent> { ) -> Result<TypedCellContent> {
let mut ctx = self.execute_context(turbo_tasks); let mut ctx = self.execute_context(turbo_tasks);
let task = ctx.task(task_id, TaskDataCategory::Data); let task = ctx.task(task_id, TaskDataCategory::Data);
if let Some(content) = task.get_cell_data(options.is_serializable_cell_content, cell) { if let Some(content) = task.get_cell_data(&cell).cloned() {
debug_assert!(content.type_id == cell.type_id, "Cell type ID mismatch"); Ok(CellContent(Some(content)).into_typed(cell.type_id))
Ok(CellContent(Some(content.reference)).into_typed(cell.type_id))
} else { } else {
Ok(CellContent(None).into_typed(cell.type_id)) Ok(CellContent(None).into_typed(cell.type_id))
} }
...@@ -3041,7 +3022,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -3041,7 +3022,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
&self, &self,
task_id: TaskId, task_id: TaskId,
cell: CellId, cell: CellId,
is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
updated_key_hashes: Option<SmallVec<[u64; 2]>>, updated_key_hashes: Option<SmallVec<[u64; 2]>>,
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
...@@ -3052,7 +3032,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -3052,7 +3032,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
task_id, task_id,
cell, cell,
content, content,
is_serializable_cell_content,
updated_key_hashes, updated_key_hashes,
content_hash, content_hash,
verification_mode, verification_mode,
...@@ -3553,11 +3532,9 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> { ...@@ -3553,11 +3532,9 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
&self, &self,
task_id: TaskId, task_id: TaskId,
cell: CellId, cell: CellId,
options: ReadCellOptions,
turbo_tasks: &dyn TurboTasksBackendApi<Self>, turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) -> Result<TypedCellContent> { ) -> Result<TypedCellContent> {
self.0 self.0.try_read_own_task_cell(task_id, cell, turbo_tasks)
.try_read_own_task_cell(task_id, cell, options, turbo_tasks)
} }
fn read_task_collectibles( fn read_task_collectibles(
...@@ -3598,7 +3575,6 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> { ...@@ -3598,7 +3575,6 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
&self, &self,
task_id: TaskId, task_id: TaskId,
cell: CellId, cell: CellId,
is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
updated_key_hashes: Option<SmallVec<[u64; 2]>>, updated_key_hashes: Option<SmallVec<[u64; 2]>>,
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
...@@ -3608,7 +3584,6 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> { ...@@ -3608,7 +3584,6 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
self.0.update_task_cell( self.0.update_task_cell(
task_id, task_id,
cell, cell,
is_serializable_cell_content,
content, content,
updated_key_hashes, updated_key_hashes,
content_hash, content_hash,
......
...@@ -18,8 +18,8 @@ use tracing::info_span; ...@@ -18,8 +18,8 @@ use tracing::info_span;
#[cfg(feature = "trace_prepare_tasks")] #[cfg(feature = "trace_prepare_tasks")]
use tracing::trace_span; use tracing::trace_span;
use turbo_tasks::{ use turbo_tasks::{
CellId, DynTaskInputs, FxIndexMap, RawVc, TaskExecutionReason, TaskId, TaskPriority, CellId, DynTaskInputs, FxIndexMap, RawVc, SharedReference, TaskExecutionReason, TaskId,
TurboTasksBackendApi, TurboTasksCallApi, TypedSharedReference, backend::CachedTaskType, TaskPriority, TurboTasksBackendApi, TurboTasksCallApi, backend::CachedTaskType,
macro_helpers::NativeFunction, macro_helpers::NativeFunction,
}; };
...@@ -1255,60 +1255,9 @@ pub trait TaskGuard: Debug + TaskStorageAccessors { ...@@ -1255,60 +1255,9 @@ pub trait TaskGuard: Debug + TaskStorageAccessors {
.unwrap_or_default(); .unwrap_or_default();
dirty_count > clean_count dirty_count > clean_count
} }
fn remove_cell_data( /// Add new cell data. Panics if the cell already had a value.
&mut self, fn add_cell_data(&mut self, cell: CellId, value: SharedReference) {
is_serializable_cell_content: bool, let old = self.insert_cell_data(cell, value);
cell: CellId,
) -> Option<TypedSharedReference> {
if is_serializable_cell_content {
self.remove_persistent_cell_data(&cell)
} else {
self.remove_transient_cell_data(&cell)
.map(|sr| sr.into_typed(cell.type_id))
}
}
fn get_cell_data(
&self,
is_serializable_cell_content: bool,
cell: CellId,
) -> Option<TypedSharedReference> {
if is_serializable_cell_content {
self.get_persistent_cell_data(&cell).cloned()
} else {
self.get_transient_cell_data(&cell)
.map(|sr| sr.clone().into_typed(cell.type_id))
}
}
fn has_cell_data(&self, is_serializable_cell_content: bool, cell: CellId) -> bool {
if is_serializable_cell_content {
self.persistent_cell_data_contains(&cell)
} else {
self.transient_cell_data_contains(&cell)
}
}
/// Set cell data, returning the old value if any.
fn set_cell_data(
&mut self,
is_serializable_cell_content: bool,
cell: CellId,
value: TypedSharedReference,
) -> Option<TypedSharedReference> {
if is_serializable_cell_content {
self.insert_persistent_cell_data(cell, value)
} else {
self.insert_transient_cell_data(cell, value.into_untyped())
.map(|sr| sr.into_typed(cell.type_id))
}
}
/// Add new cell data (asserts that the cell is new and didn't exist before).
fn add_cell_data(
&mut self,
is_serializable_cell_content: bool,
cell: CellId,
value: TypedSharedReference,
) {
let old = self.set_cell_data(is_serializable_cell_content, cell, value);
assert!(old.is_none(), "Cell data already exists for {cell:?}"); assert!(old.is_none(), "Cell data already exists for {cell:?}");
} }
......
...@@ -21,15 +21,14 @@ use std::sync::Arc; ...@@ -21,15 +21,14 @@ use std::sync::Arc;
use parking_lot::Mutex; use parking_lot::Mutex;
use turbo_tasks::{ use turbo_tasks::{
CellId, SharedReference, TaskExecutionReason, TaskId, TraitTypeId, TypedSharedReference, CellId, SharedReference, TaskExecutionReason, TaskId, TraitTypeId, ValueTypeId,
ValueTypeId,
backend::{CachedTaskType, CellHash, TransientTaskType}, backend::{CachedTaskType, CellHash, TransientTaskType},
event::Event, event::Event,
task_storage, task_storage,
}; };
use crate::{ use crate::{
backend::counter_map::CounterMap, backend::{cell_data::CellData, counter_map::CounterMap},
data::{ data::{
ActivenessState, AggregationNumber, CellRef, CollectibleRef, CollectiblesRef, Dirtyness, ActivenessState, AggregationNumber, CellRef, CollectibleRef, CollectiblesRef, Dirtyness,
InProgressCellState, InProgressState, LeafDistance, OutputValue, RootType, TransientTask, InProgressCellState, InProgressState, LeafDistance, OutputValue, RootType, TransientTask,
...@@ -286,13 +285,22 @@ struct TaskStorageSchema { ...@@ -286,13 +285,22 @@ struct TaskStorageSchema {
// ========================================================================= // =========================================================================
// CELL DATA (data) // CELL DATA (data)
// ========================================================================= // =========================================================================
/// Persistent cell data (serializable). /// Cell data for all cells, regardless of serialization mode.
#[field(storage = "auto_map", category = "data", shrink_on_completion)] ///
persistent_cell_data: AutoMap<CellId, TypedSharedReference>, /// `CellData` is a newtype over `AutoMap<CellId, SharedReference>` whose
/// bincode impl filters out entries whose value type is not
/// Transient cell data (not serializable). /// `ValueTypePersistence::Persistable` at encode time (i.e. `SkipPersist`
#[field(storage = "auto_map", category = "transient", shrink_on_completion)] /// or `SessionStateful`). Those entries stay in memory but are not
transient_cell_data: AutoMap<CellId, SharedReference>, /// persisted — on restore the next read triggers the "cell index in range
/// but data missing" recompute path. `SessionStateful` value types are
/// identified on `ValueType::persistence` for future eviction handling.
#[field(
storage = "auto_map",
category = "data",
shrink_on_completion,
as_type = "AutoMap<CellId, SharedReference>"
)]
cell_data: CellData,
/// Hash of transient cell data, persisted for hash-based change detection when /// Hash of transient cell data, persisted for hash-based change detection when
/// transient data has been evicted from memory. /// transient data has been evicted from memory.
......
...@@ -56,7 +56,7 @@ async fn test_read_ref() { ...@@ -56,7 +56,7 @@ async fn test_read_ref() {
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct CounterValue(usize); struct CounterValue(usize);
#[turbo_tasks::value(serialization = "none", cell = "new", eq = "manual")] #[turbo_tasks::value(serialization = "skip", evict = "never", cell = "new", eq = "manual")]
struct Counter { struct Counter {
#[turbo_tasks(debug_ignore, trace_ignore)] #[turbo_tasks(debug_ignore, trace_ignore)]
value: Mutex<(usize, HashSet<Invalidator>)>, value: Mutex<(usize, HashSet<Invalidator>)>,
......
...@@ -65,7 +65,7 @@ async fn trait_ref() { ...@@ -65,7 +65,7 @@ async fn trait_ref() {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct CounterValue(usize); struct CounterValue(usize);
#[turbo_tasks::value(serialization = "none", cell = "new", eq = "manual")] #[turbo_tasks::value(serialization = "skip", evict = "never", cell = "new", eq = "manual")]
struct Counter { struct Counter {
#[turbo_tasks(debug_ignore, trace_ignore)] #[turbo_tasks(debug_ignore, trace_ignore)]
value: Mutex<(usize, HashSet<Invalidator>)>, value: Mutex<(usize, HashSet<Invalidator>)>,
......
...@@ -17,9 +17,9 @@ pub use self::{ ...@@ -17,9 +17,9 @@ pub use self::{
filter::FilterProcessEnv, filter::FilterProcessEnv,
}; };
/// Like [`EnvMap`], but with `serialization = "none"` to avoid storing /// Like [`EnvMap`], but with `serialization = "skip"` to avoid storing
/// environment variables (which may contain secrets) in the persistent cache. /// environment variables (which may contain secrets) in the persistent cache.
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "skip")]
pub struct TransientEnvMap(#[turbo_tasks(trace_ignore)] FxIndexMap<RcStr, RcStr>); pub struct TransientEnvMap(#[turbo_tasks(trace_ignore)] FxIndexMap<RcStr, RcStr>);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -11,7 +11,7 @@ use crate::{ ...@@ -11,7 +11,7 @@ use crate::{
#[derive(ValueToString)] #[derive(ValueToString)]
#[value_to_string(self.name)] #[value_to_string(self.name)]
#[turbo_tasks::value(serialization = "none", cell = "new", eq = "manual")] #[turbo_tasks::value(serialization = "skip", cell = "new", eq = "manual")]
pub struct EmbeddedFileSystem { pub struct EmbeddedFileSystem {
name: RcStr, name: RcStr,
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
......
...@@ -2478,7 +2478,7 @@ impl FileContent { ...@@ -2478,7 +2478,7 @@ impl FileContent {
} }
/// A file's content interpreted as a JSON value. /// A file's content interpreted as a JSON value.
#[turbo_tasks::value(shared, serialization = "none")] #[turbo_tasks::value(shared, serialization = "skip")]
pub enum FileJsonContent { pub enum FileJsonContent {
Content(Value), Content(Value),
Unparsable(Box<UnparsableJson>), Unparsable(Box<UnparsableJson>),
...@@ -2549,7 +2549,7 @@ impl FileLine { ...@@ -2549,7 +2549,7 @@ impl FileLine {
} }
} }
#[turbo_tasks::value(shared, serialization = "none")] #[turbo_tasks::value(shared, serialization = "skip")]
pub enum FileLinesContent { pub enum FileLinesContent {
Lines(#[turbo_tasks(trace_ignore)] Vec<FileLine>), Lines(#[turbo_tasks(trace_ignore)] Vec<FileLine>),
Unparsable, Unparsable,
......
...@@ -69,6 +69,16 @@ struct FieldInfo { ...@@ -69,6 +69,16 @@ struct FieldInfo {
/// If true, drop this field entirely after execution completes if the task is immutable. /// If true, drop this field entirely after execution completes if the task is immutable.
/// Immutable tasks don't re-execute, so dependency tracking fields are not needed. /// Immutable tasks don't re-execute, so dependency tracking fields are not needed.
drop_on_completion_if_immutable: bool, drop_on_completion_if_immutable: bool,
/// Optional override for the underlying map type, used when the field is a
/// newtype wrapping `AutoMap<K, V>` (or similar) so callers can inject
/// custom bincode / accessor behavior while the macro still generates map
/// accessors with the right key/value types.
///
/// The newtype must `Deref`/`DerefMut` to the inner map so the generated
/// accessors (which call `.iter()`, `.insert()`, etc.) keep working.
///
/// When absent, the macro parses the outer field type directly.
as_type: Option<Type>,
} }
impl FieldInfo { impl FieldInfo {
...@@ -363,6 +373,7 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo { ...@@ -363,6 +373,7 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo {
let mut use_default = false; let mut use_default = false;
let mut shrink_on_completion = false; let mut shrink_on_completion = false;
let mut drop_on_completion_if_immutable = false; let mut drop_on_completion_if_immutable = false;
let mut as_type: Option<Type> = None;
// Find and parse the field attribute // Find and parse the field attribute
if let Some(attr) = field.attrs.iter().find(|attr| { if let Some(attr) = field.attrs.iter().find(|attr| {
...@@ -437,11 +448,28 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo { ...@@ -437,11 +448,28 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo {
}); });
} }
} }
"as_type" => {
if let Some(lit_str) = expect_string_literal(&nv.value, "as_type") {
match syn::parse_str::<Type>(&lit_str.value()) {
Ok(ty) => as_type = Some(ty),
Err(err) => {
lit_str
.span()
.unwrap()
.error(format!(
"`as_type` must parse as a Rust type: {err}"
))
.emit();
}
}
}
}
other => { other => {
meta.span() meta.span()
.unwrap() .unwrap()
.error(format!( .error(format!(
"unknown attribute `{other}`, expected `storage` or `category`" "unknown attribute `{other}`, expected `storage`, `category`, \
or `as_type`"
)) ))
.emit(); .emit();
} }
...@@ -581,6 +609,7 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo { ...@@ -581,6 +609,7 @@ fn parse_field_storage_attributes(field: &syn::Field) -> FieldInfo {
use_default, use_default,
shrink_on_completion, shrink_on_completion,
drop_on_completion_if_immutable, drop_on_completion_if_immutable,
as_type,
} }
} }
...@@ -2302,7 +2331,12 @@ fn generate_countermap_ops(field: &FieldInfo) -> TokenStream { ...@@ -2302,7 +2331,12 @@ fn generate_countermap_ops(field: &FieldInfo) -> TokenStream {
fn generate_automap_ops(field: &FieldInfo) -> TokenStream { fn generate_automap_ops(field: &FieldInfo) -> TokenStream {
let field_type = &field.field_type; let field_type = &field.field_type;
let Some((key_type, value_type)) = extract_map_types(field_type, "AutoMap") else { // If the field uses a newtype wrapper, `as_type` gives us the actual
// `AutoMap<K, V>` to extract key/value types from. Otherwise parse the
// declared field type directly.
let map_ty = field.as_type.as_ref().unwrap_or(field_type);
let Some((key_type, value_type)) = extract_map_types(map_ty, "AutoMap") else {
return quote! {}; return quote! {};
}; };
......
...@@ -57,7 +57,7 @@ pub fn primitive(input: TokenStream) -> TokenStream { ...@@ -57,7 +57,7 @@ pub fn primitive(input: TokenStream) -> TokenStream {
} }
} else { } else {
quote! { quote! {
turbo_tasks::ValueType::new_with_bincode::<#ty>(#name) turbo_tasks::ValueType::persistable::<#ty>(#name)
} }
}; };
......
...@@ -43,14 +43,20 @@ impl TryFrom<LitStr> for CellMode { ...@@ -43,14 +43,20 @@ impl TryFrom<LitStr> for CellMode {
} }
} }
/// How a value type's cells are persisted across restarts.
enum SerializationMode { enum SerializationMode {
None, /// Round-trip through bincode via auto-derived `Encode` / `Decode`.
/// Like `None` (no bincode serialization), but also stores a hash of the cell value so that
/// changes can be detected even when the transient cell data has been evicted from memory.
/// Only valid with `cell = "compare"` (or the default).
Hash,
Auto, Auto,
/// Round-trip through bincode via a manual `Encode` / `Decode` impl
/// supplied by the value type.
Custom, Custom,
/// No persistence of the value itself. Eviction policy is controlled
/// separately via the `evict` attribute.
Skip,
/// Persist only a hash of the value so post-eviction reads can detect
/// unchanged content and skip invalidation. Only valid with
/// `cell = "compare"` (or the default).
Hash,
} }
impl Parse for SerializationMode { impl Parse for SerializationMode {
...@@ -65,13 +71,53 @@ impl TryFrom<LitStr> for SerializationMode { ...@@ -65,13 +71,53 @@ impl TryFrom<LitStr> for SerializationMode {
fn try_from(lit: LitStr) -> Result<Self, Self::Error> { fn try_from(lit: LitStr) -> Result<Self, Self::Error> {
match lit.value().as_str() { match lit.value().as_str() {
"none" => Ok(SerializationMode::None),
"hash" => Ok(SerializationMode::Hash),
"auto" => Ok(SerializationMode::Auto), "auto" => Ok(SerializationMode::Auto),
"custom" => Ok(SerializationMode::Custom), "custom" => Ok(SerializationMode::Custom),
"skip" => Ok(SerializationMode::Skip),
"hash" => Ok(SerializationMode::Hash),
_ => Err(Error::new_spanned(
&lit,
"expected \"auto\", \"custom\", \"skip\", or \"hash\"",
)),
}
}
}
/// Eviction policy for a `serialization = "skip"` value type. Ignored for
/// other serialization modes (the macro rejects non-`Always` values in that
/// case).
enum EvictMode {
/// Evictable freely. The next reader after eviction triggers a recompute
/// from the task's inputs. This is the default when `evict` is omitted.
Always,
/// Evictable, but re-deriving is non-trivial (e.g. WASM compile,
/// spawning a Node process pool). Eviction policy should prefer
/// evicting cheaper cells first.
Last,
/// Not evictable: the value holds interior-mutable state that
/// accumulates across the session (`State<>` cells, `Arc<Mutex<_>>`
/// dedup histories) and must stay in memory.
Never,
}
impl Parse for EvictMode {
fn parse(input: ParseStream) -> syn::Result<Self> {
let ident = input.parse::<LitStr>()?;
Self::try_from(ident)
}
}
impl TryFrom<LitStr> for EvictMode {
type Error = Error;
fn try_from(lit: LitStr) -> Result<Self, Self::Error> {
match lit.value().as_str() {
"always" => Ok(EvictMode::Always),
"last" => Ok(EvictMode::Last),
"never" => Ok(EvictMode::Never),
_ => Err(Error::new_spanned( _ => Err(Error::new_spanned(
&lit, &lit,
"expected \"none\", \"hash\", \"auto\", or \"custom\"", "expected \"always\", \"last\", or \"never\"",
)), )),
} }
} }
...@@ -79,6 +125,7 @@ impl TryFrom<LitStr> for SerializationMode { ...@@ -79,6 +125,7 @@ impl TryFrom<LitStr> for SerializationMode {
struct ValueArguments { struct ValueArguments {
serialization_mode: SerializationMode, serialization_mode: SerializationMode,
evict_mode: EvictMode,
shared: bool, shared: bool,
cell_mode: CellMode, cell_mode: CellMode,
manual_eq: bool, manual_eq: bool,
...@@ -92,6 +139,7 @@ impl Parse for ValueArguments { ...@@ -92,6 +139,7 @@ impl Parse for ValueArguments {
fn parse(input: ParseStream) -> syn::Result<Self> { fn parse(input: ParseStream) -> syn::Result<Self> {
let mut result = ValueArguments { let mut result = ValueArguments {
serialization_mode: SerializationMode::Auto, serialization_mode: SerializationMode::Auto,
evict_mode: EvictMode::Always,
shared: false, shared: false,
cell_mode: CellMode::Compare, cell_mode: CellMode::Compare,
manual_eq: false, manual_eq: false,
...@@ -124,6 +172,18 @@ impl Parse for ValueArguments { ...@@ -124,6 +172,18 @@ impl Parse for ValueArguments {
) => { ) => {
result.serialization_mode = SerializationMode::try_from(str)?; result.serialization_mode = SerializationMode::try_from(str)?;
} }
(
"evict",
Meta::NameValue(MetaNameValue {
value:
Expr::Lit(ExprLit {
lit: Lit::Str(str), ..
}),
..
}),
) => {
result.evict_mode = EvictMode::try_from(str)?;
}
( (
"cell", "cell",
Meta::NameValue(MetaNameValue { Meta::NameValue(MetaNameValue {
...@@ -179,8 +239,8 @@ impl Parse for ValueArguments { ...@@ -179,8 +239,8 @@ impl Parse for ValueArguments {
&meta, &meta,
format!( format!(
"unexpected {meta:?}, expected \"shared\", \"into\", \ "unexpected {meta:?}, expected \"shared\", \"into\", \
\"serialization\", \"cell\", \"eq\", \"hash\", \"transparent\", or \ \"serialization\", \"evict\", \"cell\", \"eq\", \"hash\", \
\"operation\"" \"transparent\", or \"operation\""
), ),
)); ));
} }
...@@ -195,6 +255,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -195,6 +255,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
let item = parse_macro_input!(input as Item); let item = parse_macro_input!(input as Item);
let ValueArguments { let ValueArguments {
serialization_mode, serialization_mode,
evict_mode,
shared, shared,
cell_mode, cell_mode,
manual_eq, manual_eq,
...@@ -225,6 +286,20 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -225,6 +286,20 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
.into(); .into();
} }
// `evict = "last" | "never"` is only valid when `serialization = "skip"`;
// other persistence modes have their own eviction semantics fixed by the
// backend (Persistable: evict-and-restore, HashOnly: evict-with-hash-gate).
if !matches!(evict_mode, EvictMode::Always)
&& !matches!(serialization_mode, SerializationMode::Skip)
{
return syn::Error::new(
proc_macro2::Span::call_site(),
"evict = \"last\" | \"never\" is only valid with serialization = \"skip\"",
)
.to_compile_error()
.into();
}
let mut struct_attributes = vec![quote! { let mut struct_attributes = vec![quote! {
#[derive( #[derive(
turbo_tasks::ShrinkToFit, turbo_tasks::ShrinkToFit,
...@@ -363,7 +438,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -363,7 +438,7 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
#[bincode(crate = "turbo_tasks::macro_helpers::bincode")] #[bincode(crate = "turbo_tasks::macro_helpers::bincode")]
}); });
} }
SerializationMode::None | SerializationMode::Hash | SerializationMode::Custom => {} SerializationMode::Custom | SerializationMode::Skip | SerializationMode::Hash => {}
}; };
if inner_type.is_some() { if inner_type.is_some() {
// Transparent structs have their own manual `ValueDebug` implementation. // Transparent structs have their own manual `ValueDebug` implementation.
...@@ -394,18 +469,28 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream { ...@@ -394,18 +469,28 @@ pub fn value(args: TokenStream, input: TokenStream) -> TokenStream {
} }
let name = global_name_for_type(ident); let name = global_name_for_type(ident);
let new_value_type = match serialization_mode { // Dispatch to the constructor whose name reflects the persistence +
SerializationMode::None | SerializationMode::Hash => quote! { // eviction combo. `evict` is only read when `serialization = Skip`;
turbo_tasks::ValueType::new::<#ident>(#name) // other modes ignore it (and the parser rejects non-Always values).
let new_value_type = match (&serialization_mode, &evict_mode) {
(SerializationMode::Auto | SerializationMode::Custom, _) => quote! {
turbo_tasks::ValueType::persistable::<#ident>(#name)
},
(SerializationMode::Hash, _) => quote! {
turbo_tasks::ValueType::hash_only::<#ident>(#name)
},
(SerializationMode::Skip, EvictMode::Always) => quote! {
turbo_tasks::ValueType::skip_persist::<#ident>(#name)
},
(SerializationMode::Skip, EvictMode::Last) => quote! {
turbo_tasks::ValueType::skip_persist_expensive::<#ident>(#name)
},
(SerializationMode::Skip, EvictMode::Never) => quote! {
turbo_tasks::ValueType::session_stateful::<#ident>(#name)
}, },
SerializationMode::Auto | SerializationMode::Custom => {
quote! {
turbo_tasks::ValueType::new_with_bincode::<#ident>(#name)
}
}
}; };
let has_serialization = match serialization_mode { let has_serialization = match serialization_mode {
SerializationMode::None | SerializationMode::Hash => quote! { false }, SerializationMode::Skip | SerializationMode::Hash => quote! { false },
SerializationMode::Auto | SerializationMode::Custom => quote! { true }, SerializationMode::Auto | SerializationMode::Custom => quote! { true },
}; };
......
...@@ -220,9 +220,8 @@ impl TurboTasksApi for VcStorage { ...@@ -220,9 +220,8 @@ impl TurboTasksApi for VcStorage {
&self, &self,
current_task: TaskId, current_task: TaskId,
index: CellId, index: CellId,
options: ReadCellOptions,
) -> Result<TypedCellContent> { ) -> Result<TypedCellContent> {
self.read_own_task_cell(current_task, index, options) self.read_own_task_cell(current_task, index)
} }
fn try_read_local_output( fn try_read_local_output(
...@@ -258,12 +257,7 @@ impl TurboTasksApi for VcStorage { ...@@ -258,12 +257,7 @@ impl TurboTasksApi for VcStorage {
unimplemented!() unimplemented!()
} }
fn read_own_task_cell( fn read_own_task_cell(&self, task: TaskId, index: CellId) -> Result<TypedCellContent> {
&self,
task: TaskId,
index: CellId,
_options: ReadCellOptions,
) -> Result<TypedCellContent> {
let map = self.cells.lock().unwrap(); let map = self.cells.lock().unwrap();
Ok(if let Some(cell) = map.get(&(task, index)) { Ok(if let Some(cell) = map.get(&(task, index)) {
cell.to_owned() cell.to_owned()
...@@ -277,7 +271,6 @@ impl TurboTasksApi for VcStorage { ...@@ -277,7 +271,6 @@ impl TurboTasksApi for VcStorage {
&self, &self,
task: TaskId, task: TaskId,
index: CellId, index: CellId,
_is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
_updated_key_hashes: Option<SmallVec<[u64; 2]>>, _updated_key_hashes: Option<SmallVec<[u64; 2]>>,
_content_hash: Option<[u8; 16]>, _content_hash: Option<[u8; 16]>,
......
...@@ -30,7 +30,7 @@ use turbo_tasks_hash::DeterministicHasher; ...@@ -30,7 +30,7 @@ use turbo_tasks_hash::DeterministicHasher;
use crate::{ use crate::{
RawVc, ReadCellOptions, ReadOutputOptions, ReadRef, SharedReference, TaskId, TaskIdSet, RawVc, ReadCellOptions, ReadOutputOptions, ReadRef, SharedReference, TaskId, TaskIdSet,
TaskPriority, TraitRef, TraitTypeId, TurboTasksCallApi, TurboTasksPanic, ValueTypeId, TaskPriority, TraitRef, TraitTypeId, TurboTasksCallApi, TurboTasksPanic, ValueTypeId,
VcValueTrait, VcValueType, ValueTypePersistence, VcValueTrait, VcValueType,
dyn_task_inputs::{DynTaskInputs, StackDynTaskInputs}, dyn_task_inputs::{DynTaskInputs, StackDynTaskInputs},
event::EventListener, event::EventListener,
macro_helpers::NativeFunction, macro_helpers::NativeFunction,
...@@ -258,10 +258,10 @@ impl TypedCellContent { ...@@ -258,10 +258,10 @@ impl TypedCellContent {
let Self(type_id, content) = self; let Self(type_id, content) = self;
let value_type = registry::get_value_type(*type_id); let value_type = registry::get_value_type(*type_id);
type_id.encode(enc)?; type_id.encode(enc)?;
if let Some(bincode) = value_type.bincode { if let ValueTypePersistence::Persistable(encode_fn, _) = value_type.persistence {
if let Some(reference) = &content.0 { if let Some(reference) = &content.0 {
true.encode(enc)?; true.encode(enc)?;
bincode.0(&*reference.0, enc)?; encode_fn(&*reference.0, enc)?;
Ok(()) Ok(())
} else { } else {
false.encode(enc)?; false.encode(enc)?;
...@@ -275,10 +275,10 @@ impl TypedCellContent { ...@@ -275,10 +275,10 @@ impl TypedCellContent {
pub fn decode(dec: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> { pub fn decode(dec: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> {
let type_id = ValueTypeId::decode(dec)?; let type_id = ValueTypeId::decode(dec)?;
let value_type = registry::get_value_type(type_id); let value_type = registry::get_value_type(type_id);
if let Some(bincode) = value_type.bincode { if let ValueTypePersistence::Persistable(_, decode_fn) = value_type.persistence {
let is_some = bool::decode(dec)?; let is_some = bool::decode(dec)?;
if is_some { if is_some {
let reference = bincode.1(dec)?; let reference = decode_fn(dec)?;
return Ok(TypedCellContent(type_id, CellContent(Some(reference)))); return Ok(TypedCellContent(type_id, CellContent(Some(reference))));
} }
} }
...@@ -603,14 +603,8 @@ pub trait Backend: Sync + Send { ...@@ -603,14 +603,8 @@ pub trait Backend: Sync + Send {
&self, &self,
current_task: TaskId, current_task: TaskId,
index: CellId, index: CellId,
options: ReadCellOptions,
turbo_tasks: &dyn TurboTasksBackendApi<Self>, turbo_tasks: &dyn TurboTasksBackendApi<Self>,
) -> Result<TypedCellContent> { ) -> Result<TypedCellContent>;
match self.try_read_task_cell(current_task, index, None, options, turbo_tasks)? {
Ok(content) => Ok(content),
Err(_) => Ok(TypedCellContent(index.type_id, CellContent(None))),
}
}
/// INVALIDATION: Be careful with this, when reader is None, it will not track dependencies, so /// INVALIDATION: Be careful with this, when reader is None, it will not track dependencies, so
/// using it could break cache invalidation. /// using it could break cache invalidation.
...@@ -643,7 +637,6 @@ pub trait Backend: Sync + Send { ...@@ -643,7 +637,6 @@ pub trait Backend: Sync + Send {
&self, &self,
task: TaskId, task: TaskId,
index: CellId, index: CellId,
is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
updated_key_hashes: Option<SmallVec<[u64; 2]>>, updated_key_hashes: Option<SmallVec<[u64; 2]>>,
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
......
...@@ -143,7 +143,7 @@ type DynEffectApplyFuture<'a> = Pin<Box<dyn Future<Output = Result<()>> + Send + ...@@ -143,7 +143,7 @@ type DynEffectApplyFuture<'a> = Pin<Box<dyn Future<Output = Result<()>> + Send +
trait EffectCollectible {} trait EffectCollectible {}
/// The Effect instance collectible that is emitted for effects. /// The Effect instance collectible that is emitted for effects.
#[turbo_tasks::value(serialization = "none", cell = "new", eq = "manual")] #[turbo_tasks::value(serialization = "skip", evict = "last", cell = "new", eq = "manual")]
struct EffectInstance { struct EffectInstance {
#[turbo_tasks(debug_ignore)] #[turbo_tasks(debug_ignore)]
inner: Box<dyn DynEffect>, inner: Box<dyn DynEffect>,
...@@ -199,7 +199,7 @@ pub fn emit_effect(effect: impl Effect) { ...@@ -199,7 +199,7 @@ pub fn emit_effect(effect: impl Effect) {
/// # #[turbo_tasks::function(operation)] /// # #[turbo_tasks::function(operation)]
/// # fn some_turbo_tasks_operation(_args: Args) {} /// # fn some_turbo_tasks_operation(_args: Args) {}
/// # /// #
/// #[turbo_tasks::value(serialization = "none")] /// #[turbo_tasks::value(serialization = "skip", evict = "last")]
/// struct OutputWithEffects { /// struct OutputWithEffects {
/// output: ReadRef<Example>, /// output: ReadRef<Example>,
/// effects: Effects, /// effects: Effects,
...@@ -255,7 +255,7 @@ type UniqueEffectIndices = Result<Vec<(usize, Arc<EffectStateEntry>)>, String>; ...@@ -255,7 +255,7 @@ type UniqueEffectIndices = Result<Vec<(usize, Arc<EffectStateEntry>)>, String>;
/// Captured effects from an operation. This struct can be used to return Effects from a turbo-tasks /// Captured effects from an operation. This struct can be used to return Effects from a turbo-tasks
/// function and apply them later. /// function and apply them later.
#[derive(Default)] #[derive(Default)]
#[turbo_tasks::value(shared, eq = "manual", serialization = "none")] #[turbo_tasks::value(shared, eq = "manual", serialization = "skip", evict = "last")]
pub struct Effects { pub struct Effects {
#[turbo_tasks(debug_ignore)] #[turbo_tasks(debug_ignore)]
effects: Vec<ReadRef<EffectInstance>>, effects: Vec<ReadRef<EffectInstance>>,
......
...@@ -109,7 +109,7 @@ pub use crate::{ ...@@ -109,7 +109,7 @@ pub use crate::{
task_execution_reason::TaskExecutionReason, task_execution_reason::TaskExecutionReason,
trait_ref::TraitRef, trait_ref::TraitRef,
value::{TransientInstance, TransientValue}, value::{TransientInstance, TransientValue},
value_type::{TraitMethod, TraitType, ValueType}, value_type::{TraitMethod, TraitType, ValueType, ValueTypePersistence},
vc::{ vc::{
Dynamic, NonLocalValue, OperationValue, OperationVc, OptionVcExt, ReadVcFuture, Dynamic, NonLocalValue, OperationValue, OperationVc, OptionVcExt, ReadVcFuture,
ResolveOperationVcFuture, ResolveVcFuture, ResolvedVc, ToResolvedVcFuture, Upcast, ResolveOperationVcFuture, ResolveVcFuture, ResolvedVc, ToResolvedVcFuture, Upcast,
......
...@@ -159,20 +159,13 @@ pub trait TurboTasksApi: TurboTasksCallApi + Sync + Send { ...@@ -159,20 +159,13 @@ pub trait TurboTasksApi: TurboTasksCallApi + Sync + Send {
&self, &self,
current_task: TaskId, current_task: TaskId,
index: CellId, index: CellId,
options: ReadCellOptions,
) -> Result<TypedCellContent>; ) -> Result<TypedCellContent>;
fn read_own_task_cell( fn read_own_task_cell(&self, task: TaskId, index: CellId) -> Result<TypedCellContent>;
&self,
task: TaskId,
index: CellId,
options: ReadCellOptions,
) -> Result<TypedCellContent>;
fn update_own_task_cell( fn update_own_task_cell(
&self, &self,
task: TaskId, task: TaskId,
index: CellId, index: CellId,
is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
updated_key_hashes: Option<SmallVec<[u64; 2]>>, updated_key_hashes: Option<SmallVec<[u64; 2]>>,
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
...@@ -1484,10 +1477,9 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> { ...@@ -1484,10 +1477,9 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> {
&self, &self,
current_task: TaskId, current_task: TaskId,
index: CellId, index: CellId,
options: ReadCellOptions,
) -> Result<TypedCellContent> { ) -> Result<TypedCellContent> {
self.backend self.backend
.try_read_own_task_cell(current_task, index, options, self) .try_read_own_task_cell(current_task, index, self)
} }
#[track_caller] #[track_caller]
...@@ -1557,20 +1549,14 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> { ...@@ -1557,20 +1549,14 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> {
} }
} }
fn read_own_task_cell( fn read_own_task_cell(&self, task: TaskId, index: CellId) -> Result<TypedCellContent> {
&self, self.try_read_own_task_cell(task, index)
task: TaskId,
index: CellId,
options: ReadCellOptions,
) -> Result<TypedCellContent> {
self.try_read_own_task_cell(task, index, options)
} }
fn update_own_task_cell( fn update_own_task_cell(
&self, &self,
task: TaskId, task: TaskId,
index: CellId, index: CellId,
is_serializable_cell_content: bool,
content: CellContent, content: CellContent,
updated_key_hashes: Option<SmallVec<[u64; 2]>>, updated_key_hashes: Option<SmallVec<[u64; 2]>>,
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
...@@ -1579,7 +1565,6 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> { ...@@ -1579,7 +1565,6 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> {
self.backend.update_task_cell( self.backend.update_task_cell(
task, task,
index, index,
is_serializable_cell_content,
content, content,
updated_key_hashes, updated_key_hashes,
content_hash, content_hash,
...@@ -2041,7 +2026,6 @@ pub(crate) async fn read_task_output( ...@@ -2041,7 +2026,6 @@ pub(crate) async fn read_task_output(
pub struct CurrentCellRef { pub struct CurrentCellRef {
current_task: TaskId, current_task: TaskId,
index: CellId, index: CellId,
is_serializable_cell_content: bool,
} }
type VcReadTarget<T> = <<T as VcValueType>::Read as VcRead<T>>::Target; type VcReadTarget<T> = <<T as VcValueType>::Read as VcRead<T>>::Target;
...@@ -2077,24 +2061,12 @@ impl CurrentCellRef { ...@@ -2077,24 +2061,12 @@ impl CurrentCellRef {
)>, )>,
) { ) {
let tt = turbo_tasks(); let tt = turbo_tasks();
let cell_content = tt let cell_content = tt.read_own_task_cell(self.current_task, self.index).ok();
.read_own_task_cell(
self.current_task,
self.index,
ReadCellOptions {
// INVALIDATION: Reading our own cell must be untracked
tracking: ReadCellTracking::Untracked,
is_serializable_cell_content: self.is_serializable_cell_content,
final_read_hint: false,
},
)
.ok();
let update = functor(cell_content.as_ref().and_then(|cc| cc.1.0.as_ref())); let update = functor(cell_content.as_ref().and_then(|cc| cc.1.0.as_ref()));
if let Some((update, updated_key_hashes, content_hash)) = update { if let Some((update, updated_key_hashes, content_hash)) = update {
tt.update_own_task_cell( tt.update_own_task_cell(
self.current_task, self.current_task,
self.index, self.index,
self.is_serializable_cell_content,
CellContent(Some(update)), CellContent(Some(update)),
updated_key_hashes, updated_key_hashes,
content_hash, content_hash,
...@@ -2286,7 +2258,6 @@ impl CurrentCellRef { ...@@ -2286,7 +2258,6 @@ impl CurrentCellRef {
tt.update_own_task_cell( tt.update_own_task_cell(
self.current_task, self.current_task,
self.index, self.index,
self.is_serializable_cell_content,
CellContent(Some(SharedReference::new(triomphe::Arc::new(new_value)))), CellContent(Some(SharedReference::new(triomphe::Arc::new(new_value)))),
None, None,
None, None,
...@@ -2308,18 +2279,7 @@ impl CurrentCellRef { ...@@ -2308,18 +2279,7 @@ impl CurrentCellRef {
) { ) {
let tt = turbo_tasks(); let tt = turbo_tasks();
let update = if matches!(verification_mode, VerificationMode::EqualityCheck) { let update = if matches!(verification_mode, VerificationMode::EqualityCheck) {
let content = tt let content = tt.read_own_task_cell(self.current_task, self.index).ok();
.read_own_task_cell(
self.current_task,
self.index,
ReadCellOptions {
// INVALIDATION: Reading our own cell must be untracked
tracking: ReadCellTracking::Untracked,
is_serializable_cell_content: self.is_serializable_cell_content,
final_read_hint: false,
},
)
.ok();
if let Some(TypedCellContent(_, CellContent(Some(shared_ref_exp)))) = content { if let Some(TypedCellContent(_, CellContent(Some(shared_ref_exp)))) = content {
// pointer equality (not value equality) // pointer equality (not value equality)
shared_ref_exp != shared_ref shared_ref_exp != shared_ref
...@@ -2333,7 +2293,6 @@ impl CurrentCellRef { ...@@ -2333,7 +2293,6 @@ impl CurrentCellRef {
tt.update_own_task_cell( tt.update_own_task_cell(
self.current_task, self.current_task,
self.index, self.index,
self.is_serializable_cell_content,
CellContent(Some(shared_ref)), CellContent(Some(shared_ref)),
None, None,
None, None,
...@@ -2355,10 +2314,10 @@ fn extract_sr_value<T: VcValueType>(sr: &SharedReference) -> &T { ...@@ -2355,10 +2314,10 @@ fn extract_sr_value<T: VcValueType>(sr: &SharedReference) -> &T {
} }
pub fn find_cell_by_type<T: VcValueType>() -> CurrentCellRef { pub fn find_cell_by_type<T: VcValueType>() -> CurrentCellRef {
find_cell_by_id(T::get_value_type_id(), T::has_serialization()) find_cell_by_id(T::get_value_type_id())
} }
pub fn find_cell_by_id(ty: ValueTypeId, is_serializable_cell_content: bool) -> CurrentCellRef { pub fn find_cell_by_id(ty: ValueTypeId) -> CurrentCellRef {
CURRENT_TASK_STATE.with(|ts| { CURRENT_TASK_STATE.with(|ts| {
let current_task = current_task("celling turbo_tasks values"); let current_task = current_task("celling turbo_tasks values");
let mut ts = ts.write().unwrap(); let mut ts = ts.write().unwrap();
...@@ -2369,7 +2328,6 @@ pub fn find_cell_by_id(ty: ValueTypeId, is_serializable_cell_content: bool) -> C ...@@ -2369,7 +2328,6 @@ pub fn find_cell_by_id(ty: ValueTypeId, is_serializable_cell_content: bool) -> C
CurrentCellRef { CurrentCellRef {
current_task, current_task,
index: CellId { type_id: ty, index }, index: CellId { type_id: ty, index },
is_serializable_cell_content,
} }
}) })
} }
......
...@@ -135,16 +135,10 @@ impl RawVc { ...@@ -135,16 +135,10 @@ impl RawVc {
} }
} }
pub(crate) fn into_read(self, is_serializable_cell_content: bool) -> ReadRawVcFuture { pub(crate) fn into_read(self) -> ReadRawVcFuture {
// returns a custom future to have something concrete and sized // returns a custom future to have something concrete and sized
// this avoids boxing in IntoFuture // this avoids boxing in IntoFuture
ReadRawVcFuture::new(self, Some(is_serializable_cell_content)) ReadRawVcFuture::new(self)
}
pub(crate) fn into_read_with_unknown_is_serializable_cell_content(self) -> ReadRawVcFuture {
// returns a custom future to have something concrete and sized
// this avoids boxing in IntoFuture
ReadRawVcFuture::new(self, None)
} }
/// See [`crate::Vc::to_resolved`]. /// See [`crate::Vc::to_resolved`].
...@@ -396,10 +390,6 @@ pub struct ReadRawVcFuture { ...@@ -396,10 +390,6 @@ pub struct ReadRawVcFuture {
resolve: ResolveRawVcFuture, resolve: ResolveRawVcFuture,
/// Phase 2: options for the cell read once we have a [`RawVc::TaskCell`]. /// Phase 2: options for the cell read once we have a [`RawVc::TaskCell`].
read_cell_options: ReadCellOptions, read_cell_options: ReadCellOptions,
/// If `true`, the `is_serializable_cell_content` flag in `read_cell_options` is unknown at
/// construction time and must be determined lazily from the type registry once we reach the
/// [`RawVc::TaskCell`].
is_serializable_cell_content_unknown: bool,
/// Phase 2: the resolved task and cell identity, set when phase 1 completes. /// Phase 2: the resolved task and cell identity, set when phase 1 completes.
resolved: Option<(TaskId, CellId)>, resolved: Option<(TaskId, CellId)>,
/// Phase 2: listener for the cell read wait. /// Phase 2: listener for the cell read wait.
...@@ -407,14 +397,10 @@ pub struct ReadRawVcFuture { ...@@ -407,14 +397,10 @@ pub struct ReadRawVcFuture {
} }
impl ReadRawVcFuture { impl ReadRawVcFuture {
pub(crate) fn new(vc: RawVc, is_serializable_cell_content: Option<bool>) -> Self { pub(crate) fn new(vc: RawVc) -> Self {
ReadRawVcFuture { ReadRawVcFuture {
resolve: ResolveRawVcFuture::new(vc), resolve: ResolveRawVcFuture::new(vc),
read_cell_options: ReadCellOptions { read_cell_options: ReadCellOptions::default(),
is_serializable_cell_content: is_serializable_cell_content.unwrap_or(false),
..Default::default()
},
is_serializable_cell_content_unknown: is_serializable_cell_content.is_none(),
resolved: None, resolved: None,
listener: None, listener: None,
} }
...@@ -478,14 +464,6 @@ impl Future for ReadRawVcFuture { ...@@ -478,14 +464,6 @@ impl Future for ReadRawVcFuture {
// At this point `this.resolved` is `Some((task, index))`. // At this point `this.resolved` is `Some((task, index))`.
let (task, index) = this.resolved.unwrap(); let (task, index) = this.resolved.unwrap();
// Lazily resolve `is_serializable_cell_content` from the type registry on the first
// entry into phase 2, then clear the flag so subsequent polls skip this lookup.
if this.is_serializable_cell_content_unknown {
this.read_cell_options.is_serializable_cell_content =
get_value_type(index.type_id).bincode.is_some();
this.is_serializable_cell_content_unknown = false;
}
let poll_fn = |tt: &Arc<dyn TurboTasksApi>| -> Poll<Self::Output> { let poll_fn = |tt: &Arc<dyn TurboTasksApi>| -> Poll<Self::Output> {
loop { loop {
ready!(poll_listener(&mut this.listener, cx)); ready!(poll_listener(&mut this.listener, cx));
......
...@@ -3,7 +3,6 @@ use crate::{ReadConsistency, ReadTracking, manager::ReadCellTracking}; ...@@ -3,7 +3,6 @@ use crate::{ReadConsistency, ReadTracking, manager::ReadCellTracking};
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default)]
pub struct ReadCellOptions { pub struct ReadCellOptions {
pub tracking: ReadCellTracking, pub tracking: ReadCellTracking,
pub is_serializable_cell_content: bool,
pub final_read_hint: bool, pub final_read_hint: bool,
} }
......
...@@ -18,7 +18,7 @@ use turbo_bincode::{ ...@@ -18,7 +18,7 @@ use turbo_bincode::{
use unsize::CoerceUnsize; use unsize::CoerceUnsize;
use crate::{ use crate::{
ValueType, ValueTypeId, registry, ValueType, ValueTypeId, ValueTypePersistence, registry,
triomphe_utils::{coerce_to_any_send_sync, downcast_triomphe_arc}, triomphe_utils::{coerce_to_any_send_sync, downcast_triomphe_arc},
}; };
...@@ -69,9 +69,9 @@ impl TurboBincodeEncode for TypedSharedReference { ...@@ -69,9 +69,9 @@ impl TurboBincodeEncode for TypedSharedReference {
fn encode(&self, encoder: &mut TurboBincodeEncoder) -> Result<(), EncodeError> { fn encode(&self, encoder: &mut TurboBincodeEncoder) -> Result<(), EncodeError> {
let Self { type_id, reference } = self; let Self { type_id, reference } = self;
let value_type = registry::get_value_type(*type_id); let value_type = registry::get_value_type(*type_id);
if let Some(bincode) = value_type.bincode { if let ValueTypePersistence::Persistable(encode_fn, _) = value_type.persistence {
type_id.encode(encoder)?; type_id.encode(encoder)?;
bincode.0(&*reference.0, encoder)?; encode_fn(&*reference.0, encoder)?;
Ok(()) Ok(())
} else { } else {
Err(EncodeError::OtherString(format!( Err(EncodeError::OtherString(format!(
...@@ -86,8 +86,8 @@ impl<Context> TurboBincodeDecode<Context> for TypedSharedReference { ...@@ -86,8 +86,8 @@ impl<Context> TurboBincodeDecode<Context> for TypedSharedReference {
fn decode(decoder: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> { fn decode(decoder: &mut TurboBincodeDecoder) -> Result<Self, DecodeError> {
let type_id = ValueTypeId::decode(decoder)?; let type_id = ValueTypeId::decode(decoder)?;
let value_type = registry::get_value_type(type_id); let value_type = registry::get_value_type(type_id);
if let Some(bincode) = value_type.bincode { if let ValueTypePersistence::Persistable(_, decode_fn) = value_type.persistence {
let reference = bincode.1(decoder)?; let reference = decode_fn(decoder)?;
Ok(Self { type_id, reference }) Ok(Self { type_id, reference })
} else { } else {
#[cold] #[cold]
......
...@@ -500,7 +500,7 @@ macro_rules! into_future { ...@@ -500,7 +500,7 @@ macro_rules! into_future {
type Output = <ReadVcFuture<T> as Future>::Output; type Output = <ReadVcFuture<T> as Future>::Output;
type IntoFuture = ReadVcFuture<T>; type IntoFuture = ReadVcFuture<T>;
fn into_future(self) -> Self::IntoFuture { fn into_future(self) -> Self::IntoFuture {
self.node.into_read(T::has_serialization()).into() self.node.into_read().into()
} }
} }
}; };
...@@ -517,28 +517,19 @@ where ...@@ -517,28 +517,19 @@ where
/// Do not use this: Use [`OperationVc::read_strongly_consistent`] instead. /// Do not use this: Use [`OperationVc::read_strongly_consistent`] instead.
#[cfg(feature = "non_operation_vc_strongly_consistent")] #[cfg(feature = "non_operation_vc_strongly_consistent")]
pub fn strongly_consistent(self) -> ReadVcFuture<T> { pub fn strongly_consistent(self) -> ReadVcFuture<T> {
self.node self.node.into_read().strongly_consistent().into()
.into_read(T::has_serialization())
.strongly_consistent()
.into()
} }
/// Returns a untracked read of the value. This will not invalidate the current function when /// Returns a untracked read of the value. This will not invalidate the current function when
/// the read value changed. /// the read value changed.
pub fn untracked(self) -> ReadVcFuture<T> { pub fn untracked(self) -> ReadVcFuture<T> {
self.node self.node.into_read().untracked().into()
.into_read(T::has_serialization())
.untracked()
.into()
} }
/// Read the value with the hint that this is the final read of the value. This might drop the /// Read the value with the hint that this is the final read of the value. This might drop the
/// cell content. Future reads might need to recompute the value. /// cell content. Future reads might need to recompute the value.
pub fn final_read_hint(self) -> ReadVcFuture<T> { pub fn final_read_hint(self) -> ReadVcFuture<T> {
self.node self.node.into_read().final_read_hint().into()
.into_read(T::has_serialization())
.final_read_hint()
.into()
} }
} }
...@@ -549,7 +540,7 @@ where ...@@ -549,7 +540,7 @@ where
{ {
/// Read the value and returns a owned version of it. It might clone the value. /// Read the value and returns a owned version of it. It might clone the value.
pub fn owned(self) -> ReadOwnedVcFuture<T> { pub fn owned(self) -> ReadOwnedVcFuture<T> {
let future: ReadVcFuture<T> = self.node.into_read(T::has_serialization()).into(); let future: ReadVcFuture<T> = self.node.into_read().into();
future.owned() future.owned()
} }
} }
...@@ -566,7 +557,7 @@ where ...@@ -566,7 +557,7 @@ where
Q: Hash + ?Sized, Q: Hash + ?Sized,
VcReadTarget<T>: KeyedAccess<Q>, VcReadTarget<T>: KeyedAccess<Q>,
{ {
let future: ReadVcFuture<T> = self.node.into_read(T::has_serialization()).into(); let future: ReadVcFuture<T> = self.node.into_read().into();
future.get(key) future.get(key)
} }
...@@ -577,7 +568,7 @@ where ...@@ -577,7 +568,7 @@ where
Q: Hash + ?Sized, Q: Hash + ?Sized,
VcReadTarget<T>: KeyedAccess<Q>, VcReadTarget<T>: KeyedAccess<Q>,
{ {
let future: ReadVcFuture<T> = self.node.into_read(T::has_serialization()).into(); let future: ReadVcFuture<T> = self.node.into_read().into();
future.contains_key(key) future.contains_key(key)
} }
} }
...@@ -594,9 +585,7 @@ where ...@@ -594,9 +585,7 @@ where
/// have the same future-like semantics as value vcs when it comes to producing refs. This /// have the same future-like semantics as value vcs when it comes to producing refs. This
/// behavior is rarely needed, so in most cases, `.await`ing a trait vc is a mistake. /// behavior is rarely needed, so in most cases, `.await`ing a trait vc is a mistake.
pub fn into_trait_ref(self) -> ReadVcFuture<T, VcValueTraitCast<T>> { pub fn into_trait_ref(self) -> ReadVcFuture<T, VcValueTraitCast<T>> {
self.node self.node.into_read().into()
.into_read_with_unknown_is_serializable_cell_content()
.into()
} }
} }
......
...@@ -171,11 +171,7 @@ impl<T: ?Sized> OperationVc<T> { ...@@ -171,11 +171,7 @@ impl<T: ?Sized> OperationVc<T> {
where where
T: VcValueType, T: VcValueType,
{ {
self.connect() self.connect().node.into_read().strongly_consistent().into()
.node
.into_read(T::has_serialization())
.strongly_consistent()
.into()
} }
/// [Connects the `OperationVc`][Self::connect] and returns a [strongly /// [Connects the `OperationVc`][Self::connect] and returns a [strongly
......
...@@ -24,7 +24,7 @@ use crate::{ ...@@ -24,7 +24,7 @@ use crate::{
chunking_context::{CURRENT_CHUNK_METHOD_DOCUMENT_CURRENT_SCRIPT_EXPR, CurrentChunkMethod}, chunking_context::{CURRENT_CHUNK_METHOD_DOCUMENT_CURRENT_SCRIPT_EXPR, CurrentChunkMethod},
}; };
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
pub struct EcmascriptBrowserChunkContent { pub struct EcmascriptBrowserChunkContent {
pub(super) chunking_context: ResolvedVc<BrowserChunkingContext>, pub(super) chunking_context: ResolvedVc<BrowserChunkingContext>,
pub(super) chunk: ResolvedVc<EcmascriptBrowserChunk>, pub(super) chunk: ResolvedVc<EcmascriptBrowserChunk>,
......
...@@ -9,7 +9,7 @@ type VersionTraitRef = TraitRef<Box<dyn Version>>; ...@@ -9,7 +9,7 @@ type VersionTraitRef = TraitRef<Box<dyn Version>>;
/// The version of a [`EcmascriptDevChunkListContent`]. /// The version of a [`EcmascriptDevChunkListContent`].
/// ///
/// [`EcmascriptDevChunkListContent`]: super::content::EcmascriptDevChunkListContent /// [`EcmascriptDevChunkListContent`]: super::content::EcmascriptDevChunkListContent
#[turbo_tasks::value(serialization = "none", shared)] #[turbo_tasks::value(serialization = "skip", shared)]
pub(super) struct EcmascriptDevChunkListVersion { pub(super) struct EcmascriptDevChunkListVersion {
/// A map from chunk path to its version. /// A map from chunk path to its version.
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
......
...@@ -15,7 +15,7 @@ use super::{ ...@@ -15,7 +15,7 @@ use super::{
/// [`EcmascriptChunkContentMerger`]. /// [`EcmascriptChunkContentMerger`].
/// ///
/// [`EcmascriptChunkContentMerger`]: super::merger::EcmascriptChunkContentMerger /// [`EcmascriptChunkContentMerger`]: super::merger::EcmascriptChunkContentMerger
#[turbo_tasks::value(serialization = "none", shared)] #[turbo_tasks::value(serialization = "skip", shared)]
pub(super) struct EcmascriptBrowserMergedChunkContent { pub(super) struct EcmascriptBrowserMergedChunkContent {
pub contents: Vec<ResolvedVc<EcmascriptBrowserChunkContent>>, pub contents: Vec<ResolvedVc<EcmascriptBrowserChunkContent>>,
} }
......
...@@ -8,7 +8,7 @@ use super::super::version::EcmascriptBrowserChunkVersion; ...@@ -8,7 +8,7 @@ use super::super::version::EcmascriptBrowserChunkVersion;
/// The version of a [`super::content::EcmascriptMergedChunkContent`]. This is /// The version of a [`super::content::EcmascriptMergedChunkContent`]. This is
/// essentially a composite [`EcmascriptChunkVersion`]. /// essentially a composite [`EcmascriptChunkVersion`].
#[turbo_tasks::value(serialization = "none", shared)] #[turbo_tasks::value(serialization = "skip", shared)]
pub(super) struct EcmascriptBrowserMergedChunkVersion { pub(super) struct EcmascriptBrowserMergedChunkVersion {
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
pub(super) versions: Vec<ReadRef<EcmascriptBrowserChunkVersion>>, pub(super) versions: Vec<ReadRef<EcmascriptBrowserChunkVersion>>,
......
...@@ -8,7 +8,7 @@ use turbopack_ecmascript::chunk::EcmascriptChunkContent; ...@@ -8,7 +8,7 @@ use turbopack_ecmascript::chunk::EcmascriptChunkContent;
use super::content_entry::EcmascriptBrowserChunkContentEntries; use super::content_entry::EcmascriptBrowserChunkContentEntries;
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
pub(super) struct EcmascriptBrowserChunkVersion { pub(super) struct EcmascriptBrowserChunkVersion {
pub(super) chunk_path: String, pub(super) chunk_path: String,
pub(super) entries_hashes: FxIndexMap<ModuleId, u64>, pub(super) entries_hashes: FxIndexMap<ModuleId, u64>,
......
...@@ -349,7 +349,7 @@ impl SeenIssues { ...@@ -349,7 +349,7 @@ impl SeenIssues {
/// ///
/// The ConsoleUi can be shared and capture issues from multiple sources, with deduplication /// The ConsoleUi can be shared and capture issues from multiple sources, with deduplication
/// operating across all issues. /// operating across all issues.
#[turbo_tasks::value(shared, serialization = "none", eq = "manual")] #[turbo_tasks::value(shared, serialization = "skip", evict = "never", eq = "manual")]
#[derive(Clone)] #[derive(Clone)]
pub struct ConsoleUi { pub struct ConsoleUi {
options: LogOptions, options: LogOptions,
......
...@@ -140,7 +140,7 @@ impl AvailableModules { ...@@ -140,7 +140,7 @@ impl AvailableModules {
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AvailableModulesSnapshot { pub struct AvailableModulesSnapshot {
parent: Option<ReadRef<AvailableModulesSnapshot>>, parent: Option<ReadRef<AvailableModulesSnapshot>>,
......
...@@ -6,7 +6,7 @@ use auto_hash_map::AutoSet; ...@@ -6,7 +6,7 @@ use auto_hash_map::AutoSet;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{CollectiblesSource, FxIndexMap, ResolvedVc, Upcast, Vc, emit}; use turbo_tasks::{CollectiblesSource, FxIndexMap, ResolvedVc, Upcast, Vc, emit};
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct PlainDiagnostic { pub struct PlainDiagnostic {
pub category: RcStr, pub category: RcStr,
......
...@@ -354,7 +354,7 @@ impl EdgeWorkerEnvironment { ...@@ -354,7 +354,7 @@ impl EdgeWorkerEnvironment {
// TODO preset_env_base::Version implements Serialize/Deserialize incorrectly // TODO preset_env_base::Version implements Serialize/Deserialize incorrectly
#[derive(Debug)] #[derive(Debug)]
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "skip")]
pub struct RuntimeVersions(#[turbo_tasks(trace_ignore)] pub Versions); pub struct RuntimeVersions(#[turbo_tasks(trace_ignore)] pub Versions);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -892,7 +892,7 @@ impl Display for IssueStage { ...@@ -892,7 +892,7 @@ impl Display for IssueStage {
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Clone, Debug, PartialOrd, Ord)] #[derive(Clone, Debug, PartialOrd, Ord)]
pub struct PlainIssue { pub struct PlainIssue {
pub severity: IssueSeverity, pub severity: IssueSeverity,
...@@ -910,7 +910,7 @@ pub struct PlainIssue { ...@@ -910,7 +910,7 @@ pub struct PlainIssue {
pub import_traces: Vec<PlainTrace>, pub import_traces: Vec<PlainTrace>,
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Clone, Debug, PartialOrd, Ord)] #[derive(Clone, Debug, PartialOrd, Ord)]
pub struct PlainAdditionalIssueSource { pub struct PlainAdditionalIssueSource {
pub description: RcStr, pub description: RcStr,
...@@ -1014,14 +1014,14 @@ impl PlainIssue { ...@@ -1014,14 +1014,14 @@ impl PlainIssue {
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Clone, Debug, PartialOrd, Ord)] #[derive(Clone, Debug, PartialOrd, Ord)]
pub struct PlainIssueSource { pub struct PlainIssueSource {
pub asset: ReadRef<PlainSource>, pub asset: ReadRef<PlainSource>,
pub range: Option<(SourcePos, SourcePos)>, pub range: Option<(SourcePos, SourcePos)>,
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Clone, Debug, PartialOrd, Ord)] #[derive(Clone, Debug, PartialOrd, Ord)]
pub struct PlainSource { pub struct PlainSource {
pub ident: ReadRef<RcStr>, pub ident: ReadRef<RcStr>,
......
...@@ -688,7 +688,7 @@ impl ImportTracer for ModuleGraphImportTracer { ...@@ -688,7 +688,7 @@ impl ImportTracer for ModuleGraphImportTracer {
/// The ReadRef version of ModuleGraphBase. This is better for eventual consistency, as the graphs /// The ReadRef version of ModuleGraphBase. This is better for eventual consistency, as the graphs
/// aren't awaited multiple times within the same task. /// aren't awaited multiple times within the same task.
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
pub struct ModuleGraph { pub struct ModuleGraph {
input_graphs: Vec<OperationVc<SingleModuleGraph>>, input_graphs: Vec<OperationVc<SingleModuleGraph>>,
input_binding_usage: Option<OperationVc<BindingUsageInfo>>, input_binding_usage: Option<OperationVc<BindingUsageInfo>>,
...@@ -858,7 +858,7 @@ impl Deref for ModuleGraph { ...@@ -858,7 +858,7 @@ impl Deref for ModuleGraph {
} }
} }
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
pub struct ModuleGraphLayer { pub struct ModuleGraphLayer {
snapshot: ModuleGraphSnapshot, snapshot: ModuleGraphSnapshot,
} }
...@@ -2310,7 +2310,7 @@ pub mod tests { ...@@ -2310,7 +2310,7 @@ pub mod tests {
+ Send + Send
+ 'static, + 'static,
) { ) {
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(serialization = "skip", eq = "manual", cell = "new")]
struct SetupGraph { struct SetupGraph {
module_graph: ReadRef<ModuleGraph>, module_graph: ReadRef<ModuleGraph>,
entry_modules: Vec<ResolvedVc<Box<dyn Module>>>, entry_modules: Vec<ResolvedVc<Box<dyn Module>>>,
......
...@@ -32,7 +32,7 @@ impl Deref for PackageJson { ...@@ -32,7 +32,7 @@ impl Deref for PackageJson {
} }
} }
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "skip")]
pub struct OptionPackageJson(Option<PackageJson>); pub struct OptionPackageJson(Option<PackageJson>);
/// Reads a package.json file (if it exists). If the file is unparsable, it /// Reads a package.json file (if it exists). If the file is unparsable, it
......
...@@ -174,7 +174,7 @@ impl Version for NotFoundVersion { ...@@ -174,7 +174,7 @@ impl Version for NotFoundVersion {
} }
/// Describes an update to a versioned object. /// Describes an update to a versioned object.
#[turbo_tasks::value(serialization = "none", shared)] #[turbo_tasks::value(serialization = "skip", shared)]
#[derive(Debug)] #[derive(Debug)]
pub enum Update { pub enum Update {
/// The asset can't be meaningfully updated while the app is running, so the /// The asset can't be meaningfully updated while the app is running, so the
...@@ -260,7 +260,7 @@ struct VersionRef( ...@@ -260,7 +260,7 @@ struct VersionRef(
#[turbo_tasks(trace_ignore)] TraitRef<Box<dyn Version>>, #[turbo_tasks(trace_ignore)] TraitRef<Box<dyn Version>>,
); );
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip", evict = "never")]
pub struct VersionState { pub struct VersionState {
version: State<VersionRef>, version: State<VersionRef>,
} }
......
...@@ -5,7 +5,7 @@ use crate::chunk::CssImport; ...@@ -5,7 +5,7 @@ use crate::chunk::CssImport;
/// impl of code generation inferred from a ModuleReference. /// impl of code generation inferred from a ModuleReference.
/// This is rust only and can't be implemented by non-rust plugins. /// This is rust only and can't be implemented by non-rust plugins.
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
pub struct CodeGeneration { pub struct CodeGeneration {
#[turbo_tasks(debug_ignore, trace_ignore)] #[turbo_tasks(debug_ignore, trace_ignore)]
pub imports: Vec<CssImport>, pub imports: Vec<CssImport>,
......
...@@ -149,7 +149,7 @@ async fn stylesheet_to_css( ...@@ -149,7 +149,7 @@ async fn stylesheet_to_css(
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct UnresolvedUrlReferences(pub Vec<(String, ResolvedVc<UrlAssetReference>)>); pub struct UnresolvedUrlReferences(pub Vec<(String, ResolvedVc<UrlAssetReference>)>);
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
#[allow(clippy::large_enum_variant)] // This is a turbo-tasks value #[allow(clippy::large_enum_variant)] // This is a turbo-tasks value
pub enum ParseCssResult { pub enum ParseCssResult {
Ok { Ok {
...@@ -169,7 +169,7 @@ pub enum ParseCssResult { ...@@ -169,7 +169,7 @@ pub enum ParseCssResult {
NotFound, NotFound,
} }
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
pub enum CssWithPlaceholderResult { pub enum CssWithPlaceholderResult {
Ok { Ok {
parse_result: ResolvedVc<ParseCssResult>, parse_result: ResolvedVc<ParseCssResult>,
...@@ -188,7 +188,7 @@ pub enum CssWithPlaceholderResult { ...@@ -188,7 +188,7 @@ pub enum CssWithPlaceholderResult {
NotFound, NotFound,
} }
#[turbo_tasks::value(shared, serialization = "none")] #[turbo_tasks::value(shared, serialization = "skip")]
pub enum FinalCssResult { pub enum FinalCssResult {
Ok { Ok {
#[turbo_tasks(trace_ignore)] #[turbo_tasks(trace_ignore)]
......
...@@ -21,7 +21,7 @@ use crate::{ ...@@ -21,7 +21,7 @@ use crate::{
references::css_resolve, references::css_resolve,
}; };
#[turbo_tasks::value(eq = "manual", serialization = "none", shared)] #[turbo_tasks::value(eq = "manual", serialization = "skip", shared)]
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum ImportAttributes { pub enum ImportAttributes {
LightningCss { LightningCss {
......
...@@ -28,7 +28,7 @@ use crate::source::{ ...@@ -28,7 +28,7 @@ use crate::source::{
resolve::{ResolveSourceRequestResult, resolve_source_request}, resolve::{ResolveSourceRequestResult, resolve_source_request},
}; };
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
enum GetFromSourceResult { enum GetFromSourceResult {
Static { Static {
content: ReadRef<FileContent>, content: ReadRef<FileContent>,
...@@ -71,7 +71,7 @@ async fn get_from_source_operation( ...@@ -71,7 +71,7 @@ async fn get_from_source_operation(
) )
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct GetFromSourceResultWithCollectibles { struct GetFromSourceResultWithCollectibles {
result: ReadRef<GetFromSourceResult>, result: ReadRef<GetFromSourceResult>,
effects: Effects, effects: Effects,
......
...@@ -55,7 +55,7 @@ where ...@@ -55,7 +55,7 @@ where
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct ContentSourceWithIssues { struct ContentSourceWithIssues {
source_op: OperationVc<Box<dyn ContentSource>>, source_op: OperationVc<Box<dyn ContentSource>>,
effects: Effects, effects: Effects,
......
...@@ -28,7 +28,7 @@ struct OutputAssetsMap( ...@@ -28,7 +28,7 @@ struct OutputAssetsMap(
type ExpandedState = State<FxHashSet<RcStr>>; type ExpandedState = State<FxHashSet<RcStr>>;
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(serialization = "skip", eq = "manual", cell = "new")]
pub struct AssetGraphContentSource { pub struct AssetGraphContentSource {
root_path: FileSystemPath, root_path: FileSystemPath,
root_assets: ResolvedVc<OutputAssetsSet>, root_assets: ResolvedVc<OutputAssetsSet>,
......
...@@ -23,7 +23,7 @@ use crate::source::{ ...@@ -23,7 +23,7 @@ use crate::source::{
/// The result of [`resolve_source_request`]. Similar to a [`ContentSourceContent`], but without the /// The result of [`resolve_source_request`]. Similar to a [`ContentSourceContent`], but without the
/// [`Rewrite`][ContentSourceContent::Rewrite] variant, as this is taken care in the function. /// [`Rewrite`][ContentSourceContent::Rewrite] variant, as this is taken care in the function.
#[turbo_tasks::value(serialization = "none", shared)] #[turbo_tasks::value(serialization = "skip", shared)]
pub enum ResolveSourceRequestResult { pub enum ResolveSourceRequestResult {
NotFound, NotFound,
Static(ResolvedVc<StaticContent>, ResolvedVc<HeaderList>), Static(ResolvedVc<StaticContent>, ResolvedVc<HeaderList>),
......
...@@ -359,7 +359,7 @@ impl Stream for UpdateStream { ...@@ -359,7 +359,7 @@ impl Stream for UpdateStream {
} }
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
#[derive(Debug)] #[derive(Debug)]
pub enum UpdateStreamItem { pub enum UpdateStreamItem {
NotFound, NotFound,
...@@ -369,7 +369,7 @@ pub enum UpdateStreamItem { ...@@ -369,7 +369,7 @@ pub enum UpdateStreamItem {
}, },
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
struct FatalStreamIssue { struct FatalStreamIssue {
description: ResolvedVc<StyledString>, description: ResolvedVc<StyledString>,
resource: RcStr, resource: RcStr,
......
...@@ -16,7 +16,16 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext}; ...@@ -16,7 +16,16 @@ use turbopack_ecmascript::{CustomTransformer, TransformContext};
/// Internally this contains a `CompiledPluginModuleBytes`, which points to the /// Internally this contains a `CompiledPluginModuleBytes`, which points to the
/// compiled, serialized WASM module instead of raw file bytes to reduce the /// compiled, serialized WASM module instead of raw file bytes to reduce the
/// cost of the compilation. /// cost of the compilation.
#[turbo_tasks::value(serialization = "none", eq = "manual", cell = "new", shared)] ///
/// Tagged `evict = "last"` so eviction prefers evicting cheaper cells first —
/// re-deriving a compiled module is pure but pays a non-trivial WASM compile.
#[turbo_tasks::value(
serialization = "skip",
evict = "last",
eq = "manual",
cell = "new",
shared
)]
pub struct SwcPluginModule { pub struct SwcPluginModule {
pub name: RcStr, pub name: RcStr,
#[turbo_tasks(trace_ignore, debug_ignore)] #[turbo_tasks(trace_ignore, debug_ignore)]
......
...@@ -12,10 +12,10 @@ use crate::chunk::{ ...@@ -12,10 +12,10 @@ use crate::chunk::{
EcmascriptChunkItemWithAsyncInfo, EcmascriptChunkItemWithAsyncInfo,
}; };
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "skip")]
pub struct CodeAndIds(SmallVec<[(ModuleId, ReadRef<Code>); 1]>); pub struct CodeAndIds(SmallVec<[(ModuleId, ReadRef<Code>); 1]>);
#[turbo_tasks::value(transparent, serialization = "none")] #[turbo_tasks::value(transparent, serialization = "skip")]
pub struct BatchGroupCodeAndIds( pub struct BatchGroupCodeAndIds(
FxHashMap<EcmascriptChunkItemOrBatchWithAsyncInfo, ReadRef<CodeAndIds>>, FxHashMap<EcmascriptChunkItemOrBatchWithAsyncInfo, ReadRef<CodeAndIds>>,
); );
......
...@@ -53,7 +53,7 @@ pub enum RewriteSourcePath { ...@@ -53,7 +53,7 @@ pub enum RewriteSourcePath {
// Note we don't want to persist this as `module_factory_with_code_generation_issue` is already // Note we don't want to persist this as `module_factory_with_code_generation_issue` is already
// persisted and we want to avoid duplicating it. // persisted and we want to avoid duplicating it.
#[turbo_tasks::value(shared, serialization = "none")] #[turbo_tasks::value(shared, serialization = "skip")]
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct EcmascriptChunkItemContent { pub struct EcmascriptChunkItemContent {
pub inner_code: Rope, pub inner_code: Rope,
......
...@@ -144,7 +144,7 @@ impl Visit for IdentCollector { ...@@ -144,7 +144,7 @@ impl Visit for IdentCollector {
} }
} }
#[turbo_tasks::value(shared, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual", cell = "new")]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum ParseResult { pub enum ParseResult {
Ok { Ok {
......
...@@ -93,7 +93,7 @@ pub trait CustomTransformer: Debug { ...@@ -93,7 +93,7 @@ pub trait CustomTransformer: Debug {
/// A wrapper around a TransformPlugin instance, allowing it to operate with /// A wrapper around a TransformPlugin instance, allowing it to operate with
/// the turbo_task caching requirements. /// the turbo_task caching requirements.
#[turbo_tasks::value(transparent, serialization = "none", eq = "manual", cell = "new")] #[turbo_tasks::value(transparent, serialization = "skip", eq = "manual", cell = "new")]
#[derive(Debug)] #[derive(Debug)]
pub struct TransformPlugin(#[turbo_tasks(trace_ignore)] Box<dyn CustomTransformer + Send + Sync>); pub struct TransformPlugin(#[turbo_tasks(trace_ignore)] Box<dyn CustomTransformer + Send + Sync>);
......
...@@ -437,7 +437,7 @@ async fn get_part_id(result: &SplitResult, part: &ModulePart) -> Result<u32> { ...@@ -437,7 +437,7 @@ async fn get_part_id(result: &SplitResult, part: &ModulePart) -> Result<u32> {
) )
} }
#[turbo_tasks::value(shared, serialization = "none", eq = "manual")] #[turbo_tasks::value(shared, serialization = "skip", eq = "manual")]
pub(crate) enum SplitResult { pub(crate) enum SplitResult {
Ok { Ok {
asset_ident: ResolvedVc<AssetIdent>, asset_ident: ResolvedVc<AssetIdent>,
......
...@@ -24,7 +24,7 @@ use crate::{ ...@@ -24,7 +24,7 @@ use crate::{
utils::unparen, utils::unparen,
}; };
#[turbo_tasks::value(shared, serialization = "none")] #[turbo_tasks::value(shared, serialization = "skip")]
#[derive(Debug)] #[derive(Debug)]
pub enum WebpackRuntime { pub enum WebpackRuntime {
Webpack5 { Webpack5 {
......
...@@ -67,7 +67,13 @@ enum EvalJavaScriptIncomingMessage { ...@@ -67,7 +67,13 @@ enum EvalJavaScriptIncomingMessage {
Error(StructuredError), Error(StructuredError),
} }
#[turbo_tasks::value(cell = "new", serialization = "none", eq = "manual", shared)] #[turbo_tasks::value(
cell = "new",
serialization = "skip",
evict = "last",
eq = "manual",
shared
)]
pub struct EvaluatePool { pub struct EvaluatePool {
#[turbo_tasks(trace_ignore, debug_ignore)] #[turbo_tasks(trace_ignore, debug_ignore)]
pool: Box<dyn EvaluateOperation>, pool: Box<dyn EvaluateOperation>,
......
...@@ -531,7 +531,13 @@ impl ProcessArgs { ...@@ -531,7 +531,13 @@ impl ProcessArgs {
/// ///
/// The worker will *not* use the `env` of the parent process by default. All environment variables /// The worker will *not* use the `env` of the parent process by default. All environment variables
/// need to be provided to make the execution as pure as possible. /// need to be provided to make the execution as pure as possible.
#[turbo_tasks::value(cell = "new", serialization = "none", eq = "manual", shared)] #[turbo_tasks::value(
cell = "new",
serialization = "skip",
evict = "last",
eq = "manual",
shared
)]
pub struct ChildProcessPool { pub struct ChildProcessPool {
cwd: PathBuf, cwd: PathBuf,
entrypoint: PathBuf, entrypoint: PathBuf,
......
...@@ -36,7 +36,13 @@ mod worker_thread; ...@@ -36,7 +36,13 @@ mod worker_thread;
static OPERATION_TASK_ID: AtomicU32 = AtomicU32::new(1); static OPERATION_TASK_ID: AtomicU32 = AtomicU32::new(1);
#[turbo_tasks::value(cell = "new", serialization = "none", eq = "manual", shared)] #[turbo_tasks::value(
cell = "new",
serialization = "skip",
evict = "last",
eq = "manual",
shared
)]
pub(crate) struct WorkerThreadPool { pub(crate) struct WorkerThreadPool {
worker_options: Arc<WorkerOptions>, worker_options: Arc<WorkerOptions>,
concurrency: usize, concurrency: usize,
......
...@@ -57,7 +57,7 @@ pub(crate) struct PoolState { ...@@ -57,7 +57,7 @@ pub(crate) struct PoolState {
pub(crate) waiters: Mutex<Vec<oneshot::Sender<u32>>>, pub(crate) waiters: Mutex<Vec<oneshot::Sender<u32>>>,
} }
#[turbo_tasks::value(cell = "new", serialization = "none", eq = "manual", shared)] #[turbo_tasks::value(cell = "new", serialization = "skip", eq = "manual", shared)]
#[derive(Clone, PartialEq, Eq, Hash)] #[derive(Clone, PartialEq, Eq, Hash)]
pub(super) struct WorkerOptions { pub(super) struct WorkerOptions {
pub(super) filename: RcStr, pub(super) filename: RcStr,
......
...@@ -9,7 +9,7 @@ use turbopack_core::{ ...@@ -9,7 +9,7 @@ use turbopack_core::{
}; };
use turbopack_ecmascript::chunk::{CodeAndIds, EcmascriptChunkContent}; use turbopack_ecmascript::chunk::{CodeAndIds, EcmascriptChunkContent};
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip")]
pub(super) struct EcmascriptBuildNodeChunkVersion { pub(super) struct EcmascriptBuildNodeChunkVersion {
pub(super) chunk_path: String, pub(super) chunk_path: String,
pub(super) chunk_items: Vec<ReadRef<CodeAndIds>>, pub(super) chunk_items: Vec<ReadRef<CodeAndIds>>,
......
...@@ -213,7 +213,7 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe ...@@ -213,7 +213,7 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe
noop_backing_storage(), noop_backing_storage(),
)); ));
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip", evict = "never")]
struct JsResultWithEffects { struct JsResultWithEffects {
result: ReadRef<JsResult>, result: ReadRef<JsResult>,
effects: Effects, effects: Effects,
......
...@@ -346,7 +346,7 @@ fn bench_against_node_nft_inner(input: CaseInput) { ...@@ -346,7 +346,7 @@ fn bench_against_node_nft_inner(input: CaseInput) {
}); });
} }
#[turbo_tasks::value(serialization = "none")] #[turbo_tasks::value(serialization = "skip", evict = "never")]
struct NodeFileTraceResult { struct NodeFileTraceResult {
rebased: ResolvedVc<RebasedAsset>, rebased: ResolvedVc<RebasedAsset>,
effects: Effects, effects: Effects,
......
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