Skip to content

Commit

Permalink
avoid tracking children count
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 25e40ca commit a3551b7
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -22,7 +22,9 @@ use crate::{
invalidate::{make_task_dirty, TaskDirtyCause},
ExecuteContext, Operation, TaskGuard,
},
storage::{get, get_many, iter_many, remove, update, update_count, update_ucount_and_get},
storage::{
count, get, get_many, iter_many, remove, update, update_count, update_ucount_and_get,

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / rustdoc check / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / rust check / build

unused import: `count`

Check failure on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / rust check / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / build-native / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / stable - x86_64-unknown-linux-gnu - node@16

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test devlow package / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test unit (20) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / types and precompiled / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (dev) (3/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (dev) (4/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (dev) (5/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr integration / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (dev) (1/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (dev) (2/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (prod) (2/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (prod) (3/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test unit (18) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (prod) (1/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (prod) (5/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests for flakes (prod) (4/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / lint / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=true, --scenario=heavy-npm-deps-dev --page=homepage) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / build / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test cargo unit / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=false, --scenario=heavy-npm-deps-dev --page=homepage) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=true, --scenario=heavy-npm-deps-build-turbo-cache-enabled --pa... / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=false, --scenario=heavy-npm-deps-build-turbo-cache-enabled --p... / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (6/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack dev (5/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test firefox and safari / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (1/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (5/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (2/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (4/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test next-swc wasm / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=false, --scenario=heavy-npm-deps-build --page=homepage) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack dev (1/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (12/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Run devlow benchmarks (--turbopack=true, --scenario=heavy-npm-deps-build --page=homepage) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (4/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (5/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (11/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack dev (3/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (8/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (5/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (10/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (6/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (1/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (2/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (1/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (3/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (4/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (3/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test cargo benches / Test

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test cargo benches / Test

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (2/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (9/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack dev (2/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (1/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack dev (4/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (2/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (2/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (7/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (5/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (4/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (3/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (1/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (7/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (6/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (5/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (6/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (6/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (2/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (1/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (3/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (4/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (4/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (2/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (5/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (7/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (4/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (3/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (2/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (6/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (1/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (6/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (3/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test prod (3/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack development integration (3/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests when deployed (3/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests when deployed (2/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests when deployed (1/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production integration (6/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests when deployed (4/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / Test new tests when deployed (5/5) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (7/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test turbopack production (7/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test dev (5/6) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (13/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test integration (4/13) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr prod (5/7) / build

unused import: `count`

Check warning on line 26 in turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

GitHub Actions / test ppr dev (1/6) / build

unused import: `count`
},
TaskDataCategory,
},
data::{
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ use crate::{
invalidate::{make_task_dirty, TaskDirtyCause},
AggregatedDataUpdate, ExecuteContext, Operation, TaskGuard,
},
storage::{update_count, update_ucount_and_get},
storage::update_count,
TaskDataCategory,
},
data::{CachedDataItemKey, CellRef, CollectibleRef, CollectiblesRef},
@@ -82,8 +82,6 @@ impl Operation for CleanupOldEdgesOperation {
for &child_id in children.iter() {
task.remove(&CachedDataItemKey::Child { task: child_id });
}
let remove_children_count = u32::try_from(children.len()).unwrap();
update_ucount_and_get!(task, ChildrenCount, -remove_children_count);
if is_aggregating_node(get_aggregation_number(&task)) {
queue.push(AggregationUpdateJob::InnerOfUpperLostFollowers {
upper_id: task_id,
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use crate::{
},
is_root_node, ExecuteContext, Operation, TaskGuard,
},
storage::{get, update_ucount_and_get},
storage::{count, get},
TaskDataCategory,
},
data::{CachedDataItem, CachedDataItemKey},
@@ -60,8 +60,8 @@ impl ConnectChildOperation {
}) {
let mut queue = AggregationUpdateQueue::new();

// Update the children count
let children_count = update_ucount_and_get!(parent_task, ChildrenCount, 1);
// Get the children count
let children_count = count!(parent_task, Child);

// Compute future parent aggregation number based on the number of children
let current_parent_aggregation = get!(parent_task, AggregationNumber)
7 changes: 7 additions & 0 deletions turbopack/crates/turbo-tasks-backend/src/backend/storage.rs
Original file line number Diff line number Diff line change
@@ -325,6 +325,12 @@ impl DerefMut for StorageWriteGuard<'_> {
}
}

macro_rules! count {
($task:ident, $key:ident) => {{
$task.count($crate::data::CachedDataItemType::$key)
}};
}

macro_rules! get {
($task:ident, $key:ident $input:tt) => {{
#[allow(unused_imports)]
@@ -520,6 +526,7 @@ macro_rules! remove {
};
}

pub(crate) use count;
pub(crate) use get;
pub(crate) use get_many;
pub(crate) use get_mut;

0 comments on commit a3551b7

Please sign in to comment.