Unverified Commit 208f6f99 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[Turbopack] fix invalidation and counting with collectibles (#75195)

### What?

* invalidate tasks when collectibles change
* fix bug where collectibles are double counted
parent 7ea552de
......@@ -203,14 +203,6 @@ impl AggregatedDataUpdate {
for collectible in collectibles {
collectibles_update.push((collectible, 1));
}
collectibles_update.extend(iter_many!(
task,
Collectible {
collectible
} count => {
(collectible, *count)
}
));
}
if let Some(dirty) = get!(task, Dirty) {
dirty_container_count.update_with_dirty_state(dirty);
......
use std::mem::take;
use rustc_hash::FxHashSet;
use serde::{Deserialize, Serialize};
use turbo_tasks::TaskId;
......@@ -7,7 +8,7 @@ use turbo_tasks::TaskId;
use crate::backend::operation::invalidate::TaskDirtyCause;
use crate::{
backend::{
get,
get, get_many,
operation::{
aggregation_update::{
get_aggregation_number, get_uppers, is_aggregating_node, AggregationUpdateJob,
......@@ -120,13 +121,27 @@ impl Operation for CleanupOldEdgesOperation {
_ => true,
});
let mut task = ctx.task(task_id, TaskDataCategory::All);
let mut emptied_collectables = FxHashSet::default();
for (collectible, count) in collectibles.iter_mut() {
update_count!(
if update_count!(
task,
Collectible {
collectible: *collectible
},
*count
) {
emptied_collectables.insert(collectible.collectible_type);
}
}
for ty in emptied_collectables {
let task_ids = get_many!(task, CollectiblesDependent { collectible_type, task } if collectible_type == ty => { task });
queue.push(
AggregationUpdateJob::InvalidateDueToCollectiblesChange {
task_ids,
#[cfg(feature = "trace_task_dirty")]
collectible_type: ty,
},
);
}
queue.extend(AggregationUpdateJob::data_update(
......
use std::cmp::min;
use smallvec::SmallVec;
use turbo_tasks::TaskId;
use crate::{
backend::{
get_many,
operation::{
get_aggregation_number, is_root_node, AggregatedDataUpdate, AggregationUpdateJob,
AggregationUpdateQueue, ExecuteContext, Operation,
......@@ -70,7 +72,25 @@ impl UpdateCollectibleOperation {
}
}
if count != 0 {
update_count!(task, Collectible { collectible }, count);
if update_count!(task, Collectible { collectible }, count) {
let ty = collectible.collectible_type;
let dependent: SmallVec<[TaskId; 4]> = get_many!(
task,
CollectiblesDependent {
collectible_type,
task,
} if collectible_type == ty => {
task
}
);
if !dependent.is_empty() {
queue.push(AggregationUpdateJob::InvalidateDueToCollectiblesChange {
task_ids: dependent,
#[cfg(feature = "trace_task_dirty")]
collectible_type: ty,
})
}
}
queue.extend(AggregationUpdateJob::data_update(
&mut task,
AggregatedDataUpdate::new().collectibles_update(vec![(collectible, count)]),
......
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