Skip to content

Commit

Permalink
fix dirty task counting
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 2, 2024
1 parent 2422e9f commit 61957f7
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions crates/turbo-tasks-memory/src/task/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ impl<'a> AggregationContext for TaskAggregationContext<'a> {
change.unfinished_tasks_update.push((task, -count));
}
for (&task, &count) in data.dirty_tasks.iter() {
change.dirty_tasks_update.push((task, -count));
if count > 0 {
change.dirty_tasks_update.push((task, -1));
}
}
for (trait_type_id, collectibles_info) in data.collectibles.iter() {
for (collectible, count) in collectibles_info.collectibles.iter() {
Expand Down Expand Up @@ -508,7 +510,13 @@ impl<'l> AggregationNodeGuard for TaskGuard<'l> {
Some(change)
}
}
TaskMetaStateWriteGuard::Partial(_) | TaskMetaStateWriteGuard::Unloaded(_) => None,
TaskMetaStateWriteGuard::Partial(_) | TaskMetaStateWriteGuard::Unloaded(_) => {
Some(TaskChange {
unfinished: 1,
dirty_tasks_update: vec![(self.id, 1)],
collectibles: vec![],
})
}
TaskMetaStateWriteGuard::TemporaryFiller => unreachable!(),
}
}
Expand Down Expand Up @@ -554,7 +562,13 @@ impl<'l> AggregationNodeGuard for TaskGuard<'l> {
Some(change)
}
}
TaskMetaStateWriteGuard::Partial(_) | TaskMetaStateWriteGuard::Unloaded(_) => None,
TaskMetaStateWriteGuard::Partial(_) | TaskMetaStateWriteGuard::Unloaded(_) => {
Some(TaskChange {
unfinished: -1,
dirty_tasks_update: vec![(self.id, -1)],
collectibles: vec![],
})
}
TaskMetaStateWriteGuard::TemporaryFiller => unreachable!(),
}
}
Expand Down Expand Up @@ -632,6 +646,9 @@ fn update_count_entry<K: Eq + Hash, H: BuildHasher + Default, const I: usize>(
Entry::Vacant(e) => {
if update == 0 {
(0, UpdateCountEntryChange::Updated)
} else if update < 0 {
e.insert(update);
(update, UpdateCountEntryChange::Updated)
} else {
e.insert(update);
(update, UpdateCountEntryChange::Inserted)
Expand Down

0 comments on commit 61957f7

Please sign in to comment.