@@ -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+
7585const 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 {
0 commit comments