Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ed631bbc
Commit
ed631bbc
authored
Apr 04, 2026
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tracing improvements
parent
bbfc2280
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
169 additions
and
87 deletions
+169
-87
mod.rs
turbopack/crates/turbo-persistence/benches/mod.rs
+3
-0
db.rs
turbopack/crates/turbo-persistence/src/db.rs
+1
-1
sst_filter.rs
turbopack/crates/turbo-persistence/src/sst_filter.rs
+6
-0
tests.rs
turbopack/crates/turbo-persistence/src/tests.rs
+2
-0
mod.rs
turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
+20
-15
aggregation_update.rs
...tasks-backend/src/backend/operation/aggregation_update.rs
+61
-44
mod.rs
...k/crates/turbo-tasks-backend/src/backend/operation/mod.rs
+75
-27
update_cell.rs
.../turbo-tasks-backend/src/backend/operation/update_cell.rs
+1
-0
No files found.
turbopack/crates/turbo-persistence/benches/mod.rs
View file @
ed631bbc
...
@@ -576,6 +576,7 @@ fn prefill_multi_value_database(
...
@@ -576,6 +576,7 @@ fn prefill_multi_value_database(
)
->
Result
<
Vec
<
Box
<
[
u8
]
>>>
{
)
->
Result
<
Vec
<
Box
<
[
u8
]
>>>
{
let
db_config
=
TpDbConfig
{
let
db_config
=
TpDbConfig
{
family_configs
:
[
FamilyConfig
{
family_configs
:
[
FamilyConfig
{
name
:
"test"
,
kind
:
FamilyKind
::
MultiValue
,
kind
:
FamilyKind
::
MultiValue
,
}],
}],
};
};
...
@@ -648,6 +649,7 @@ fn setup_prefilled_multi_value_db(
...
@@ -648,6 +649,7 @@ fn setup_prefilled_multi_value_db(
fn
open_multi_value_db
(
path
:
&
Path
)
->
TurboPersistence
<
SerialScheduler
,
1
>
{
fn
open_multi_value_db
(
path
:
&
Path
)
->
TurboPersistence
<
SerialScheduler
,
1
>
{
let
db_config
=
TpDbConfig
{
let
db_config
=
TpDbConfig
{
family_configs
:
[
FamilyConfig
{
family_configs
:
[
FamilyConfig
{
name
:
"test"
,
kind
:
FamilyKind
::
MultiValue
,
kind
:
FamilyKind
::
MultiValue
,
}],
}],
};
};
...
@@ -914,6 +916,7 @@ fn bench_write_multi_value(c: &mut Criterion) {
...
@@ -914,6 +916,7 @@ fn bench_write_multi_value(c: &mut Criterion) {
|(
tempdir
,
keys
,
random_data
)|
{
|(
tempdir
,
keys
,
random_data
)|
{
let
db_config
=
TpDbConfig
{
let
db_config
=
TpDbConfig
{
family_configs
:
[
FamilyConfig
{
family_configs
:
[
FamilyConfig
{
name
:
"test"
,
kind
:
FamilyKind
::
MultiValue
,
kind
:
FamilyKind
::
MultiValue
,
}],
}],
};
};
...
...
turbopack/crates/turbo-persistence/src/db.rs
View file @
ed631bbc
...
@@ -1573,7 +1573,7 @@ impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES>
...
@@ -1573,7 +1573,7 @@ impl<S: ParallelScheduler, const FAMILIES: usize> TurboPersistence<S, FAMILIES>
}
}
let
span
=
tracing
::
trace_span!
(
let
span
=
tracing
::
trace_span!
(
"database batch read"
,
"database batch read"
,
name
=
family
,
name
=
self
.config.family_configs
[
family
]
.name
,
keys
=
keys
.len
(),
keys
=
keys
.len
(),
not_found
=
tracing
::
field
::
Empty
,
not_found
=
tracing
::
field
::
Empty
,
deleted
=
tracing
::
field
::
Empty
,
deleted
=
tracing
::
field
::
Empty
,
...
...
turbopack/crates/turbo-persistence/src/sst_filter.rs
View file @
ed631bbc
...
@@ -67,3 +67,9 @@ impl SstFilter {
...
@@ -67,3 +67,9 @@ impl SstFilter {
!
used
&&
!
meta
.has_active_entries
()
!
used
&&
!
meta
.has_active_entries
()
}
}
}
}
impl
Default
for
SstFilter
{
fn
default
()
->
Self
{
Self
::
new
()
}
}
turbopack/crates/turbo-persistence/src/tests.rs
View file @
ed631bbc
...
@@ -1521,6 +1521,7 @@ fn compaction_multi_value_preserves_different_values() -> Result<()> {
...
@@ -1521,6 +1521,7 @@ fn compaction_multi_value_preserves_different_values() -> Result<()> {
fn
multi_value_config
()
->
DbConfig
<
1
>
{
fn
multi_value_config
()
->
DbConfig
<
1
>
{
let
mut
config
=
DbConfig
::
<
1
>
::
default
();
let
mut
config
=
DbConfig
::
<
1
>
::
default
();
config
.family_configs
[
0
]
=
FamilyConfig
{
config
.family_configs
[
0
]
=
FamilyConfig
{
name
:
"test"
,
kind
:
FamilyKind
::
MultiValue
,
kind
:
FamilyKind
::
MultiValue
,
};
};
config
config
...
@@ -2097,6 +2098,7 @@ fn compaction_deletes_blob_multi_value_tombstone() -> Result<()> {
...
@@ -2097,6 +2098,7 @@ fn compaction_deletes_blob_multi_value_tombstone() -> Result<()> {
let
config
=
DbConfig
{
let
config
=
DbConfig
{
family_configs
:
[
FamilyConfig
{
family_configs
:
[
FamilyConfig
{
name
:
"test"
,
kind
:
FamilyKind
::
MultiValue
,
kind
:
FamilyKind
::
MultiValue
,
}],
}],
};
};
...
...
turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
View file @
ed631bbc
...
@@ -1912,7 +1912,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
...
@@ -1912,7 +1912,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let
once_task
=
matches!
(
task_type
,
TaskType
::
Transient
(
ref
tt
)
if
matches!
(
&**
tt
,
TransientTask
::
Once
(
_
)));
let
once_task
=
matches!
(
task_type
,
TaskType
::
Transient
(
ref
tt
)
if
matches!
(
&**
tt
,
TransientTask
::
Once
(
_
)));
if
let
Some
(
tasks
)
=
task
.prefetch
()
{
if
let
Some
(
tasks
)
=
task
.prefetch
()
{
drop
(
task
);
drop
(
task
);
ctx
.prepare_tasks
(
tasks
);
ctx
.prepare_tasks
(
tasks
,
"prefetch"
);
task
=
ctx
.task
(
task_id
,
TaskDataCategory
::
All
);
task
=
ctx
.task
(
task_id
,
TaskDataCategory
::
All
);
}
}
let
in_progress
=
task
.take_in_progress
()
?
;
let
in_progress
=
task
.take_in_progress
()
?
;
...
@@ -2399,6 +2399,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
...
@@ -2399,6 +2399,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
output_dependent_tasks
output_dependent_tasks
.iter
()
.iter
()
.map
(|
&
id
|
(
id
,
TaskDataCategory
::
All
)),
.map
(|
&
id
|
(
id
,
TaskDataCategory
::
All
)),
"invalidate output dependents"
,
);
);
}
}
...
@@ -2491,20 +2492,24 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
...
@@ -2491,20 +2492,24 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
debug_assert!
(
!
new_children
.is_empty
());
debug_assert!
(
!
new_children
.is_empty
());
let
mut
queue
=
AggregationUpdateQueue
::
new
();
let
mut
queue
=
AggregationUpdateQueue
::
new
();
ctx
.for_each_task_all
(
new_children
.iter
()
.copied
(),
|
child_task
,
ctx
|
{
ctx
.for_each_task_all
(
if
!
child_task
.has_output
()
{
new_children
.iter
()
.copied
(),
let
child_id
=
child_task
.id
();
"unfinished children dirty"
,
make_task_dirty_internal
(
|
child_task
,
ctx
|
{
child_task
,
if
!
child_task
.has_output
()
{
child_id
,
let
child_id
=
child_task
.id
();
false
,
make_task_dirty_internal
(
#[cfg(feature
=
"trace_task_dirty"
)]
child_task
,
TaskDirtyCause
::
InitialDirty
,
child_id
,
&
mut
queue
,
false
,
ctx
,
#[cfg(feature
=
"trace_task_dirty"
)]
);
TaskDirtyCause
::
InitialDirty
,
}
&
mut
queue
,
});
ctx
,
);
}
},
);
queue
.execute
(
ctx
);
queue
.execute
(
ctx
);
}
}
...
...
turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs
View file @
ed631bbc
...
@@ -1256,10 +1256,14 @@ impl AggregationUpdateQueue {
...
@@ -1256,10 +1256,14 @@ impl AggregationUpdateQueue {
self
.find_and_schedule_dirty
(
jobs
,
ctx
);
self
.find_and_schedule_dirty
(
jobs
,
ctx
);
false
false
}
else
if
!
self
.scheduled_tasks
.is_empty
()
{
}
else
if
!
self
.scheduled_tasks
.is_empty
()
{
ctx
.for_each_task_all
(
self
.scheduled_tasks
.keys
()
.copied
(),
|
task
,
ctx
|
{
ctx
.for_each_task_all
(
let
parent_priority
=
self
.scheduled_tasks
[
&
task
.id
()];
self
.scheduled_tasks
.keys
()
.copied
(),
ctx
.schedule_task
(
task
,
parent_priority
);
"schedule tasks"
,
});
|
task
,
ctx
|
{
let
parent_priority
=
self
.scheduled_tasks
[
&
task
.id
()];
ctx
.schedule_task
(
task
,
parent_priority
);
},
);
self
.scheduled_tasks
.clear
();
self
.scheduled_tasks
.clear
();
false
false
}
else
{
}
else
{
...
@@ -1444,18 +1448,22 @@ impl AggregationUpdateQueue {
...
@@ -1444,18 +1448,22 @@ impl AggregationUpdateQueue {
.map
(|
job
|
(
job
.task_id
,
job
.span
.clone
()))
.map
(|
job
|
(
job
.task_id
,
job
.span
.clone
()))
.collect
();
.collect
();
// For performance reasons this should stay `Meta` and not `All`
// For performance reasons this should stay `Meta` and not `All`
ctx
.for_each_task_meta
(
jobs
.into_iter
()
.map
(|
job
|
job
.task_id
),
|
task
,
ctx
|
{
ctx
.for_each_task_meta
(
let
task_id
=
task
.id
();
jobs
.into_iter
()
.map
(|
job
|
job
.task_id
),
// Enter the enqueue-time span and create a per-task child span with the
"find and schedule dirty"
,
// task description. Both guards must live until the end of the closure.
|
task
,
ctx
|
{
#[cfg(feature
=
"trace_find_and_schedule"
)]
let
task_id
=
task
.id
();
let
_trace
=
(
// Enter the enqueue-time span and create a per-task child span with the
spans
.remove
(
&
task_id
)
.flatten
()
.map
(|
s
|
s
.entered
()),
// task description. Both guards must live until the end of the closure.
trace_span!
(
"find and schedule"
,
%
task_id
,
name
=
task
.get_task_description
())
#[cfg(feature
=
"trace_find_and_schedule"
)]
.entered
(),
let
_trace
=
(
);
spans
.remove
(
&
task_id
)
.flatten
()
.map
(|
s
|
s
.entered
()),
self
.find_and_schedule_dirty_internal
(
task_id
,
task
,
ctx
);
trace_span!
(
"find and schedule"
,
%
task_id
,
name
=
task
.get_task_description
())
});
.entered
(),
);
self
.find_and_schedule_dirty_internal
(
task_id
,
task
,
ctx
);
},
);
}
}
fn
find_and_schedule_dirty_internal
(
fn
find_and_schedule_dirty_internal
(
...
@@ -1507,21 +1515,25 @@ impl AggregationUpdateQueue {
...
@@ -1507,21 +1515,25 @@ impl AggregationUpdateQueue {
update
:
AggregatedDataUpdate
,
update
:
AggregatedDataUpdate
,
)
{
)
{
// For performance reasons this should stay `Meta` and not `All`
// For performance reasons this should stay `Meta` and not `All`
ctx
.for_each_task_meta
(
upper_ids
.iter
()
.copied
(),
|
mut
upper
,
ctx
|
{
ctx
.for_each_task_meta
(
let
diff
=
update
.apply
(
&
mut
upper
,
ctx
.should_track_activeness
(),
self
);
upper_ids
.iter
()
.copied
(),
if
!
diff
.is_empty
()
{
"aggregated data update"
,
let
upper_ids
=
get_uppers
(
&
upper
);
|
mut
upper
,
ctx
|
{
if
!
upper_ids
.is_empty
()
{
let
diff
=
update
.apply
(
&
mut
upper
,
ctx
.should_track_activeness
(),
self
);
self
.push
(
if
!
diff
.is_empty
()
{
AggregatedDataUpdateJob
{
let
upper_ids
=
get_uppers
(
&
upper
);
upper_ids
,
if
!
upper_ids
.is_empty
()
{
update
:
diff
,
self
.push
(
}
AggregatedDataUpdateJob
{
.into
(),
upper_ids
,
);
update
:
diff
,
}
.into
(),
);
}
}
}
}
}
,
}
);
);
}
}
fn
inner_of_uppers_lost_follower
(
fn
inner_of_uppers_lost_follower
(
...
@@ -1574,20 +1586,24 @@ impl AggregationUpdateQueue {
...
@@ -1574,20 +1586,24 @@ impl AggregationUpdateQueue {
if
!
data
.is_empty
()
{
if
!
data
.is_empty
()
{
// remove data from upper
// remove data from upper
// For performance reasons this should stay `Meta` and not `All`
// For performance reasons this should stay `Meta` and not `All`
ctx
.for_each_task_meta
(
removed_uppers
.iter
()
.copied
(),
|
mut
upper
,
ctx
|
{
ctx
.for_each_task_meta
(
// STEP 6
removed_uppers
.iter
()
.copied
(),
let
diff
=
data
.apply
(
&
mut
upper
,
ctx
.should_track_activeness
(),
self
);
"remove data from uppers"
,
if
!
diff
.is_empty
()
{
|
mut
upper
,
ctx
|
{
let
upper_ids
=
get_uppers
(
&
upper
);
// STEP 6
self
.push
(
let
diff
=
data
.apply
(
&
mut
upper
,
ctx
.should_track_activeness
(),
self
);
AggregatedDataUpdateJob
{
if
!
diff
.is_empty
()
{
upper_ids
,
let
upper_ids
=
get_uppers
(
&
upper
);
update
:
diff
,
self
.push
(
}
AggregatedDataUpdateJob
{
.into
(),
upper_ids
,
)
update
:
diff
,
}
}
});
.into
(),
)
}
},
);
}
}
// STEP 7
// STEP 7
if
!
followers
.is_empty
()
{
if
!
followers
.is_empty
()
{
...
@@ -2061,6 +2077,7 @@ impl AggregationUpdateQueue {
...
@@ -2061,6 +2077,7 @@ impl AggregationUpdateQueue {
upper_ids_with_min_aggregation_number
upper_ids_with_min_aggregation_number
.iter
()
.iter
()
.map
(|(
entry
,
_
)|
entry
.task_id
()),
.map
(|(
entry
,
_
)|
entry
.task_id
()),
"add data to uppers"
,
|
mut
upper
,
ctx
|
{
|
mut
upper
,
ctx
|
{
// STEP 6d
// STEP 6d
if
has_data
{
if
has_data
{
...
...
turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs
View file @
ed631bbc
...
@@ -13,6 +13,7 @@ use std::{
...
@@ -13,6 +13,7 @@ use std::{
};
};
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
tracing
::
trace_span
;
use
turbo_tasks
::{
use
turbo_tasks
::{
CellId
,
FxIndexMap
,
TaskExecutionReason
,
TaskId
,
TaskPriority
,
TurboTasksBackendApi
,
CellId
,
FxIndexMap
,
TaskExecutionReason
,
TaskId
,
TaskPriority
,
TurboTasksBackendApi
,
TurboTasksCallApi
,
TypedSharedReference
,
backend
::
CachedTaskType
,
TurboTasksCallApi
,
TypedSharedReference
,
backend
::
CachedTaskType
,
...
@@ -45,29 +46,35 @@ pub trait ExecuteContext<'e>: Sized {
...
@@ -45,29 +46,35 @@ pub trait ExecuteContext<'e>: Sized {
fn
prepare_tasks
(
fn
prepare_tasks
(
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
+
Clone
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
+
Clone
,
reason
:
&
'static
str
,
);
);
fn
for_each_task
(
fn
for_each_task
(
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
reason
:
&
'static
str
,
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
);
);
fn
for_each_task_meta
(
fn
for_each_task_meta
(
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
TaskId
>
,
task_ids
:
impl
IntoIterator
<
Item
=
TaskId
>
,
reason
:
&
'static
str
,
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
)
{
)
{
self
.for_each_task
(
self
.for_each_task
(
task_ids
.into_iter
()
.map
(|
id
|
(
id
,
TaskDataCategory
::
Meta
)),
task_ids
.into_iter
()
.map
(|
id
|
(
id
,
TaskDataCategory
::
Meta
)),
reason
,
func
,
func
,
)
)
}
}
fn
for_each_task_all
(
fn
for_each_task_all
(
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
TaskId
>
,
task_ids
:
impl
IntoIterator
<
Item
=
TaskId
>
,
reason
:
&
'static
str
,
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
)
{
)
{
self
.for_each_task
(
self
.for_each_task
(
task_ids
.into_iter
()
.map
(|
id
|
(
id
,
TaskDataCategory
::
All
)),
task_ids
.into_iter
()
.map
(|
id
|
(
id
,
TaskDataCategory
::
All
)),
reason
,
func
,
func
,
)
)
}
}
...
@@ -199,6 +206,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -199,6 +206,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
&
self
,
&
self
,
task_ids
:
&
[
TaskId
],
task_ids
:
&
[
TaskId
],
category
:
SpecificTaskDataCategory
,
category
:
SpecificTaskDataCategory
,
reason
:
&
'static
str
,
)
->
Option
<
Vec
<
TaskStorage
>>
{
)
->
Option
<
Vec
<
TaskStorage
>>
{
debug_assert!
(
debug_assert!
(
task_ids
.len
()
>
1
,
task_ids
.len
()
>
1
,
...
@@ -208,6 +216,13 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -208,6 +216,13 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
// If we don't need to restore, we return None
// If we don't need to restore, we return None
return
None
;
return
None
;
}
}
let
_span
=
trace_span!
(
"restore_task_data_batch"
,
reason
,
category
=
?
category
,
keys
=
task_ids
.len
(),
)
.entered
();
let
result
=
self
let
result
=
self
.backend
.backend
.backing_storage
.backing_storage
...
@@ -230,6 +245,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -230,6 +245,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
call_prepared_task_callback_for_transient_tasks
:
bool
,
call_prepared_task_callback_for_transient_tasks
:
bool
,
reason
:
&
'static
str
,
mut
prepared_task_callback
:
impl
FnMut
(
mut
prepared_task_callback
:
impl
FnMut
(
&
mut
Self
,
&
mut
Self
,
TaskId
,
TaskId
,
...
@@ -237,6 +253,15 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -237,6 +253,15 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
StorageWriteGuard
<
'e
>
,
StorageWriteGuard
<
'e
>
,
),
),
)
{
)
{
let
span
=
trace_span!
(
"prepare_tasks_with_callback"
,
reason
,
requested_data
=
tracing
::
field
::
Empty
,
requested_meta
=
tracing
::
field
::
Empty
,
races_data
=
tracing
::
field
::
Empty
,
races_meta
=
tracing
::
field
::
Empty
,
);
let
_guard
=
span
.enter
();
let
mut
data_count
=
0
;
let
mut
data_count
=
0
;
let
mut
meta_count
=
0
;
let
mut
meta_count
=
0
;
let
mut
all_count
=
0
;
let
mut
all_count
=
0
;
...
@@ -267,6 +292,8 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -267,6 +292,8 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
.collect
::
<
Vec
<
_
>>
();
.collect
::
<
Vec
<
_
>>
();
data_count
+=
all_count
;
data_count
+=
all_count
;
meta_count
+=
all_count
;
meta_count
+=
all_count
;
span
.record
(
"requested_data"
,
data_count
);
span
.record
(
"requested_meta"
,
meta_count
);
let
mut
tasks_to_restore_for_data
=
Vec
::
with_capacity
(
data_count
);
let
mut
tasks_to_restore_for_data
=
Vec
::
with_capacity
(
data_count
);
let
mut
tasks_to_restore_for_data_indicies
=
Vec
::
with_capacity
(
data_count
);
let
mut
tasks_to_restore_for_data_indicies
=
Vec
::
with_capacity
(
data_count
);
...
@@ -312,6 +339,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -312,6 +339,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
if
let
Some
(
data
)
=
self
.restore_task_data_batch
(
if
let
Some
(
data
)
=
self
.restore_task_data_batch
(
&
tasks_to_restore_for_data
,
&
tasks_to_restore_for_data
,
SpecificTaskDataCategory
::
Data
,
SpecificTaskDataCategory
::
Data
,
reason
,
)
{
)
{
data
.into_iter
()
data
.into_iter
()
.zip
(
tasks_to_restore_for_data_indicies
)
.zip
(
tasks_to_restore_for_data_indicies
)
...
@@ -337,6 +365,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -337,6 +365,7 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
if
let
Some
(
data
)
=
self
.restore_task_data_batch
(
if
let
Some
(
data
)
=
self
.restore_task_data_batch
(
&
tasks_to_restore_for_meta
,
&
tasks_to_restore_for_meta
,
SpecificTaskDataCategory
::
Meta
,
SpecificTaskDataCategory
::
Meta
,
reason
,
)
{
)
{
data
.into_iter
()
data
.into_iter
()
.zip
(
tasks_to_restore_for_meta_indicies
)
.zip
(
tasks_to_restore_for_meta_indicies
)
...
@@ -351,6 +380,8 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -351,6 +380,8 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
}
}
}
}
let
mut
races_data
=
0u32
;
let
mut
races_meta
=
0u32
;
for
(
task_id
,
category
,
storage_for_data
,
storage_for_meta
)
in
tasks
{
for
(
task_id
,
category
,
storage_for_data
,
storage_for_meta
)
in
tasks
{
if
storage_for_data
.is_none
()
&&
storage_for_meta
.is_none
()
{
if
storage_for_data
.is_none
()
&&
storage_for_meta
.is_none
()
{
continue
;
continue
;
...
@@ -359,18 +390,24 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
...
@@ -359,18 +390,24 @@ impl<'e, B: BackingStorage> ExecuteContextImpl<'e, B> {
let
mut
task_type
=
None
;
let
mut
task_type
=
None
;
let
mut
task
=
self
.backend.storage
.access_mut
(
task_id
);
let
mut
task
=
self
.backend.storage
.access_mut
(
task_id
);
if
let
Some
(
storage
)
=
storage_for_data
if
let
Some
(
storage
)
=
storage_for_data
{
&&
!
task
.flags
.is_restored
(
TaskDataCategory
::
Data
)
if
!
task
.flags
.is_restored
(
TaskDataCategory
::
Data
)
{
{
task
.restore_from
(
storage
,
TaskDataCategory
::
Data
);
task
.restore_from
(
storage
,
TaskDataCategory
::
Data
);
task
.flags
.set_restored
(
TaskDataCategory
::
Data
);
task
.flags
.set_restored
(
TaskDataCategory
::
Data
);
task_type
=
task
.get_persistent_task_type
()
.cloned
()
task_type
=
task
.get_persistent_task_type
()
.cloned
()
}
else
{
races_data
+=
1
;
span
.record
(
"races_data"
,
races_data
);
}
}
}
if
let
Some
(
storage
)
=
storage_for_meta
if
let
Some
(
storage
)
=
storage_for_meta
{
&&
!
task
.flags
.is_restored
(
TaskDataCategory
::
Meta
)
if
!
task
.flags
.is_restored
(
TaskDataCategory
::
Meta
)
{
{
task
.restore_from
(
storage
,
TaskDataCategory
::
Meta
);
task
.restore_from
(
storage
,
TaskDataCategory
::
Meta
);
task
.flags
.set_restored
(
TaskDataCategory
::
Meta
);
task
.flags
.set_restored
(
TaskDataCategory
::
Meta
);
}
else
{
races_meta
+=
1
;
span
.record
(
"races_meta"
,
races_meta
);
}
}
}
self
.task_lock_counter
.release
();
self
.task_lock_counter
.release
();
prepared_task_callback
(
self
,
task_id
,
category
,
task
);
prepared_task_callback
(
self
,
task_id
,
category
,
task
);
...
@@ -446,30 +483,41 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> {
...
@@ -446,30 +483,41 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> {
}
}
}
}
fn
prepare_tasks
(
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
)
{
fn
prepare_tasks
(
self
.prepare_tasks_with_callback
(
task_ids
,
false
,
|
_
,
_
,
_
,
_
|
{});
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
+
Clone
,
reason
:
&
'static
str
,
)
{
self
.prepare_tasks_with_callback
(
task_ids
,
false
,
reason
,
|
_
,
_
,
_
,
_
|
{});
}
}
fn
for_each_task
(
fn
for_each_task
(
&
mut
self
,
&
mut
self
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
task_ids
:
impl
IntoIterator
<
Item
=
(
TaskId
,
TaskDataCategory
)
>
,
reason
:
&
'static
str
,
mut
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
mut
func
:
impl
FnMut
(
Self
::
TaskGuardImpl
,
&
mut
Self
),
)
{
)
{
let
task_lock_counter
=
self
.task_lock_counter
.clone
();
let
task_lock_counter
=
self
.task_lock_counter
.clone
();
self
.prepare_tasks_with_callback
(
task_ids
,
true
,
|
this
,
task_id
,
_category
,
task
|
{
self
.prepare_tasks_with_callback
(
// prepare_tasks_with_callback releases the counter before calling this callback,
task_ids
,
// so the counter is 0 here. Acquire for the TaskGuardImpl that will release on Drop.
true
,
task_lock_counter
.acquire
();
reason
,
|
this
,
task_id
,
_category
,
task
|
{
let
guard
=
TaskGuardImpl
{
// prepare_tasks_with_callback releases the counter before calling this callback,
task
,
// so the counter is 0 here. Acquire for the TaskGuardImpl that will release on
task_id
,
// Drop.
#[cfg(debug_assertions)]
task_lock_counter
.acquire
();
category
:
_category
,
task_lock_counter
:
task_lock_counter
.clone
(),
let
guard
=
TaskGuardImpl
{
};
task
,
func
(
guard
,
this
);
task_id
,
});
#[cfg(debug_assertions)]
category
:
_category
,
task_lock_counter
:
task_lock_counter
.clone
(),
};
func
(
guard
,
this
);
},
);
}
}
fn
task_pair
(
fn
task_pair
(
...
...
turbopack/crates/turbo-tasks-backend/src/backend/operation/update_cell.rs
View file @
ed631bbc
...
@@ -153,6 +153,7 @@ impl UpdateCellOperation {
...
@@ -153,6 +153,7 @@ impl UpdateCellOperation {
dependent_tasks
dependent_tasks
.keys
()
.keys
()
.map
(|
&
id
|
(
id
,
TaskDataCategory
::
All
)),
.map
(|
&
id
|
(
id
,
TaskDataCategory
::
All
)),
"invalidate cell dependents"
,
);
);
UpdateCellOperation
::
InvalidateWhenCellDependency
{
UpdateCellOperation
::
InvalidateWhenCellDependency
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment