Unverified Commit 1ee20b5d authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Bind concrete task guards to execution contexts

Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent 8d8c0cd5
...@@ -250,7 +250,7 @@ impl TurboTasksBackend { ...@@ -250,7 +250,7 @@ impl TurboTasksBackend {
GcJob::Collect(task_id) => task_id, GcJob::Collect(task_id) => task_id,
}; };
let collector = |child_id| spawner.spawn(GcJob::Collect(child_id)); let collector = |child_id| spawner.spawn(GcJob::Collect(child_id));
let mut ctx = ExecuteContext::new_for_gc(self, turbo_tasks, phase, &collector); let ctx = ExecuteContext::new_for_gc(self, turbo_tasks, phase, &collector);
// `All` restores Data so `capture_all_edges` below can read the // `All` restores Data so `capture_all_edges` below can read the
// Data-category dependency sets. The recheck itself only needs Meta. // Data-category dependency sets. The recheck itself only needs Meta.
let mut task = ctx.task(task_id, TaskDataCategory::All); let mut task = ctx.task(task_id, TaskDataCategory::All);
...@@ -287,7 +287,7 @@ impl TurboTasksBackend { ...@@ -287,7 +287,7 @@ impl TurboTasksBackend {
// Delete outgoing edges but don't update the aggregation graph yet. // Delete outgoing edges but don't update the aggregation graph yet.
// To avoid accidentally rebalancing on deleted tasks due to racing deletions, // To avoid accidentally rebalancing on deleted tasks due to racing deletions,
// we defer all rebalancing to the end // we defer all rebalancing to the end
let deferred = cleanup_old_edges_deletions_only(task_id, old_edges, &mut ctx); let deferred = cleanup_old_edges_deletions_only(task_id, old_edges, &ctx);
result.deferred_balance_edges.extend(deferred.balance_edges); result.deferred_balance_edges.extend(deferred.balance_edges);
ControlFlow::Continue(()) ControlFlow::Continue(())
}, },
...@@ -306,10 +306,10 @@ impl TurboTasksBackend { ...@@ -306,10 +306,10 @@ impl TurboTasksBackend {
let deferred = std::mem::take(&mut result.deferred_balance_edges); let deferred = std::mem::take(&mut result.deferred_balance_edges);
if !deferred.is_empty() { if !deferred.is_empty() {
let noop_collector = |_task_id| {}; let noop_collector = |_task_id| {};
let mut ctx = ExecuteContext::new_for_gc(self, turbo_tasks, phase, &noop_collector); let ctx = ExecuteContext::new_for_gc(self, turbo_tasks, phase, &noop_collector);
let mut queue = AggregationUpdateQueue::new(); let mut queue = AggregationUpdateQueue::new();
queue.extend_balance_edges(deferred, &mut ctx); queue.extend_balance_edges(deferred, &ctx);
while !queue.process(&mut ctx) {} while !queue.process(&ctx) {}
} }
// Collect all active roots // Collect all active roots
...@@ -398,7 +398,7 @@ impl TurboTasksBackend { ...@@ -398,7 +398,7 @@ impl TurboTasksBackend {
// We expect this call to come from outside a turbo-task context, at least sometimes // We expect this call to come from outside a turbo-task context, at least sometimes
// So be defensive about conostructing a context. If we get none then we are shutting down // So be defensive about conostructing a context. If we get none then we are shutting down
// and it is too late for ref-counting. // and it is too late for ref-counting.
let Some(mut ctx) = self.try_execute_context(turbo_tasks) else { let Some(ctx) = self.try_execute_context(turbo_tasks) else {
return; return;
}; };
// Technically we only need to manipulate transient data so meta is overkill. But the task // Technically we only need to manipulate transient data so meta is overkill. But the task
......
...@@ -112,7 +112,7 @@ pub fn get_uppers(task: &TaskGuard<'_>) -> TaskIdVec { ...@@ -112,7 +112,7 @@ pub fn get_uppers(task: &TaskGuard<'_>) -> TaskIdVec {
/// Acquires a `Meta`-category guard for `task_id` and sets `optimization_pending`. Used in /// Acquires a `Meta`-category guard for `task_id` and sets `optimization_pending`. Used in
/// the optimize-queue drop paths when the caller doesn't already hold a guard for the task. /// the optimize-queue drop paths when the caller doesn't already hold a guard for the task.
fn lock_and_mark_optimization_pending(ctx: &mut ExecuteContext<'_>, task_id: TaskId) { fn lock_and_mark_optimization_pending(ctx: &ExecuteContext<'_>, task_id: TaskId) {
let mut task = ctx.task(task_id, TaskDataCategory::Meta); let mut task = ctx.task(task_id, TaskDataCategory::Meta);
task.set_optimization_pending(true); task.set_optimization_pending(true);
} }
...@@ -1028,7 +1028,7 @@ impl AggregationUpdateQueue { ...@@ -1028,7 +1028,7 @@ impl AggregationUpdateQueue {
/// Only called from `optimize_task`'s self re-enqueue, which has just cleared the flag at /// Only called from `optimize_task`'s self re-enqueue, which has just cleared the flag at
/// entry, so the enqueued job carries `optimization_pending_flag_already_set = false`. The /// entry, so the enqueued job carries `optimization_pending_flag_already_set = false`. The
/// `Meta`-category guard is acquired only when the push has to be dropped. /// `Meta`-category guard is acquired only when the push has to be dropped.
fn push_optimize_task_by_id(&mut self, ctx: &mut ExecuteContext<'_>, task_id: TaskId) { fn push_optimize_task_by_id(&mut self, ctx: &ExecuteContext<'_>, task_id: TaskId) {
if !self.try_enqueue_optimize_job(task_id, false) { if !self.try_enqueue_optimize_job(task_id, false) {
lock_and_mark_optimization_pending(ctx, task_id); lock_and_mark_optimization_pending(ctx, task_id);
} }
...@@ -1055,7 +1055,7 @@ impl AggregationUpdateQueue { ...@@ -1055,7 +1055,7 @@ impl AggregationUpdateQueue {
} }
/// Runs the job and all dependent jobs until it's done. /// Runs the job and all dependent jobs until it's done.
pub fn run(job: AggregationUpdateJob, ctx: &mut ExecuteContext<'_>) { pub fn run(job: AggregationUpdateJob, ctx: &ExecuteContext<'_>) {
let mut queue = Self::new(); let mut queue = Self::new();
queue.push(job); queue.push(job);
queue.execute(ctx); queue.execute(ctx);
...@@ -1114,7 +1114,7 @@ impl AggregationUpdateQueue { ...@@ -1114,7 +1114,7 @@ impl AggregationUpdateQueue {
pub fn extend_balance_edges( pub fn extend_balance_edges(
&mut self, &mut self,
edges: impl IntoIterator<Item = (TaskId, TaskId)>, edges: impl IntoIterator<Item = (TaskId, TaskId)>,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
for (upper_id, task_id) in edges { for (upper_id, task_id) in edges {
// structure as 2 if statements to ensure the first guard is dropped before the second // structure as 2 if statements to ensure the first guard is dropped before the second
...@@ -1130,7 +1130,7 @@ impl AggregationUpdateQueue { ...@@ -1130,7 +1130,7 @@ impl AggregationUpdateQueue {
} }
/// Executes a single step of the queue. Returns true, when the queue is empty. /// Executes a single step of the queue. Returns true, when the queue is empty.
pub fn process(&mut self, ctx: &mut ExecuteContext<'_>) -> bool { pub fn process(&mut self, ctx: &ExecuteContext<'_>) -> bool {
if let Some(job) = self.jobs.pop_front() { if let Some(job) = self.jobs.pop_front() {
let job: AggregationUpdateJobGuard = job.entered(); let job: AggregationUpdateJobGuard = job.entered();
match job.job { match job.job {
...@@ -1612,7 +1612,7 @@ impl AggregationUpdateQueue { ...@@ -1612,7 +1612,7 @@ impl AggregationUpdateQueue {
/// triggers more changes to the structure. /// triggers more changes to the structure.
/// ///
/// It locks both tasks simultaneously to atomically change the edges. /// It locks both tasks simultaneously to atomically change the edges.
fn balance_edge(&mut self, ctx: &mut ExecuteContext<'_>, upper_id: TaskId, task_id: TaskId) { fn balance_edge(&mut self, ctx: &ExecuteContext<'_>, upper_id: TaskId, task_id: TaskId) {
#[cfg(feature = "trace_aggregation_update")] #[cfg(feature = "trace_aggregation_update")]
let _span = trace_span!("process balance edge").entered(); let _span = trace_span!("process balance edge").entered();
...@@ -1784,7 +1784,7 @@ impl AggregationUpdateQueue { ...@@ -1784,7 +1784,7 @@ impl AggregationUpdateQueue {
fn find_and_schedule_dirty( fn find_and_schedule_dirty(
&mut self, &mut self,
jobs: SmallVec<[FindAndScheduleJob; 4]>, jobs: SmallVec<[FindAndScheduleJob; 4]>,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
#[cfg(feature = "trace_find_and_schedule")] #[cfg(feature = "trace_find_and_schedule")]
let mut spans: FxHashMap<TaskId, Option<Span>> = jobs let mut spans: FxHashMap<TaskId, Option<Span>> = jobs
...@@ -1814,7 +1814,7 @@ impl AggregationUpdateQueue { ...@@ -1814,7 +1814,7 @@ impl AggregationUpdateQueue {
&mut self, &mut self,
task_id: TaskId, task_id: TaskId,
mut task: TaskGuard<'_>, mut task: TaskGuard<'_>,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
// Task need to be scheduled if it's dirty or doesn't have output // Task need to be scheduled if it's dirty or doesn't have output
let dirty = task.is_dirty(); let dirty = task.is_dirty();
...@@ -1855,7 +1855,7 @@ impl AggregationUpdateQueue { ...@@ -1855,7 +1855,7 @@ impl AggregationUpdateQueue {
fn aggregated_data_update( fn aggregated_data_update(
&mut self, &mut self,
upper_ids: TaskIdVec, upper_ids: TaskIdVec,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
update: AggregatedDataUpdate, update: AggregatedDataUpdate,
) { ) {
// For performance reasons this should stay `Meta` and not `All` // For performance reasons this should stay `Meta` and not `All`
...@@ -1883,7 +1883,7 @@ impl AggregationUpdateQueue { ...@@ -1883,7 +1883,7 @@ impl AggregationUpdateQueue {
fn inner_of_upper_lost_follower( fn inner_of_upper_lost_follower(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
lost_follower_id: TaskId, lost_follower_id: TaskId,
upper_id: TaskId, upper_id: TaskId,
mut retry: u16, mut retry: u16,
...@@ -2061,7 +2061,7 @@ impl AggregationUpdateQueue { ...@@ -2061,7 +2061,7 @@ impl AggregationUpdateQueue {
fn inner_of_uppers_lost_follower( fn inner_of_uppers_lost_follower(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
lost_follower_id: TaskId, lost_follower_id: TaskId,
mut upper_ids: TaskIdVec, mut upper_ids: TaskIdVec,
mut retry: u16, mut retry: u16,
...@@ -2254,7 +2254,7 @@ impl AggregationUpdateQueue { ...@@ -2254,7 +2254,7 @@ impl AggregationUpdateQueue {
fn inner_of_upper_lost_followers( fn inner_of_upper_lost_followers(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
mut lost_follower_ids: TaskIdVec, mut lost_follower_ids: TaskIdVec,
upper_id: TaskId, upper_id: TaskId,
mut retry: u16, mut retry: u16,
...@@ -2450,7 +2450,7 @@ impl AggregationUpdateQueue { ...@@ -2450,7 +2450,7 @@ impl AggregationUpdateQueue {
/// See detailed comments in that function, follow the STEP numbers. /// See detailed comments in that function, follow the STEP numbers.
fn inner_of_uppers_has_new_follower<T: TaskIdWithOptionalCount + Clone, const N: usize>( fn inner_of_uppers_has_new_follower<T: TaskIdWithOptionalCount + Clone, const N: usize>(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
new_follower_id: TaskId, new_follower_id: TaskId,
mut upper_ids: SmallVec<[T; N]>, mut upper_ids: SmallVec<[T; N]>,
) { ) {
...@@ -2696,7 +2696,7 @@ impl AggregationUpdateQueue { ...@@ -2696,7 +2696,7 @@ impl AggregationUpdateQueue {
/// See detailed comments in that function, follow the STEP numbers. /// See detailed comments in that function, follow the STEP numbers.
fn inner_of_upper_has_new_followers<T: TaskIdWithOptionalCount, const N: usize>( fn inner_of_upper_has_new_followers<T: TaskIdWithOptionalCount, const N: usize>(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
new_follower_ids: SmallVec<[T; N]>, new_follower_ids: SmallVec<[T; N]>,
upper_id: TaskId, upper_id: TaskId,
) { ) {
...@@ -2957,7 +2957,7 @@ impl AggregationUpdateQueue { ...@@ -2957,7 +2957,7 @@ impl AggregationUpdateQueue {
fn inner_of_upper_has_new_follower( fn inner_of_upper_has_new_follower(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
new_follower_id: TaskId, new_follower_id: TaskId,
upper_id: TaskId, upper_id: TaskId,
count: u32, count: u32,
...@@ -3139,7 +3139,7 @@ impl AggregationUpdateQueue { ...@@ -3139,7 +3139,7 @@ impl AggregationUpdateQueue {
/// Decreases the active count of a task. /// Decreases the active count of a task.
/// ///
/// Only used when activeness is tracked. /// Only used when activeness is tracked.
fn decrease_active_count(&mut self, ctx: &mut ExecuteContext<'_>, task_id: TaskId) { fn decrease_active_count(&mut self, ctx: &ExecuteContext<'_>, task_id: TaskId) {
#[cfg(feature = "trace_aggregation_update")] #[cfg(feature = "trace_aggregation_update")]
let _span = trace_span!("decrease active count").entered(); let _span = trace_span!("decrease active count").entered();
...@@ -3186,7 +3186,7 @@ impl AggregationUpdateQueue { ...@@ -3186,7 +3186,7 @@ impl AggregationUpdateQueue {
/// Only used when activeness is tracked. /// Only used when activeness is tracked.
fn increase_active_count( fn increase_active_count(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
task_id: TaskId, task_id: TaskId,
release_construction_ref: bool, release_construction_ref: bool,
) { ) {
...@@ -3238,7 +3238,7 @@ impl AggregationUpdateQueue { ...@@ -3238,7 +3238,7 @@ impl AggregationUpdateQueue {
fn update_aggregation_number( fn update_aggregation_number(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
task_id: TaskId, task_id: TaskId,
base_effective_distance: Option<std::num::NonZero<u32>>, base_effective_distance: Option<std::num::NonZero<u32>>,
base_aggregation_number: u32, base_aggregation_number: u32,
...@@ -3342,7 +3342,7 @@ impl AggregationUpdateQueue { ...@@ -3342,7 +3342,7 @@ impl AggregationUpdateQueue {
/// does so); when `false`, the flag is known to be unset already and we can skip the write. /// does so); when `false`, the flag is known to be unset already and we can skip the write.
fn optimize_task( fn optimize_task(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
task_id: TaskId, task_id: TaskId,
optimization_pending_flag_already_set: bool, optimization_pending_flag_already_set: bool,
) { ) {
...@@ -3485,17 +3485,14 @@ impl AggregationUpdateQueue { ...@@ -3485,17 +3485,14 @@ impl AggregationUpdateQueue {
} }
#[cfg(feature = "trace_aggregation_update_stats")] #[cfg(feature = "trace_aggregation_update_stats")]
pub fn execute_with_stats( pub fn execute_with_stats(&mut self, ctx: &ExecuteContext<'_>) -> AggregationUpdateQueueStats {
&mut self,
ctx: &mut ExecuteContext<'_>,
) -> AggregationUpdateQueueStats {
while !self.process(ctx) {} while !self.process(ctx) {}
take(&mut self.stats) take(&mut self.stats)
} }
} }
impl AggregationUpdateQueue { impl AggregationUpdateQueue {
pub fn execute(&mut self, ctx: &mut ExecuteContext<'_>) { pub fn execute(&mut self, ctx: &ExecuteContext<'_>) {
while !self.process(ctx) {} while !self.process(ctx) {}
} }
} }
......
...@@ -88,7 +88,7 @@ pub fn cleanup_old_edges( ...@@ -88,7 +88,7 @@ pub fn cleanup_old_edges(
task_id: TaskId, task_id: TaskId,
outdated: Vec<OutdatedEdge>, outdated: Vec<OutdatedEdge>,
queue: AggregationUpdateQueue, queue: AggregationUpdateQueue,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) -> Stats { ) -> Stats {
cleanup_old_edges_inner(task_id, outdated, queue, ctx, false).0 cleanup_old_edges_inner(task_id, outdated, queue, ctx, false).0
} }
...@@ -101,7 +101,7 @@ pub fn cleanup_old_edges( ...@@ -101,7 +101,7 @@ pub fn cleanup_old_edges(
pub fn cleanup_old_edges_deletions_only( pub fn cleanup_old_edges_deletions_only(
task_id: TaskId, task_id: TaskId,
outdated: Vec<OutdatedEdge>, outdated: Vec<OutdatedEdge>,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) -> DeferredCleanup { ) -> DeferredCleanup {
let (_, stopped) = cleanup_old_edges_inner( let (_, stopped) = cleanup_old_edges_inner(
task_id, task_id,
...@@ -118,7 +118,7 @@ fn cleanup_old_edges_inner( ...@@ -118,7 +118,7 @@ fn cleanup_old_edges_inner(
task_id: TaskId, task_id: TaskId,
mut outdated: Vec<OutdatedEdge>, mut outdated: Vec<OutdatedEdge>,
mut queue: AggregationUpdateQueue, mut queue: AggregationUpdateQueue,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
stop_when_only_rebalance_remains: bool, stop_when_only_rebalance_remains: bool,
) -> (Stats, Option<DeferredCleanup>) { ) -> (Stats, Option<DeferredCleanup>) {
while let Some(edge) = outdated.pop() { while let Some(edge) = outdated.pop() {
......
...@@ -20,12 +20,12 @@ use crate::{ ...@@ -20,12 +20,12 @@ use crate::{
/// connect handshake. /// connect handshake.
/// ///
/// GC destructively mutates tasks so mark resurrected tasks as dirty to get them re-scheduled. /// GC destructively mutates tasks so mark resurrected tasks as dirty to get them re-scheduled.
pub(super) fn resurrect_deleted<'e>( pub(super) fn resurrect_deleted<'ctx>(
guard: TaskGuard<'e>, guard: TaskGuard<'ctx>,
task_id: TaskId, task_id: TaskId,
queue: &mut AggregationUpdateQueue, queue: &mut AggregationUpdateQueue,
ctx: &mut ExecuteContext<'e>, ctx: &'ctx ExecuteContext<'_>,
) -> TaskGuard<'e> { ) -> TaskGuard<'ctx> {
if !guard.deleted() { if !guard.deleted() {
return guard; return guard;
} }
...@@ -64,7 +64,7 @@ pub(super) fn resurrect_deleted<'e>( ...@@ -64,7 +64,7 @@ pub(super) fn resurrect_deleted<'e>(
task task
} }
fn release_construction_ref(task_id: TaskId, ctx: &mut ExecuteContext<'_>) { fn release_construction_ref(task_id: TaskId, ctx: &ExecuteContext<'_>) {
let mut task = ctx.task(task_id, TaskDataCategory::Meta); let mut task = ctx.task(task_id, TaskDataCategory::Meta);
task.update_and_get_transient_ref_count(-1); task.update_and_get_transient_ref_count(-1);
} }
...@@ -73,7 +73,7 @@ pub fn connect_child( ...@@ -73,7 +73,7 @@ pub fn connect_child(
parent_task_id: Option<TaskId>, parent_task_id: Option<TaskId>,
child_task_id: TaskId, child_task_id: TaskId,
release_construction_ref: bool, release_construction_ref: bool,
mut ctx: ExecuteContext<'_>, ctx: ExecuteContext<'_>,
) { ) {
if parent_task_id.is_none() { if parent_task_id.is_none() {
// All parentless tasks receive a transient ref when connected: their lifetime cannot be // All parentless tasks receive a transient ref when connected: their lifetime cannot be
...@@ -95,7 +95,7 @@ pub fn connect_child( ...@@ -95,7 +95,7 @@ pub fn connect_child(
if new_children.contains(&child_task_id) { if new_children.contains(&child_task_id) {
drop(parent_task); drop(parent_task);
if release_construction_ref { if release_construction_ref {
self::release_construction_ref(child_task_id, &mut ctx); self::release_construction_ref(child_task_id, &ctx);
} }
return; return;
} }
...@@ -111,7 +111,7 @@ pub fn connect_child( ...@@ -111,7 +111,7 @@ pub fn connect_child(
new_children.insert(child_task_id); new_children.insert(child_task_id);
drop(parent_task); drop(parent_task);
if release_construction_ref { if release_construction_ref {
self::release_construction_ref(child_task_id, &mut ctx); self::release_construction_ref(child_task_id, &ctx);
} }
return; return;
} }
...@@ -142,7 +142,7 @@ pub fn connect_child( ...@@ -142,7 +142,7 @@ pub fn connect_child(
// Revive the child if GC soft-deleted it. This can happen in a rare race between a // Revive the child if GC soft-deleted it. This can happen in a rare race between a
// cache hit on a task and snapshotting actually performing the delete. // cache hit on a task and snapshotting actually performing the delete.
let mut child_task = resurrect_deleted(child_task, child_task_id, &mut queue, &mut ctx); let mut child_task = resurrect_deleted(child_task, child_task_id, &mut queue, &ctx);
let has_output = child_task.has_output(); let has_output = child_task.has_output();
// An already constructed top-level task was made a root when it was first connected. // An already constructed top-level task was made a root when it was first connected.
...@@ -174,7 +174,7 @@ pub fn connect_child( ...@@ -174,7 +174,7 @@ pub fn connect_child(
} }
if !queue.is_empty() { if !queue.is_empty() {
queue.execute(&mut ctx); queue.execute(&ctx);
} }
if let Some(parent_task_id) = parent_task_id { if let Some(parent_task_id) = parent_task_id {
...@@ -195,7 +195,7 @@ pub fn connect_child( ...@@ -195,7 +195,7 @@ pub fn connect_child(
AggregationUpdateJob::DecreaseActiveCount { AggregationUpdateJob::DecreaseActiveCount {
task: child_task_id, task: child_task_id,
}, },
&mut ctx, &ctx,
); );
} }
} }
......
...@@ -18,7 +18,7 @@ use crate::backend::{ ...@@ -18,7 +18,7 @@ use crate::backend::{
}; };
pub fn connect_children( pub fn connect_children(
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
parent_task_id: TaskId, parent_task_id: TaskId,
mut parent_task: TaskGuard<'_>, mut parent_task: TaskGuard<'_>,
new_children: FxHashSet<TaskId>, new_children: FxHashSet<TaskId>,
...@@ -46,7 +46,7 @@ pub fn connect_children( ...@@ -46,7 +46,7 @@ pub fn connect_children(
drop(parent_task); drop(parent_task);
fn process_new_children( fn process_new_children(
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
new_follower_ids: SmallVec<[TaskId; 4]>, new_follower_ids: SmallVec<[TaskId; 4]>,
upper_ids: Option<SmallVec<[TaskId; 4]>>, upper_ids: Option<SmallVec<[TaskId; 4]>>,
parent_task_id: TaskId, parent_task_id: TaskId,
...@@ -183,10 +183,10 @@ pub fn connect_children( ...@@ -183,10 +183,10 @@ pub fn connect_children(
let upper_ids = &upper_ids; let upper_ids = &upper_ids;
let child_ctx = ctx.child_context(); let child_ctx = ctx.child_context();
scope.spawn(move || { scope.spawn(move || {
let mut ctx = child_ctx.create(); let ctx = child_ctx.create();
let new_follower_ids = chunk.collect::<SmallVec<[_; 4]>>(); let new_follower_ids = chunk.collect::<SmallVec<[_; 4]>>();
process_new_children( process_new_children(
&mut ctx, &ctx,
new_follower_ids, new_follower_ids,
upper_ids.clone(), upper_ids.clone(),
parent_task_id, parent_task_id,
......
...@@ -20,7 +20,7 @@ use crate::{ ...@@ -20,7 +20,7 @@ use crate::{
pub fn invalidate( pub fn invalidate(
task_ids: SmallVec<[TaskId; 4]>, task_ids: SmallVec<[TaskId; 4]>,
#[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause, #[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause,
mut ctx: ExecuteContext<'_>, ctx: ExecuteContext<'_>,
) { ) {
let mut queue = AggregationUpdateQueue::new(); let mut queue = AggregationUpdateQueue::new();
for task_id in task_ids { for task_id in task_ids {
...@@ -29,10 +29,10 @@ pub fn invalidate( ...@@ -29,10 +29,10 @@ pub fn invalidate(
#[cfg(feature = "task_dirty_cause")] #[cfg(feature = "task_dirty_cause")]
cause.clone(), cause.clone(),
&mut queue, &mut queue,
&mut ctx, &ctx,
); );
} }
queue.execute(&mut ctx); queue.execute(&ctx);
} }
/// Marks a task dirty, doing nothing if it no longer exists. /// Marks a task dirty, doing nothing if it no longer exists.
...@@ -42,7 +42,7 @@ pub fn try_make_task_dirty( ...@@ -42,7 +42,7 @@ pub fn try_make_task_dirty(
task_id: TaskId, task_id: TaskId,
#[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause, #[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause,
queue: &mut AggregationUpdateQueue, queue: &mut AggregationUpdateQueue,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
let Some(mut task) = ctx.try_task(task_id, TaskDataCategory::All) else { let Some(mut task) = ctx.try_task(task_id, TaskDataCategory::All) else {
return; return;
...@@ -63,7 +63,7 @@ pub fn make_task_dirty_internal( ...@@ -63,7 +63,7 @@ pub fn make_task_dirty_internal(
make_stale: bool, make_stale: bool,
#[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause, #[cfg(feature = "task_dirty_cause")] cause: TaskDirtyCause,
queue: &mut AggregationUpdateQueue, queue: &mut AggregationUpdateQueue,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
// There must be no way to invalidate immutable tasks. If there would be a way the task is not // There must be no way to invalidate immutable tasks. If there would be a way the task is not
// immutable. // immutable.
......
...@@ -85,7 +85,7 @@ impl LeafDistanceUpdateQueue { ...@@ -85,7 +85,7 @@ impl LeafDistanceUpdateQueue {
} }
/// Executes a single step of the queue. Returns true, when the queue is empty. /// Executes a single step of the queue. Returns true, when the queue is empty.
pub fn process(&mut self, ctx: &mut ExecuteContext<'_>) -> bool { pub fn process(&mut self, ctx: &ExecuteContext<'_>) -> bool {
let mut remaining = MAX_COUNT_BEFORE_YIELD; let mut remaining = MAX_COUNT_BEFORE_YIELD;
while remaining > 0 { while remaining > 0 {
if let Some((Reverse(queue_dependencies_distance), task_id)) = self.queue.pop() { if let Some((Reverse(queue_dependencies_distance), task_id)) = self.queue.pop() {
...@@ -121,7 +121,7 @@ impl LeafDistanceUpdateQueue { ...@@ -121,7 +121,7 @@ impl LeafDistanceUpdateQueue {
fn update_leaf_distance( fn update_leaf_distance(
&mut self, &mut self,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
task_id: TaskId, task_id: TaskId,
dependencies_distance: u32, dependencies_distance: u32,
dependencies_max_distance_in_buffer: u32, dependencies_max_distance_in_buffer: u32,
...@@ -169,7 +169,7 @@ impl LeafDistanceUpdateQueue { ...@@ -169,7 +169,7 @@ impl LeafDistanceUpdateQueue {
task.set_leaf_distance(leaf_distance); task.set_leaf_distance(leaf_distance);
} }
pub fn execute(&mut self, ctx: &mut ExecuteContext<'_>) { pub fn execute(&mut self, ctx: &ExecuteContext<'_>) {
if self.is_empty() { if self.is_empty() {
return; return;
} }
......
...@@ -29,7 +29,7 @@ pub fn update_cell( ...@@ -29,7 +29,7 @@ pub fn update_cell(
content_hash: Option<CellHash>, content_hash: Option<CellHash>,
#[cfg(feature = "verify_determinism")] verification_mode: VerificationMode, #[cfg(feature = "verify_determinism")] verification_mode: VerificationMode,
#[cfg(not(feature = "verify_determinism"))] _verification_mode: VerificationMode, #[cfg(not(feature = "verify_determinism"))] _verification_mode: VerificationMode,
mut ctx: ExecuteContext<'_>, ctx: ExecuteContext<'_>,
) { ) {
let value_type = registry::get_value_type(cell.type_id()); let value_type = registry::get_value_type(cell.type_id());
// `content_hash` is only ever supplied for `HashOnly` cells — only the // `content_hash` is only ever supplied for `HashOnly` cells — only the
...@@ -186,7 +186,7 @@ pub fn update_cell( ...@@ -186,7 +186,7 @@ pub fn update_cell(
#[cfg(feature = "task_dirty_cause")] #[cfg(feature = "task_dirty_cause")]
has_updated_key_hashes, has_updated_key_hashes,
content.map(|r| r.into_typed(cell.type_id())), content.map(|r| r.into_typed(cell.type_id())),
&mut ctx, &ctx,
); );
return; return;
} }
...@@ -235,7 +235,7 @@ fn invalidate_cell_dependents( ...@@ -235,7 +235,7 @@ fn invalidate_cell_dependents(
mut dependent_tasks: FxIndexMap<TaskId, SmallVec<[Option<u64>; 2]>>, mut dependent_tasks: FxIndexMap<TaskId, SmallVec<[Option<u64>; 2]>>,
#[cfg(feature = "task_dirty_cause")] has_updated_key_hashes: bool, #[cfg(feature = "task_dirty_cause")] has_updated_key_hashes: bool,
content: Option<TypedSharedReference>, content: Option<TypedSharedReference>,
ctx: &mut ExecuteContext<'_>, ctx: &ExecuteContext<'_>,
) { ) {
let mut queue = AggregationUpdateQueue::new(); let mut queue = AggregationUpdateQueue::new();
while let Some((dependent_task_id, keys)) = dependent_tasks.pop() { while let Some((dependent_task_id, keys)) = dependent_tasks.pop() {
......
...@@ -21,7 +21,7 @@ impl UpdateCollectibleOperation { ...@@ -21,7 +21,7 @@ impl UpdateCollectibleOperation {
task_id: TaskId, task_id: TaskId,
collectible: CollectibleRef, collectible: CollectibleRef,
mut count: i32, mut count: i32,
mut ctx: ExecuteContext<'_>, ctx: ExecuteContext<'_>,
) { ) {
let mut task = ctx.task(task_id, TaskDataCategory::All); let mut task = ctx.task(task_id, TaskDataCategory::All);
if count < 0 if count < 0
...@@ -75,6 +75,6 @@ impl UpdateCollectibleOperation { ...@@ -75,6 +75,6 @@ impl UpdateCollectibleOperation {
drop(task); drop(task);
queue.execute(&mut ctx); queue.execute(&ctx);
} }
} }
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