Skip to content

Commit

Permalink
Rename Weak to Eventual and remove redundant prepare_aggregation_…
Browse files Browse the repository at this point in the history
…data call
  • Loading branch information
bgw committed Aug 15, 2024
1 parent dd88759 commit 96dab20
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion turbopack/crates/turbo-tasks-memory/benches/scope_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ pub fn scope_stress(c: &mut Criterion) {
rectangle(a, b).strongly_consistent().await?;
Ok::<Vc<()>, _>(Default::default())
});
tt.wait_task_completion(task, ReadConsistency::Weak).await
tt.wait_task_completion(task, ReadConsistency::Eventual)
.await
}
})
.try_join()
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-memory/benches/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn fibonacci(c: &mut Criterion) {
(0..size).map(|i| fib(i, i)).try_join().await?;
Ok::<Vc<()>, _>(Default::default())
});
tt.wait_task_completion(task, ReadConsistency::Weak)
tt.wait_task_completion(task, ReadConsistency::Eventual)
.await
.unwrap();
tt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ where

/// Converted the given node to a fully aggregated node. To make the next call
/// to `aggregation_data` instant.
#[cfg(test)]
pub fn prepare_aggregation_data<C: AggregationContext>(ctx: &C, node_id: &C::NodeRef) {
let mut balance_queue = BalanceQueue::new();
increase_aggregation_number_internal(
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbo-tasks-memory/src/aggregation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod root_query;
mod tests;
mod uppers;

pub use aggregation_data::{aggregation_data, prepare_aggregation_data, AggregationDataGuard};
pub use aggregation_data::{aggregation_data, AggregationDataGuard};
use balance_edge::balance_edge;
use increase::increase_aggregation_number_internal;
pub use new_edge::handle_new_edge;
Expand Down
4 changes: 1 addition & 3 deletions turbopack/crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ use turbo_tasks::{

use crate::{
aggregation::{
aggregation_data, handle_new_edge, prepare_aggregation_data, query_root_info,
AggregationDataGuard, PreparedOperation,
aggregation_data, handle_new_edge, query_root_info, AggregationDataGuard, PreparedOperation,
},
cell::{Cell, ReadContentError},
edges_set::{TaskEdge, TaskEdgesList, TaskEdgesSet},
Expand Down Expand Up @@ -1629,7 +1628,6 @@ impl Task {
) -> Result<Result<T, EventListener>> {
let mut aggregation_context = TaskAggregationContext::new(turbo_tasks, backend);
let mut state = if consistency == ReadConsistency::Strong {
prepare_aggregation_data(&aggregation_context, &self.id);
let mut aggregation = aggregation_data(&aggregation_context, &self.id);
if aggregation.unfinished > 0 {
if aggregation.root_type.is_none() {
Expand Down
9 changes: 5 additions & 4 deletions turbopack/crates/turbo-tasks/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub enum TaskPersistence {
pub enum ReadConsistency {
/// The default behavior for most APIs. Reads are faster, but may return stale values, which
/// may later trigger re-computation.
Weak,
Eventual,
/// Ensures all dependencies are fully resolved before returning the cell or output data, at
/// the cost of slower reads.
///
Expand Down Expand Up @@ -455,7 +455,8 @@ impl<B: Backend + 'static> TurboTasks<B> {
});
// INVALIDATION: A Once task will never invalidate, therefore we don't need to
// track a dependency
let raw_result = read_task_output_untracked(self, task_id, ReadConsistency::Weak).await?;
let raw_result =
read_task_output_untracked(self, task_id, ReadConsistency::Eventual).await?;
ReadVcFuture::<Completion>::from(raw_result.into_read_untracked_with_turbo_tasks(self))
.await?;

Expand Down Expand Up @@ -1544,7 +1545,7 @@ pub async fn run_once<T: Send + 'static>(

// INVALIDATION: A Once task will never invalidate, therefore we don't need to
// track a dependency
let raw_result = read_task_output_untracked(&*tt, task_id, ReadConsistency::Weak).await?;
let raw_result = read_task_output_untracked(&*tt, task_id, ReadConsistency::Eventual).await?;
ReadVcFuture::<Completion>::from(raw_result.into_read_untracked_with_turbo_tasks(&*tt)).await?;

Ok(rx.await?)
Expand All @@ -1569,7 +1570,7 @@ pub async fn run_once_with_reason<T: Send + 'static>(

// INVALIDATION: A Once task will never invalidate, therefore we don't need to
// track a dependency
let raw_result = read_task_output_untracked(&*tt, task_id, ReadConsistency::Weak).await?;
let raw_result = read_task_output_untracked(&*tt, task_id, ReadConsistency::Eventual).await?;
ReadVcFuture::<Completion>::from(raw_result.into_read_untracked_with_turbo_tasks(&*tt)).await?;

Ok(rx.await?)
Expand Down
12 changes: 6 additions & 6 deletions turbopack/crates/turbo-tasks/src/raw_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl RawVc {
loop {
match current {
RawVc::TaskOutput(task) => {
current = read_task_output(&*tt, task, ReadConsistency::Weak)
current = read_task_output(&*tt, task, ReadConsistency::Eventual)
.await
.map_err(|source| ResolveTypeError::TaskError { source })?;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ impl RawVc {

/// See [`crate::Vc::resolve`].
pub(crate) async fn resolve(self) -> Result<RawVc> {
self.resolve_inner(ReadConsistency::Weak).await
self.resolve_inner(ReadConsistency::Eventual).await
}

/// See [`crate::Vc::resolve_strongly_consistent`].
Expand Down Expand Up @@ -262,7 +262,7 @@ impl ReadRawVcFuture {
let tt = turbo_tasks();
ReadRawVcFuture {
turbo_tasks: tt,
consistency: ReadConsistency::Weak,
consistency: ReadConsistency::Eventual,
current: vc,
untracked: false,
listener: None,
Expand All @@ -273,7 +273,7 @@ impl ReadRawVcFuture {
let tt = turbo_tasks.pin();
ReadRawVcFuture {
turbo_tasks: tt,
consistency: ReadConsistency::Weak,
consistency: ReadConsistency::Eventual,
current: vc,
untracked: true,
listener: None,
Expand All @@ -284,7 +284,7 @@ impl ReadRawVcFuture {
let tt = turbo_tasks();
ReadRawVcFuture {
turbo_tasks: tt,
consistency: ReadConsistency::Weak,
consistency: ReadConsistency::Eventual,
current: vc,
untracked: true,
listener: None,
Expand Down Expand Up @@ -344,7 +344,7 @@ impl Future for ReadRawVcFuture {
// We no longer need to read strongly consistent, as any Vc returned
// from the first task will be inside of the scope of the first task. So
// it's already strongly consistent.
this.consistency = ReadConsistency::Weak;
this.consistency = ReadConsistency::Eventual;
this.current = vc;
continue 'outer;
}
Expand Down

0 comments on commit 96dab20

Please sign in to comment.