Skip to content

Commit e4d18b0

Browse files
authored
Turbopack: use unsigned values for follower and upper edges (#79489)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
1 parent 624a40b commit e4d18b0

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,6 @@ impl AggregationUpdateQueue {
13041304
follower_in_upper = true;
13051305
return None;
13061306
};
1307-
if old < 0 {
1308-
follower_in_upper = true;
1309-
return Some(old);
1310-
}
13111307
if old == 1 {
13121308
keep_upper = true;
13131309
removed_uppers.push(upper_id);
@@ -1382,10 +1378,6 @@ impl AggregationUpdateQueue {
13821378
inner_in_upper = true;
13831379
return None;
13841380
};
1385-
if old < 0 {
1386-
inner_in_upper = true;
1387-
return Some(old);
1388-
}
13891381
if old == 1 {
13901382
removed_follower = true;
13911383
return None;
@@ -1409,7 +1401,7 @@ impl AggregationUpdateQueue {
14091401
task: lost_follower_id,
14101402
});
14111403
}
1412-
// notify uppers about new follower
1404+
// notify uppers about lost follower
14131405
if !upper_ids.is_empty() {
14141406
self.push(AggregationUpdateJob::InnerOfUppersLostFollower {
14151407
upper_ids,
@@ -1471,10 +1463,6 @@ impl AggregationUpdateQueue {
14711463
follower_in_upper = true;
14721464
return None;
14731465
};
1474-
if old < 0 {
1475-
follower_in_upper = true;
1476-
return Some(old);
1477-
}
14781466
if old == 1 {
14791467
remove_upper = true;
14801468
return None;
@@ -1543,10 +1531,6 @@ impl AggregationUpdateQueue {
15431531
inner_in_upper = true;
15441532
return None;
15451533
};
1546-
if old < 0 {
1547-
inner_in_upper = true;
1548-
return Some(old);
1549-
}
15501534
if old == 1 {
15511535
removed_follower = true;
15521536
return None;
@@ -1570,7 +1554,7 @@ impl AggregationUpdateQueue {
15701554
task: lost_follower_id,
15711555
});
15721556
}
1573-
// notify uppers about new follower
1557+
// notify uppers about lost follower
15741558
if !upper_ids.is_empty() {
15751559
self.push(AggregationUpdateJob::InnerOfUppersLostFollower {
15761560
upper_ids,
@@ -2461,7 +2445,7 @@ const MAX_YIELD_DURATION: Duration = Duration::from_millis(1);
24612445
const MAX_RETRIES: u16 = 10000;
24622446

24632447
/// Retry the passed function for a few milliseconds, while yielding to other threads.
2464-
/// Returns an error if the function was not ablue to complete and the timeout was reached.
2448+
/// Returns an error if the function was not able to complete and the timeout was reached.
24652449
///
24662450
/// Each graph modification will only lock one or two tasks at a time, but updates usually also
24672451
/// require follow-up updates to connected tasks. So an update will "slowly" propagate through the
@@ -2472,7 +2456,7 @@ const MAX_RETRIES: u16 = 10000;
24722456
/// update yet). So we will retry (with this method) removals until the thing is there. So this is
24732457
/// basically a busy loop that waits for the "add" update to complete. If the busy loop is not
24742458
/// sucessful, the update is added to the end of the queue again. This is important as the "add"
2475-
/// update might even be in the curreent thread and in the same queue. If that's the case yielding
2459+
/// update might even be in the current thread and in the same queue. If that's the case yielding
24762460
/// won't help and the update need to be requeued.
24772461
fn retry_loop(mut f: impl FnMut() -> ControlFlow<()>) -> Result<(), RetryTimeout> {
24782462
let mut time: Option<Instant> = None;

turbopack/crates/turbo-tasks-backend/src/backend/storage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct InnerStorageSnapshot {
137137
aggregation_number: OptionStorage<AggregationNumber>,
138138
output_dependent: AutoMapStorage<TaskId, ()>,
139139
output: OptionStorage<OutputValue>,
140-
upper: AutoMapStorage<TaskId, i32>,
140+
upper: AutoMapStorage<TaskId, u32>,
141141
dynamic: DynamicStorage,
142142
pub meta_modified: bool,
143143
pub data_modified: bool,
@@ -205,7 +205,7 @@ pub struct InnerStorage {
205205
aggregation_number: OptionStorage<AggregationNumber>,
206206
output_dependent: AutoMapStorage<TaskId, ()>,
207207
output: OptionStorage<OutputValue>,
208-
upper: AutoMapStorage<TaskId, i32>,
208+
upper: AutoMapStorage<TaskId, u32>,
209209
dynamic: DynamicStorage,
210210
state: InnerStorageState,
211211
}

turbopack/crates/turbo-tasks-backend/src/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ pub enum CachedDataItem {
421421
},
422422
Follower {
423423
task: TaskId,
424-
value: i32,
424+
value: u32,
425425
},
426426
Upper {
427427
task: TaskId,
428-
value: i32,
428+
value: u32,
429429
},
430430

431431
// Aggregated Data

0 commit comments

Comments
 (0)