Skip to content

Commit cb3e78e

Browse files
committed
use constants
1 parent ec4fd3d commit cb3e78e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ use crate::{
7272
},
7373
};
7474

75+
/// Threshold for parallelizing making dependent tasks dirty.
76+
/// If the number of dependent tasks exceeds this threshold,
77+
/// the operation will be parallelized.
78+
const DEPENDENT_TASKS_DIRTY_PARALLIZATION_THRESHOLD: usize = 128;
79+
80+
/// Threshold for parallelizing prefetching tasks.
81+
/// If the number of tasks to prefetch exceeds this threshold,
82+
/// the operation will be parallelized.
83+
const PREFETCH_TASKS_PARALLIZATION_THRESHOLD: usize = 128;
84+
7585
const SNAPSHOT_REQUESTED_BIT: usize = 1 << (usize::BITS - 1);
7686

7787
/// Configurable idle timeout for snapshot persistence.
@@ -2212,7 +2222,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
22122222
span.record("result", "marked dirty");
22132223
}
22142224

2215-
if output_dependent_tasks.len() > 128 {
2225+
if output_dependent_tasks.len() > DEPENDENT_TASKS_DIRTY_PARALLIZATION_THRESHOLD {
22162226
let chunk_size = good_chunk_size(output_dependent_tasks.len());
22172227
let chunks = into_chunks(output_dependent_tasks.to_vec(), chunk_size);
22182228
let _ = scope_and_block(chunks.len(), |scope| {
@@ -2605,7 +2615,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
26052615
let range: Range<usize> = if let Some(range) = range {
26062616
range
26072617
} else {
2608-
if data.len() > 128 {
2618+
if data.len() > PREFETCH_TASKS_PARALLIZATION_THRESHOLD {
26092619
let chunk_size = good_chunk_size(data.len());
26102620
let chunks = data.len().div_ceil(chunk_size);
26112621
for i in 0..chunks {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ pub fn connect_children(
125125
// This avoids long pauses of more than 30µs * 10k = 300ms.
126126
// We don't want to parallelize too eagerly as spawning tasks and the temporary allocations have
127127
// a cost as well.
128-
const MIN_CHILDREN_FOR_PARALLEL: usize = 10000;
128+
const CONNECT_CHILDREN_PARALLIZATION_THRESHOLD: usize = 10000;
129129

130130
let len = new_follower_ids.len();
131-
if len >= MIN_CHILDREN_FOR_PARALLEL {
131+
if len >= CONNECT_CHILDREN_PARALLIZATION_THRESHOLD {
132132
let new_follower_ids = new_follower_ids.into_vec();
133133
let chunk_size = good_chunk_size(len);
134134
let _ = scope_and_block(len.div_ceil(chunk_size), |scope| {

0 commit comments

Comments
 (0)