Unverified Commit 939f5414 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[Turbopack] add persisting to the new backend (#69668)

### What?

Takes regular snapshots of the state of the system.

Stores task cache and task data in a lmdb database. 

Currently active operations are paused, stored and continued on restore.

Task Cache need large keys, so key hashing and lookup is added on top of
LMDB for that.
parent 1095650d
...@@ -920,9 +920,9 @@ checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" ...@@ -920,9 +920,9 @@ checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.4.3" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "bytes" name = "bytes"
...@@ -3609,6 +3609,29 @@ version = "0.4.1" ...@@ -3609,6 +3609,29 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
[[package]]
name = "lmdb-rkv"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447a296f7aca299cfbb50f4e4f3d49451549af655fb7215d7f8c0c3d64bad42b"
dependencies = [
"bitflags 1.3.2",
"byteorder",
"libc",
"lmdb-rkv-sys",
]
[[package]]
name = "lmdb-rkv-sys"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61b9ce6b3be08acefa3003c57b7565377432a89ec24476bbe72e11d101f852fe"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.10" version = "0.4.10"
...@@ -4991,6 +5014,17 @@ dependencies = [ ...@@ -4991,6 +5014,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "pot"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df842bdb3b0553a411589e64aaa1a7d0c0259f72fabcedfaa841683ae3019d80"
dependencies = [
"byteorder",
"half 2.4.1",
"serde",
]
[[package]] [[package]]
name = "powerfmt" name = "powerfmt"
version = "0.2.0" version = "0.2.0"
...@@ -8148,6 +8182,16 @@ dependencies = [ ...@@ -8148,6 +8182,16 @@ dependencies = [
"webpki", "webpki",
] ]
[[package]]
name = "tokio-scoped"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4beb8ba13bc53ac53ce1d52b42f02e5d8060f0f42138862869beb769722b256"
dependencies = [
"tokio",
"tokio-stream",
]
[[package]] [[package]]
name = "tokio-stream" name = "tokio-stream"
version = "0.1.15" version = "0.1.15"
...@@ -8550,6 +8594,7 @@ dependencies = [ ...@@ -8550,6 +8594,7 @@ dependencies = [
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"pin-project-lite", "pin-project-lite",
"rayon",
"regex", "regex",
"rustc-hash", "rustc-hash",
"serde", "serde",
...@@ -8574,17 +8619,23 @@ dependencies = [ ...@@ -8574,17 +8619,23 @@ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"auto-hash-map", "auto-hash-map",
"byteorder",
"dashmap", "dashmap",
"either", "either",
"hashbrown 0.14.5", "hashbrown 0.14.5",
"indexmap 1.9.3", "indexmap 1.9.3",
"lmdb-rkv",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"pot",
"rand", "rand",
"rayon",
"rustc-hash", "rustc-hash",
"serde", "serde",
"serde_path_to_error",
"smallvec", "smallvec",
"tokio", "tokio",
"tokio-scoped",
"tracing", "tracing",
"turbo-prehash", "turbo-prehash",
"turbo-tasks", "turbo-tasks",
......
...@@ -12,21 +12,31 @@ bench = false ...@@ -12,21 +12,31 @@ bench = false
[lints] [lints]
workspace = true workspace = true
[features]
default = []
verify_serialization = []
[dependencies] [dependencies]
anyhow = { workspace = true } anyhow = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
auto-hash-map = { workspace = true } auto-hash-map = { workspace = true }
byteorder = "1.5.0"
dashmap = { workspace = true, features = ["raw-api"]} dashmap = { workspace = true, features = ["raw-api"]}
either = { workspace = true } either = { workspace = true }
hashbrown = { workspace = true } hashbrown = { workspace = true }
indexmap = { workspace = true } indexmap = { workspace = true }
lmdb-rkv = "0.14.0"
once_cell = { workspace = true } once_cell = { workspace = true }
parking_lot = { workspace = true } parking_lot = { workspace = true }
pot = "3.0.0"
rand = { workspace = true } rand = { workspace = true }
rayon = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
serde = { workspace = true } serde = { workspace = true }
serde_path_to_error = { workspace = true }
smallvec = { workspace = true } smallvec = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
tokio-scoped = "0.2.0"
tracing = { workspace = true } tracing = { workspace = true }
turbo-prehash = { workspace = true } turbo-prehash = { workspace = true }
turbo-tasks = { workspace = true } turbo-tasks = { workspace = true }
......
...@@ -7,6 +7,7 @@ use crate::{ ...@@ -7,6 +7,7 @@ use crate::{
backend::{ backend::{
operation::{ExecuteContext, Operation, TaskGuard}, operation::{ExecuteContext, Operation, TaskGuard},
storage::{get, get_many, iter_many, remove, update, update_count}, storage::{get, get_many, iter_many, remove, update, update_count},
TaskDataCategory,
}, },
data::{ActiveType, AggregationNumber, CachedDataItem, CachedDataItemKey, RootState}, data::{ActiveType, AggregationNumber, CachedDataItem, CachedDataItemKey, RootState},
}; };
...@@ -250,13 +251,13 @@ impl AggregationUpdateQueue { ...@@ -250,13 +251,13 @@ impl AggregationUpdateQueue {
self.jobs.extend(jobs); self.jobs.extend(jobs);
} }
pub fn run(job: AggregationUpdateJob, ctx: &ExecuteContext<'_>) { pub fn run(job: AggregationUpdateJob, ctx: &mut ExecuteContext<'_>) {
let mut queue = Self::new(); let mut queue = Self::new();
queue.push(job); queue.push(job);
queue.execute(ctx); queue.execute(ctx);
} }
pub fn process(&mut self, ctx: &ExecuteContext<'_>) -> bool { pub fn process(&mut self, ctx: &mut ExecuteContext<'_>) -> bool {
if let Some(job) = self.jobs.pop_front() { if let Some(job) = self.jobs.pop_front() {
match job { match job {
AggregationUpdateJob::UpdateAggregationNumber { AggregationUpdateJob::UpdateAggregationNumber {
...@@ -384,8 +385,8 @@ impl AggregationUpdateQueue { ...@@ -384,8 +385,8 @@ impl AggregationUpdateQueue {
self.jobs.is_empty() self.jobs.is_empty()
} }
fn balance_edge(&mut self, ctx: &ExecuteContext, upper_id: TaskId, task_id: TaskId) { fn balance_edge(&mut self, ctx: &mut ExecuteContext, upper_id: TaskId, task_id: TaskId) {
let (mut upper, mut task) = ctx.task_pair(upper_id, task_id); let (mut upper, mut task) = ctx.task_pair(upper_id, task_id, TaskDataCategory::Meta);
let upper_aggregation_number = get_aggregation_number(&upper); let upper_aggregation_number = get_aggregation_number(&upper);
let task_aggregation_number = get_aggregation_number(&task); let task_aggregation_number = get_aggregation_number(&task);
...@@ -484,13 +485,13 @@ impl AggregationUpdateQueue { ...@@ -484,13 +485,13 @@ impl AggregationUpdateQueue {
} }
} }
fn find_and_schedule_dirty(&mut self, mut task_ids: Vec<TaskId>, ctx: &ExecuteContext) { fn find_and_schedule_dirty(&mut self, mut task_ids: Vec<TaskId>, ctx: &mut ExecuteContext) {
let popped = task_ids.pop(); let popped = task_ids.pop();
if !task_ids.is_empty() { if !task_ids.is_empty() {
self.push(AggregationUpdateJob::FindAndScheduleDirty { task_ids }); self.push(AggregationUpdateJob::FindAndScheduleDirty { task_ids });
} }
if let Some(task_id) = popped { if let Some(task_id) = popped {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::Meta);
#[allow(clippy::collapsible_if, reason = "readablility")] #[allow(clippy::collapsible_if, reason = "readablility")]
if task.has_key(&CachedDataItemKey::Dirty {}) { if task.has_key(&CachedDataItemKey::Dirty {}) {
let description = ctx.backend.get_task_desc_fn(task_id); let description = ctx.backend.get_task_desc_fn(task_id);
...@@ -518,11 +519,11 @@ impl AggregationUpdateQueue { ...@@ -518,11 +519,11 @@ impl AggregationUpdateQueue {
fn aggregated_data_update( fn aggregated_data_update(
&mut self, &mut self,
upper_ids: Vec<TaskId>, upper_ids: Vec<TaskId>,
ctx: &ExecuteContext, ctx: &mut ExecuteContext,
update: AggregatedDataUpdate, update: AggregatedDataUpdate,
) { ) {
for upper_id in upper_ids { for upper_id in upper_ids {
let mut upper = ctx.task(upper_id); let mut upper = ctx.task(upper_id, TaskDataCategory::Meta);
let diff = update.apply(&mut upper, self); let diff = update.apply(&mut upper, self);
if !diff.is_empty() { if !diff.is_empty() {
let upper_ids = get_uppers(&upper); let upper_ids = get_uppers(&upper);
...@@ -538,11 +539,11 @@ impl AggregationUpdateQueue { ...@@ -538,11 +539,11 @@ impl AggregationUpdateQueue {
fn inner_lost_follower( fn inner_lost_follower(
&mut self, &mut self,
ctx: &ExecuteContext, ctx: &mut ExecuteContext,
lost_follower_id: TaskId, lost_follower_id: TaskId,
mut upper_ids: Vec<TaskId>, mut upper_ids: Vec<TaskId>,
) { ) {
let mut follower = ctx.task(lost_follower_id); let mut follower = ctx.task(lost_follower_id, TaskDataCategory::Meta);
let mut follower_in_upper_ids = Vec::new(); let mut follower_in_upper_ids = Vec::new();
upper_ids.retain(|&upper_id| { upper_ids.retain(|&upper_id| {
let mut keep_upper = false; let mut keep_upper = false;
...@@ -571,7 +572,7 @@ impl AggregationUpdateQueue { ...@@ -571,7 +572,7 @@ impl AggregationUpdateQueue {
if !data.is_empty() { if !data.is_empty() {
for upper_id in upper_ids.iter() { for upper_id in upper_ids.iter() {
// remove data from upper // remove data from upper
let mut upper = ctx.task(*upper_id); let mut upper = ctx.task(*upper_id, TaskDataCategory::Meta);
let diff = data.apply(&mut upper, self); let diff = data.apply(&mut upper, self);
if !diff.is_empty() { if !diff.is_empty() {
let upper_ids = get_uppers(&upper); let upper_ids = get_uppers(&upper);
...@@ -593,7 +594,7 @@ impl AggregationUpdateQueue { ...@@ -593,7 +594,7 @@ impl AggregationUpdateQueue {
} }
for upper_id in follower_in_upper_ids { for upper_id in follower_in_upper_ids {
let mut upper = ctx.task(upper_id); let mut upper = ctx.task(upper_id, TaskDataCategory::Meta);
if update_count!( if update_count!(
upper, upper,
Follower { Follower {
...@@ -612,17 +613,17 @@ impl AggregationUpdateQueue { ...@@ -612,17 +613,17 @@ impl AggregationUpdateQueue {
fn inner_of_uppers_has_new_follower( fn inner_of_uppers_has_new_follower(
&mut self, &mut self,
ctx: &ExecuteContext, ctx: &mut ExecuteContext,
new_follower_id: TaskId, new_follower_id: TaskId,
mut upper_ids: Vec<TaskId>, mut upper_ids: Vec<TaskId>,
) { ) {
let follower_aggregation_number = { let follower_aggregation_number = {
let follower = ctx.task(new_follower_id); let follower = ctx.task(new_follower_id, TaskDataCategory::Meta);
get_aggregation_number(&follower) get_aggregation_number(&follower)
}; };
let mut upper_ids_as_follower = Vec::new(); let mut upper_ids_as_follower = Vec::new();
upper_ids.retain(|&upper_id| { upper_ids.retain(|&upper_id| {
let upper = ctx.task(upper_id); let upper = ctx.task(upper_id, TaskDataCategory::Meta);
// decide if it should be an inner or follower // decide if it should be an inner or follower
let upper_aggregation_number = get_aggregation_number(&upper); let upper_aggregation_number = get_aggregation_number(&upper);
...@@ -638,7 +639,7 @@ impl AggregationUpdateQueue { ...@@ -638,7 +639,7 @@ impl AggregationUpdateQueue {
} }
}); });
if !upper_ids.is_empty() { if !upper_ids.is_empty() {
let mut follower = ctx.task(new_follower_id); let mut follower = ctx.task(new_follower_id, TaskDataCategory::Meta);
upper_ids.retain(|&upper_id| { upper_ids.retain(|&upper_id| {
if update_count!(follower, Upper { task: upper_id }, 1) { if update_count!(follower, Upper { task: upper_id }, 1) {
// It's a new upper // It's a new upper
...@@ -656,7 +657,7 @@ impl AggregationUpdateQueue { ...@@ -656,7 +657,7 @@ impl AggregationUpdateQueue {
if !data.is_empty() { if !data.is_empty() {
for upper_id in upper_ids.iter() { for upper_id in upper_ids.iter() {
// add data to upper // add data to upper
let mut upper = ctx.task(*upper_id); let mut upper = ctx.task(*upper_id, TaskDataCategory::Meta);
let diff = data.apply(&mut upper, self); let diff = data.apply(&mut upper, self);
if !diff.is_empty() { if !diff.is_empty() {
let upper_ids = get_uppers(&upper); let upper_ids = get_uppers(&upper);
...@@ -678,7 +679,7 @@ impl AggregationUpdateQueue { ...@@ -678,7 +679,7 @@ impl AggregationUpdateQueue {
} }
} }
upper_ids_as_follower.retain(|&upper_id| { upper_ids_as_follower.retain(|&upper_id| {
let mut upper = ctx.task(upper_id); let mut upper = ctx.task(upper_id, TaskDataCategory::Meta);
update_count!( update_count!(
upper, upper,
Follower { Follower {
...@@ -697,21 +698,21 @@ impl AggregationUpdateQueue { ...@@ -697,21 +698,21 @@ impl AggregationUpdateQueue {
fn inner_of_upper_has_new_followers( fn inner_of_upper_has_new_followers(
&mut self, &mut self,
ctx: &ExecuteContext, ctx: &mut ExecuteContext,
new_follower_ids: Vec<TaskId>, new_follower_ids: Vec<TaskId>,
upper_id: TaskId, upper_id: TaskId,
) { ) {
let mut followers_with_aggregation_number = new_follower_ids let mut followers_with_aggregation_number = new_follower_ids
.into_iter() .into_iter()
.map(|new_follower_id| { .map(|new_follower_id| {
let follower = ctx.task(new_follower_id); let follower = ctx.task(new_follower_id, TaskDataCategory::Meta);
(new_follower_id, get_aggregation_number(&follower)) (new_follower_id, get_aggregation_number(&follower))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let mut followers_of_upper = Vec::new(); let mut followers_of_upper = Vec::new();
{ {
let upper = ctx.task(upper_id); let upper = ctx.task(upper_id, TaskDataCategory::Meta);
// decide if it should be an inner or follower // decide if it should be an inner or follower
let upper_aggregation_number = get_aggregation_number(&upper); let upper_aggregation_number = get_aggregation_number(&upper);
...@@ -734,7 +735,7 @@ impl AggregationUpdateQueue { ...@@ -734,7 +735,7 @@ impl AggregationUpdateQueue {
let mut upper_data_updates = Vec::new(); let mut upper_data_updates = Vec::new();
let mut upper_new_followers = Vec::new(); let mut upper_new_followers = Vec::new();
for (follower_id, _) in followers_with_aggregation_number { for (follower_id, _) in followers_with_aggregation_number {
let mut follower = ctx.task(follower_id); let mut follower = ctx.task(follower_id, TaskDataCategory::Meta);
if update_count!(follower, Upper { task: upper_id }, 1) { if update_count!(follower, Upper { task: upper_id }, 1) {
// It's a new upper // It's a new upper
let data = AggregatedDataUpdate::from_task(&mut follower); let data = AggregatedDataUpdate::from_task(&mut follower);
...@@ -755,7 +756,7 @@ impl AggregationUpdateQueue { ...@@ -755,7 +756,7 @@ impl AggregationUpdateQueue {
} }
if !upper_data_updates.is_empty() { if !upper_data_updates.is_empty() {
// add data to upper // add data to upper
let mut upper = ctx.task(upper_id); let mut upper = ctx.task(upper_id, TaskDataCategory::Meta);
let diffs = upper_data_updates let diffs = upper_data_updates
.into_iter() .into_iter()
.filter_map(|data| { .filter_map(|data| {
...@@ -782,7 +783,7 @@ impl AggregationUpdateQueue { ...@@ -782,7 +783,7 @@ impl AggregationUpdateQueue {
} }
} }
if !followers_of_upper.is_empty() { if !followers_of_upper.is_empty() {
let mut upper = ctx.task(upper_id); let mut upper = ctx.task(upper_id, TaskDataCategory::Meta);
followers_of_upper followers_of_upper
.retain(|follower_id| update_count!(upper, Follower { task: *follower_id }, 1)); .retain(|follower_id| update_count!(upper, Follower { task: *follower_id }, 1));
if !followers_of_upper.is_empty() { if !followers_of_upper.is_empty() {
...@@ -796,12 +797,12 @@ impl AggregationUpdateQueue { ...@@ -796,12 +797,12 @@ impl AggregationUpdateQueue {
fn update_aggregation_number( fn update_aggregation_number(
&mut self, &mut self,
ctx: &ExecuteContext, ctx: &mut ExecuteContext,
task_id: TaskId, task_id: TaskId,
base_effective_distance: Option<std::num::NonZero<u32>>, base_effective_distance: Option<std::num::NonZero<u32>>,
base_aggregation_number: u32, base_aggregation_number: u32,
) { ) {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::Meta);
let current = get!(task, AggregationNumber).copied().unwrap_or_default(); let current = get!(task, AggregationNumber).copied().unwrap_or_default();
// The wanted new distance is either the provided one or the old distance // The wanted new distance is either the provided one or the old distance
let distance = base_effective_distance.map_or(current.distance, |d| d.get()); let distance = base_effective_distance.map_or(current.distance, |d| d.get());
...@@ -870,8 +871,7 @@ impl AggregationUpdateQueue { ...@@ -870,8 +871,7 @@ impl AggregationUpdateQueue {
} }
impl Operation for AggregationUpdateQueue { impl Operation for AggregationUpdateQueue {
fn execute(mut self, ctx: &ExecuteContext<'_>) { fn execute(mut self, ctx: &mut ExecuteContext<'_>) {
let _span = tracing::trace_span!("aggregation update queue").entered();
loop { loop {
ctx.operation_suspend_point(&self); ctx.operation_suspend_point(&self);
if self.process(ctx) { if self.process(ctx) {
......
...@@ -4,13 +4,16 @@ use serde::{Deserialize, Serialize}; ...@@ -4,13 +4,16 @@ use serde::{Deserialize, Serialize};
use turbo_tasks::TaskId; use turbo_tasks::TaskId;
use crate::{ use crate::{
backend::operation::{ backend::{
aggregation_update::{ operation::{
get_aggregation_number, get_uppers, is_aggregating_node, AggregationUpdateJob, aggregation_update::{
AggregationUpdateQueue, get_aggregation_number, get_uppers, is_aggregating_node, AggregationUpdateJob,
AggregationUpdateQueue,
},
invalidate::make_task_dirty,
ExecuteContext, Operation,
}, },
invalidate::make_task_dirty, TaskDataCategory,
ExecuteContext, Operation,
}, },
data::{CachedDataItemKey, CellRef}, data::{CachedDataItemKey, CellRef},
}; };
...@@ -43,7 +46,7 @@ impl CleanupOldEdgesOperation { ...@@ -43,7 +46,7 @@ impl CleanupOldEdgesOperation {
task_id: TaskId, task_id: TaskId,
outdated: Vec<OutdatedEdge>, outdated: Vec<OutdatedEdge>,
data_update: Option<AggregationUpdateJob>, data_update: Option<AggregationUpdateJob>,
ctx: ExecuteContext<'_>, mut ctx: ExecuteContext<'_>,
) { ) {
let mut queue = AggregationUpdateQueue::new(); let mut queue = AggregationUpdateQueue::new();
queue.extend(data_update); queue.extend(data_update);
...@@ -52,12 +55,12 @@ impl CleanupOldEdgesOperation { ...@@ -52,12 +55,12 @@ impl CleanupOldEdgesOperation {
outdated, outdated,
queue, queue,
} }
.execute(&ctx); .execute(&mut ctx);
} }
} }
impl Operation for CleanupOldEdgesOperation { impl Operation for CleanupOldEdgesOperation {
fn execute(mut self, ctx: &ExecuteContext<'_>) { fn execute(mut self, ctx: &mut ExecuteContext<'_>) {
loop { loop {
ctx.operation_suspend_point(&self); ctx.operation_suspend_point(&self);
match self { match self {
...@@ -69,7 +72,7 @@ impl Operation for CleanupOldEdgesOperation { ...@@ -69,7 +72,7 @@ impl Operation for CleanupOldEdgesOperation {
if let Some(edge) = outdated.pop() { if let Some(edge) = outdated.pop() {
match edge { match edge {
OutdatedEdge::Child(child_id) => { OutdatedEdge::Child(child_id) => {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::All);
task.remove(&CachedDataItemKey::Child { task: child_id }); task.remove(&CachedDataItemKey::Child { task: child_id });
if is_aggregating_node(get_aggregation_number(&task)) { if is_aggregating_node(get_aggregation_number(&task)) {
queue.push(AggregationUpdateJob::InnerLostFollower { queue.push(AggregationUpdateJob::InnerLostFollower {
...@@ -89,14 +92,14 @@ impl Operation for CleanupOldEdgesOperation { ...@@ -89,14 +92,14 @@ impl Operation for CleanupOldEdgesOperation {
cell, cell,
}) => { }) => {
{ {
let mut task = ctx.task(cell_task_id); let mut task = ctx.task(cell_task_id, TaskDataCategory::Data);
task.remove(&CachedDataItemKey::CellDependent { task.remove(&CachedDataItemKey::CellDependent {
cell, cell,
task: task_id, task: task_id,
}); });
} }
{ {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::Data);
task.remove(&CachedDataItemKey::CellDependency { task.remove(&CachedDataItemKey::CellDependency {
target: CellRef { target: CellRef {
task: cell_task_id, task: cell_task_id,
...@@ -107,13 +110,13 @@ impl Operation for CleanupOldEdgesOperation { ...@@ -107,13 +110,13 @@ impl Operation for CleanupOldEdgesOperation {
} }
OutdatedEdge::OutputDependency(output_task_id) => { OutdatedEdge::OutputDependency(output_task_id) => {
{ {
let mut task = ctx.task(output_task_id); let mut task = ctx.task(output_task_id, TaskDataCategory::Data);
task.remove(&CachedDataItemKey::OutputDependent { task.remove(&CachedDataItemKey::OutputDependent {
task: task_id, task: task_id,
}); });
} }
{ {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::Data);
task.remove(&CachedDataItemKey::OutputDependency { task.remove(&CachedDataItemKey::OutputDependency {
target: output_task_id, target: output_task_id,
}); });
......
...@@ -12,6 +12,7 @@ use crate::{ ...@@ -12,6 +12,7 @@ use crate::{
is_root_node, ExecuteContext, Operation, is_root_node, ExecuteContext, Operation,
}, },
storage::get, storage::get,
TaskDataCategory,
}, },
data::{CachedDataItem, CachedDataItemIndex, CachedDataItemKey}, data::{CachedDataItem, CachedDataItemIndex, CachedDataItemKey},
}; };
...@@ -28,8 +29,8 @@ pub enum ConnectChildOperation { ...@@ -28,8 +29,8 @@ pub enum ConnectChildOperation {
} }
impl ConnectChildOperation { impl ConnectChildOperation {
pub fn run(parent_task_id: TaskId, child_task_id: TaskId, ctx: ExecuteContext<'_>) { pub fn run(parent_task_id: TaskId, child_task_id: TaskId, mut ctx: ExecuteContext<'_>) {
let mut parent_task = ctx.task(parent_task_id); let mut parent_task = ctx.task(parent_task_id, TaskDataCategory::All);
parent_task.remove(&CachedDataItemKey::OutdatedChild { parent_task.remove(&CachedDataItemKey::OutdatedChild {
task: child_task_id, task: child_task_id,
}); });
...@@ -108,7 +109,7 @@ impl ConnectChildOperation { ...@@ -108,7 +109,7 @@ impl ConnectChildOperation {
drop(parent_task); drop(parent_task);
{ {
let mut task = ctx.task(child_task_id); let mut task = ctx.task(child_task_id, TaskDataCategory::Data);
should_schedule = should_schedule || !task.has_key(&CachedDataItemKey::Output {}); should_schedule = should_schedule || !task.has_key(&CachedDataItemKey::Output {});
if should_schedule { if should_schedule {
let description = ctx.backend.get_task_desc_fn(child_task_id); let description = ctx.backend.get_task_desc_fn(child_task_id);
...@@ -122,13 +123,13 @@ impl ConnectChildOperation { ...@@ -122,13 +123,13 @@ impl ConnectChildOperation {
ConnectChildOperation::UpdateAggregation { ConnectChildOperation::UpdateAggregation {
aggregation_update: queue, aggregation_update: queue,
} }
.execute(&ctx); .execute(&mut ctx);
} }
} }
} }
impl Operation for ConnectChildOperation { impl Operation for ConnectChildOperation {
fn execute(mut self, ctx: &ExecuteContext<'_>) { fn execute(mut self, ctx: &mut ExecuteContext<'_>) {
loop { loop {
ctx.operation_suspend_point(&self); ctx.operation_suspend_point(&self);
match self { match self {
......
...@@ -11,6 +11,7 @@ use crate::{ ...@@ -11,6 +11,7 @@ use crate::{
ExecuteContext, Operation, ExecuteContext, Operation,
}, },
storage::get, storage::get,
TaskDataCategory,
}, },
data::{CachedDataItem, CachedDataItemKey}, data::{CachedDataItem, CachedDataItemKey},
}; };
...@@ -30,13 +31,13 @@ pub enum InvalidateOperation { ...@@ -30,13 +31,13 @@ pub enum InvalidateOperation {
} }
impl InvalidateOperation { impl InvalidateOperation {
pub fn run(task_ids: SmallVec<[TaskId; 4]>, ctx: ExecuteContext<'_>) { pub fn run(task_ids: SmallVec<[TaskId; 4]>, mut ctx: ExecuteContext<'_>) {
InvalidateOperation::MakeDirty { task_ids }.execute(&ctx) InvalidateOperation::MakeDirty { task_ids }.execute(&mut ctx)
} }
} }
impl Operation for InvalidateOperation { impl Operation for InvalidateOperation {
fn execute(mut self, ctx: &ExecuteContext<'_>) { fn execute(mut self, ctx: &mut ExecuteContext<'_>) {
loop { loop {
ctx.operation_suspend_point(&self); ctx.operation_suspend_point(&self);
match self { match self {
...@@ -65,12 +66,16 @@ impl Operation for InvalidateOperation { ...@@ -65,12 +66,16 @@ impl Operation for InvalidateOperation {
} }
} }
pub fn make_task_dirty(task_id: TaskId, queue: &mut AggregationUpdateQueue, ctx: &ExecuteContext) { pub fn make_task_dirty(
task_id: TaskId,
queue: &mut AggregationUpdateQueue,
ctx: &mut ExecuteContext,
) {
if ctx.is_once_task(task_id) { if ctx.is_once_task(task_id) {
return; return;
} }
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::All);
if task.add(CachedDataItem::Dirty { value: () }) { if task.add(CachedDataItem::Dirty { value: () }) {
let dirty_container = get!(task, AggregatedDirtyContainerCount) let dirty_container = get!(task, AggregatedDirtyContainerCount)
......
...@@ -4,6 +4,7 @@ use crate::{ ...@@ -4,6 +4,7 @@ use crate::{
backend::{ backend::{
operation::{ExecuteContext, InvalidateOperation}, operation::{ExecuteContext, InvalidateOperation},
storage::{get_many, remove}, storage::{get_many, remove},
TaskDataCategory,
}, },
data::{CachedDataItem, CachedDataItemKey}, data::{CachedDataItem, CachedDataItemKey},
}; };
...@@ -11,12 +12,12 @@ use crate::{ ...@@ -11,12 +12,12 @@ use crate::{
pub struct UpdateCellOperation; pub struct UpdateCellOperation;
impl UpdateCellOperation { impl UpdateCellOperation {
pub fn run(task: TaskId, cell: CellId, content: CellContent, ctx: ExecuteContext<'_>) { pub fn run(task_id: TaskId, cell: CellId, content: CellContent, mut ctx: ExecuteContext<'_>) {
let mut task = ctx.task(task); let mut task = ctx.task(task_id, TaskDataCategory::All);
let old_content = if let CellContent(Some(new_content)) = content { let old_content = if let CellContent(Some(new_content)) = content {
task.insert(CachedDataItem::CellData { task.insert(CachedDataItem::CellData {
cell, cell,
value: new_content, value: new_content.into_typed(cell.type_id),
}) })
} else { } else {
task.remove(&CachedDataItemKey::CellData { cell }) task.remove(&CachedDataItemKey::CellData { cell })
......
...@@ -7,6 +7,7 @@ use crate::{ ...@@ -7,6 +7,7 @@ use crate::{
backend::{ backend::{
operation::{ExecuteContext, InvalidateOperation}, operation::{ExecuteContext, InvalidateOperation},
storage::get_many, storage::get_many,
TaskDataCategory,
}, },
data::{CachedDataItem, CachedDataItemKey, CachedDataItemValue, CellRef, OutputValue}, data::{CachedDataItem, CachedDataItemKey, CachedDataItemValue, CellRef, OutputValue},
}; };
...@@ -17,9 +18,9 @@ impl UpdateOutputOperation { ...@@ -17,9 +18,9 @@ impl UpdateOutputOperation {
pub fn run( pub fn run(
task_id: TaskId, task_id: TaskId,
output: Result<Result<RawVc>, Option<Cow<'static, str>>>, output: Result<Result<RawVc>, Option<Cow<'static, str>>>,
ctx: ExecuteContext<'_>, mut ctx: ExecuteContext<'_>,
) { ) {
let mut task = ctx.task(task_id); let mut task = ctx.task(task_id, TaskDataCategory::Data);
let old_error = task.remove(&CachedDataItemKey::Error {}); let old_error = task.remove(&CachedDataItemKey::Error {});
let current_output = task.get(&CachedDataItemKey::Output {}); let current_output = task.get(&CachedDataItemKey::Output {});
let output_value = match output { let output_value = match output {
......
...@@ -16,6 +16,107 @@ use crate::{ ...@@ -16,6 +16,107 @@ use crate::{
utils::dash_map_multi::{get_multiple_mut, RefMut}, utils::dash_map_multi::{get_multiple_mut, RefMut},
}; };
const META_UNRESTORED: u32 = 1 << 31;
const DATA_UNRESTORED: u32 = 1 << 30;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TaskDataCategory {
Meta,
Data,
All,
}
impl TaskDataCategory {
pub fn flag(&self) -> u32 {
match self {
TaskDataCategory::Meta => META_UNRESTORED,
TaskDataCategory::Data => DATA_UNRESTORED,
TaskDataCategory::All => META_UNRESTORED | DATA_UNRESTORED,
}
}
}
impl IntoIterator for TaskDataCategory {
type Item = TaskDataCategory;
type IntoIter = TaskDataCategoryIterator;
fn into_iter(self) -> Self::IntoIter {
match self {
TaskDataCategory::Meta => TaskDataCategoryIterator::Meta,
TaskDataCategory::Data => TaskDataCategoryIterator::Data,
TaskDataCategory::All => TaskDataCategoryIterator::All,
}
}
}
pub enum TaskDataCategoryIterator {
All,
Meta,
Data,
None,
}
impl Iterator for TaskDataCategoryIterator {
type Item = TaskDataCategory;
fn next(&mut self) -> Option<Self::Item> {
match self {
TaskDataCategoryIterator::All => {
*self = TaskDataCategoryIterator::Data;
Some(TaskDataCategory::Meta)
}
TaskDataCategoryIterator::Meta => {
*self = TaskDataCategoryIterator::None;
Some(TaskDataCategory::Meta)
}
TaskDataCategoryIterator::Data => {
*self = TaskDataCategoryIterator::None;
Some(TaskDataCategory::Data)
}
TaskDataCategoryIterator::None => None,
}
}
}
pub struct PersistanceState {
value: u32,
}
impl Default for PersistanceState {
fn default() -> Self {
Self {
value: META_UNRESTORED | DATA_UNRESTORED,
}
}
}
impl PersistanceState {
pub fn set_restored(&mut self, category: TaskDataCategory) {
self.value &= !category.flag();
}
pub fn add_persisting_item(&mut self) {
self.value += 1;
}
pub fn add_persisting_items(&mut self, count: u32) {
self.value += count;
}
pub fn finish_persisting_items(&mut self, count: u32) {
self.value -= count;
}
pub fn is_restored(&self, category: TaskDataCategory) -> bool {
self.value & category.flag() == 0
}
pub fn is_fully_persisted(&self) -> bool {
self.value & !TaskDataCategory::All.flag() == 0
}
}
const INDEX_THRESHOLD: usize = 1024; const INDEX_THRESHOLD: usize = 1024;
type IndexedMap<T> = AutoMap< type IndexedMap<T> = AutoMap<
...@@ -27,8 +128,14 @@ pub enum InnerStorage<T: KeyValuePair> ...@@ -27,8 +128,14 @@ pub enum InnerStorage<T: KeyValuePair>
where where
T::Key: Indexed, T::Key: Indexed,
{ {
Plain { map: AutoMap<T::Key, T::Value> }, Plain {
Indexed { map: IndexedMap<T> }, map: AutoMap<T::Key, T::Value>,
persistance_state: PersistanceState,
},
Indexed {
map: IndexedMap<T>,
persistance_state: PersistanceState,
},
} }
impl<T: KeyValuePair> InnerStorage<T> impl<T: KeyValuePair> InnerStorage<T>
...@@ -38,11 +145,38 @@ where ...@@ -38,11 +145,38 @@ where
fn new() -> Self { fn new() -> Self {
Self::Plain { Self::Plain {
map: AutoMap::new(), map: AutoMap::new(),
persistance_state: PersistanceState::default(),
}
}
pub fn persistance_state(&self) -> &PersistanceState {
match self {
InnerStorage::Plain {
persistance_state, ..
} => persistance_state,
InnerStorage::Indexed {
persistance_state, ..
} => persistance_state,
}
}
pub fn persistance_state_mut(&mut self) -> &mut PersistanceState {
match self {
InnerStorage::Plain {
persistance_state, ..
} => persistance_state,
InnerStorage::Indexed {
persistance_state, ..
} => persistance_state,
} }
} }
fn check_threshold(&mut self) { fn check_threshold(&mut self) {
let InnerStorage::Plain { map: plain_map } = self else { let InnerStorage::Plain {
map: plain_map,
persistance_state,
} = self
else {
return; return;
}; };
if plain_map.len() >= INDEX_THRESHOLD { if plain_map.len() >= INDEX_THRESHOLD {
...@@ -51,7 +185,10 @@ where ...@@ -51,7 +185,10 @@ where
let index = key.index(); let index = key.index();
map.entry(index).or_default().insert(key, value); map.entry(index).or_default().insert(key, value);
} }
*self = InnerStorage::Indexed { map }; *self = InnerStorage::Indexed {
map,
persistance_state: take(persistance_state),
};
} }
} }
......
use std::sync::Arc;
use anyhow::Result;
use turbo_tasks::{backend::CachedTaskType, TaskId};
use crate::{
backend::{AnyOperation, TaskDataCategory},
data::{CachedDataItem, CachedDataUpdate},
utils::chunked_vec::ChunkedVec,
};
#[derive(Clone, Copy)]
pub struct ReadTransaction(pub *const ());
pub trait BackingStorage {
fn next_free_task_id(&self) -> TaskId;
fn uncompleted_operations(&self) -> Vec<AnyOperation>;
fn save_snapshot(
&self,
operations: Vec<Arc<AnyOperation>>,
task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
meta_updates: Vec<ChunkedVec<CachedDataUpdate>>,
data_updates: Vec<ChunkedVec<CachedDataUpdate>>,
) -> Result<()>;
fn start_read_transaction(&self) -> Option<ReadTransaction>;
/// # Safety
///
/// `tx` must be a transaction from this BackingStorage instance.
unsafe fn end_read_transaction(&self, tx: ReadTransaction);
/// # Safety
///
/// `tx` must be a transaction from this BackingStorage instance.
unsafe fn forward_lookup_task_cache(
&self,
tx: Option<ReadTransaction>,
key: &CachedTaskType,
) -> Option<TaskId>;
/// # Safety
///
/// `tx` must be a transaction from this BackingStorage instance.
unsafe fn reverse_lookup_task_cache(
&self,
tx: Option<ReadTransaction>,
task_id: TaskId,
) -> Option<Arc<CachedTaskType>>;
/// # Safety
///
/// `tx` must be a transaction from this BackingStorage instance.
unsafe fn lookup_data(
&self,
tx: Option<ReadTransaction>,
task_id: TaskId,
category: TaskDataCategory,
) -> Vec<CachedDataItem>;
}
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbo_tasks::{ use turbo_tasks::{
event::{Event, EventListener}, event::{Event, EventListener},
registry,
util::SharedError, util::SharedError,
CellId, KeyValuePair, SharedReference, TaskId, ValueTypeId, CellId, KeyValuePair, TaskId, TypedSharedReference, ValueTypeId,
}; };
use crate::backend::indexed::Indexed; use crate::backend::{indexed::Indexed, TaskDataCategory};
// this traits are needed for the transient variants of `CachedDataItem`
// transient variants are never cloned or compared
macro_rules! transient_traits {
($name:ident) => {
impl Clone for $name {
fn clone(&self) -> Self {
// this impl is needed for the transient variants of `CachedDataItem`
// transient variants are never cloned
panic!(concat!(stringify!($name), " cannot be cloned"));
}
}
impl PartialEq for $name {
fn eq(&self, _other: &Self) -> bool {
panic!(concat!(stringify!($name), " cannot be compared"));
}
}
};
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct CellRef { pub struct CellRef {
...@@ -52,6 +73,10 @@ impl RootState { ...@@ -52,6 +73,10 @@ impl RootState {
} }
} }
transient_traits!(RootState);
impl Eq for RootState {}
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub enum ActiveType { pub enum ActiveType {
RootTask, RootTask,
...@@ -62,12 +87,6 @@ pub enum ActiveType { ...@@ -62,12 +87,6 @@ pub enum ActiveType {
CachedActiveUntilClean, CachedActiveUntilClean,
} }
impl Clone for RootState {
fn clone(&self) -> Self {
panic!("RootState cannot be cloned");
}
}
#[derive(Debug)] #[derive(Debug)]
pub enum InProgressState { pub enum InProgressState {
Scheduled { Scheduled {
...@@ -81,22 +100,18 @@ pub enum InProgressState { ...@@ -81,22 +100,18 @@ pub enum InProgressState {
}, },
} }
impl Clone for InProgressState { transient_traits!(InProgressState);
fn clone(&self) -> Self {
panic!("InProgressState cannot be cloned"); impl Eq for InProgressState {}
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct InProgressCellState { pub struct InProgressCellState {
pub event: Event, pub event: Event,
} }
impl Clone for InProgressCellState { transient_traits!(InProgressCellState);
fn clone(&self) -> Self {
panic!("InProgressCell cannot be cloned"); impl Eq for InProgressCellState {}
}
}
impl InProgressCellState { impl InProgressCellState {
pub fn new(task_id: TaskId, cell: CellId) -> Self { pub fn new(task_id: TaskId, cell: CellId) -> Self {
...@@ -108,14 +123,14 @@ impl InProgressCellState { ...@@ -108,14 +123,14 @@ impl InProgressCellState {
} }
} }
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct AggregationNumber { pub struct AggregationNumber {
pub base: u32, pub base: u32,
pub distance: u32, pub distance: u32,
pub effective: u32, pub effective: u32,
} }
#[derive(Debug, Clone, KeyValuePair)] #[derive(Debug, Clone, KeyValuePair, Serialize, Deserialize)]
pub enum CachedDataItem { pub enum CachedDataItem {
// Output // Output
Output { Output {
...@@ -143,7 +158,7 @@ pub enum CachedDataItem { ...@@ -143,7 +158,7 @@ pub enum CachedDataItem {
// Cells // Cells
CellData { CellData {
cell: CellId, cell: CellId,
value: SharedReference, value: TypedSharedReference,
}, },
CellTypeMaxIndex { CellTypeMaxIndex {
cell_type: ValueTypeId, cell_type: ValueTypeId,
...@@ -207,14 +222,17 @@ pub enum CachedDataItem { ...@@ -207,14 +222,17 @@ pub enum CachedDataItem {
}, },
// Transient Root Type // Transient Root Type
#[serde(skip)]
AggregateRoot { AggregateRoot {
value: RootState, value: RootState,
}, },
// Transient In Progress state // Transient In Progress state
#[serde(skip)]
InProgress { InProgress {
value: InProgressState, value: InProgressState,
}, },
#[serde(skip)]
InProgressCell { InProgressCell {
cell: CellId, cell: CellId,
value: InProgressCellState, value: InProgressCellState,
...@@ -237,6 +255,7 @@ pub enum CachedDataItem { ...@@ -237,6 +255,7 @@ pub enum CachedDataItem {
}, },
// Transient Error State // Transient Error State
#[serde(skip)]
Error { Error {
value: SharedError, value: SharedError,
}, },
...@@ -277,6 +296,10 @@ impl CachedDataItem { ...@@ -277,6 +296,10 @@ impl CachedDataItem {
} }
} }
pub fn is_optional(&self) -> bool {
matches!(self, CachedDataItem::CellData { .. })
}
pub fn new_scheduled(description: impl Fn() -> String + Sync + Send + 'static) -> Self { pub fn new_scheduled(description: impl Fn() -> String + Sync + Send + 'static) -> Self {
CachedDataItem::InProgress { CachedDataItem::InProgress {
value: InProgressState::Scheduled { value: InProgressState::Scheduled {
...@@ -334,6 +357,39 @@ impl CachedDataItemKey { ...@@ -334,6 +357,39 @@ impl CachedDataItemKey {
CachedDataItemKey::Error { .. } => false, CachedDataItemKey::Error { .. } => false,
} }
} }
pub fn category(&self) -> TaskDataCategory {
match self {
CachedDataItemKey::Output { .. }
| CachedDataItemKey::Collectible { .. }
| CachedDataItemKey::Child { .. }
| CachedDataItemKey::CellData { .. }
| CachedDataItemKey::CellTypeMaxIndex { .. }
| CachedDataItemKey::OutputDependency { .. }
| CachedDataItemKey::CellDependency { .. }
| CachedDataItemKey::CollectiblesDependency { .. }
| CachedDataItemKey::OutputDependent { .. }
| CachedDataItemKey::CellDependent { .. }
| CachedDataItemKey::CollectiblesDependent { .. }
| CachedDataItemKey::InProgress { .. }
| CachedDataItemKey::InProgressCell { .. }
| CachedDataItemKey::OutdatedCollectible { .. }
| CachedDataItemKey::OutdatedOutputDependency { .. }
| CachedDataItemKey::OutdatedCellDependency { .. }
| CachedDataItemKey::OutdatedChild { .. }
| CachedDataItemKey::Error { .. } => TaskDataCategory::Data,
CachedDataItemKey::AggregationNumber { .. }
| CachedDataItemKey::Dirty { .. }
| CachedDataItemKey::DirtyWhenPersisted { .. }
| CachedDataItemKey::Follower { .. }
| CachedDataItemKey::Upper { .. }
| CachedDataItemKey::AggregatedDirtyContainer { .. }
| CachedDataItemKey::AggregatedCollectible { .. }
| CachedDataItemKey::AggregatedDirtyContainerCount { .. }
| CachedDataItemKey::AggregateRoot { .. } => TaskDataCategory::Meta,
}
}
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
...@@ -404,6 +460,9 @@ impl CachedDataItemValue { ...@@ -404,6 +460,9 @@ impl CachedDataItemValue {
pub fn is_persistent(&self) -> bool { pub fn is_persistent(&self) -> bool {
match self { match self {
CachedDataItemValue::Output { value } => !value.is_transient(), CachedDataItemValue::Output { value } => !value.is_transient(),
CachedDataItemValue::CellData { value } => {
registry::get_value_type(value.0).is_serializable()
}
_ => true, _ => true,
} }
} }
...@@ -411,11 +470,8 @@ impl CachedDataItemValue { ...@@ -411,11 +470,8 @@ impl CachedDataItemValue {
#[derive(Debug)] #[derive(Debug)]
pub struct CachedDataUpdate { pub struct CachedDataUpdate {
// TODO persistence
#[allow(dead_code)]
pub task: TaskId, pub task: TaskId,
#[allow(dead_code)]
pub key: CachedDataItemKey, pub key: CachedDataItemKey,
#[allow(dead_code)]
pub value: Option<CachedDataItemValue>, pub value: Option<CachedDataItemValue>,
pub old_value: Option<CachedDataItemValue>,
} }
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
#![allow(dead_code)] #![allow(dead_code)]
mod backend; mod backend;
mod backing_storage;
mod data; mod data;
mod lmdb_backing_storage;
mod utils; mod utils;
pub use self::backend::TurboTasksBackend; pub use self::{backend::TurboTasksBackend, lmdb_backing_storage::LmdbBackingStorage};
use std::hash::{Hash, Hasher};
use byteorder::ByteOrder;
use lmdb::{Database, RoTransaction, RwTransaction, Transaction, WriteFlags};
use rustc_hash::FxHasher;
const MAX_KEY_SIZE: usize = 511;
const SHARED_KEY: usize = MAX_KEY_SIZE - 8;
pub fn get<'tx>(
tx: &'tx RoTransaction<'tx>,
database: Database,
key: &[u8],
) -> lmdb::Result<&'tx [u8]> {
if key.len() > MAX_KEY_SIZE - 1 {
let hashed_key = hashed_key(key);
let data = tx.get(database, &hashed_key)?;
let iter = ExtendedValueIter::new(data);
for (k, v) in iter {
if k == key {
return Ok(v);
}
}
Err(lmdb::Error::NotFound)
} else {
tx.get(database, &key)
}
}
pub fn put(
tx: &mut RwTransaction<'_>,
database: Database,
key: &[u8],
value: &[u8],
flags: WriteFlags,
) -> lmdb::Result<()> {
if key.len() > MAX_KEY_SIZE - 1 {
let hashed_key = hashed_key(key);
let size = key.len() - SHARED_KEY + value.len() + 8;
let old = tx.get(database, &hashed_key);
let old_size = old.map_or(0, |v| v.len());
let mut data = Vec::with_capacity(old_size + size);
data.extend_from_slice(&((key.len() - SHARED_KEY) as u32).to_be_bytes());
data.extend_from_slice(&(value.len() as u32).to_be_bytes());
data.extend_from_slice(&key[SHARED_KEY..]);
data.extend_from_slice(value);
if let Ok(old) = old {
let iter = ExtendedValueIter::new(old);
for (k, v) in iter {
if k != &key[SHARED_KEY..] {
data.extend_from_slice(&(k.len() as u32).to_be_bytes());
data.extend_from_slice(&(v.len() as u32).to_be_bytes());
data.extend_from_slice(k);
data.extend_from_slice(v);
}
}
};
tx.put(database, &hashed_key, &data, flags)?;
Ok(())
} else {
tx.put(database, &key, &value, flags)
}
}
fn hashed_key(key: &[u8]) -> [u8; MAX_KEY_SIZE] {
let mut result = [0; MAX_KEY_SIZE];
let mut hash = FxHasher::default();
key.hash(&mut hash);
byteorder::BigEndian::write_u64(&mut result, hash.finish());
result[8..].copy_from_slice(&key[0..SHARED_KEY]);
result
}
struct ExtendedValueIter<'a> {
data: &'a [u8],
pos: usize,
}
impl<'a> Iterator for ExtendedValueIter<'a> {
type Item = (&'a [u8], &'a [u8]);
fn next(&mut self) -> Option<Self::Item> {
if self.pos >= self.data.len() {
return None;
}
let key_len = byteorder::BigEndian::read_u32(&self.data[self.pos..]) as usize;
self.pos += 4;
let value_len = byteorder::BigEndian::read_u32(&self.data[self.pos..]) as usize;
self.pos += 4;
let key = &self.data[self.pos..self.pos + key_len];
self.pos += key_len;
let value = &self.data[self.pos..self.pos + value_len];
self.pos += value_len;
Some((key, value))
}
}
impl<'a> ExtendedValueIter<'a> {
fn new(data: &'a [u8]) -> Self {
Self { data, pos: 0 }
}
}
...@@ -2,18 +2,25 @@ pub struct ChunkedVec<T> { ...@@ -2,18 +2,25 @@ pub struct ChunkedVec<T> {
chunks: Vec<Vec<T>>, chunks: Vec<Vec<T>>,
} }
impl<T> Default for ChunkedVec<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> ChunkedVec<T> { impl<T> ChunkedVec<T> {
pub fn new() -> Self { pub fn new() -> Self {
Self { chunks: Vec::new() } Self { chunks: Vec::new() }
} }
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
if let Some(last) = self.chunks.last() { for (i, chunk) in self.chunks.iter().enumerate().rev() {
let free = last.capacity() - self.len(); if !chunk.is_empty() {
cummulative_chunk_size(self.chunks.len() - 1) - free let free = chunk.capacity() - chunk.len();
} else { return cummulative_chunk_size(i) - free;
0 }
} }
0
} }
pub fn push(&mut self, item: T) { pub fn push(&mut self, item: T) {
...@@ -28,11 +35,9 @@ impl<T> ChunkedVec<T> { ...@@ -28,11 +35,9 @@ impl<T> ChunkedVec<T> {
self.chunks.push(chunk); self.chunks.push(chunk);
} }
pub fn into_iter(self) -> impl Iterator<Item = T> { pub fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
let len = self.len(); for item in iter {
ExactSizeIter { self.push(item);
iter: self.chunks.into_iter().flat_map(|chunk| chunk.into_iter()),
len,
} }
} }
...@@ -42,6 +47,31 @@ impl<T> ChunkedVec<T> { ...@@ -42,6 +47,31 @@ impl<T> ChunkedVec<T> {
len: self.len(), len: self.len(),
} }
} }
pub fn is_empty(&self) -> bool {
self.chunks.first().map_or(true, |chunk| chunk.is_empty())
}
}
impl<T> IntoIterator for ChunkedVec<T> {
type Item = T;
type IntoIter = ExactSizeIter<std::iter::Flatten<std::vec::IntoIter<Vec<T>>>>;
fn into_iter(self) -> Self::IntoIter {
let len = self.len();
ExactSizeIter {
iter: self.chunks.into_iter().flatten(),
len,
}
}
}
impl<T> Extend<T> for ChunkedVec<T> {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
for item in iter {
self.push(item);
}
}
} }
fn chunk_size(chunk_index: usize) -> usize { fn chunk_size(chunk_index: usize) -> usize {
...@@ -52,7 +82,7 @@ fn cummulative_chunk_size(chunk_index: usize) -> usize { ...@@ -52,7 +82,7 @@ fn cummulative_chunk_size(chunk_index: usize) -> usize {
(8 << (chunk_index + 1)) - 8 (8 << (chunk_index + 1)) - 8
} }
struct ExactSizeIter<I: Iterator> { pub struct ExactSizeIter<I: Iterator> {
iter: I, iter: I,
len: usize, len: usize,
} }
......
...@@ -2,3 +2,4 @@ pub mod bi_map; ...@@ -2,3 +2,4 @@ pub mod bi_map;
pub mod chunked_vec; pub mod chunked_vec;
pub mod dash_map_multi; pub mod dash_map_multi;
pub mod ptr_eq_arc; pub mod ptr_eq_arc;
pub mod sharded;
...@@ -10,6 +10,10 @@ impl<T> PtrEqArc<T> { ...@@ -10,6 +10,10 @@ impl<T> PtrEqArc<T> {
pub fn new(value: T) -> Self { pub fn new(value: T) -> Self {
Self(Arc::new(value)) Self(Arc::new(value))
} }
pub fn arc(&self) -> &Arc<T> {
&self.0
}
} }
impl<T> From<Arc<T>> for PtrEqArc<T> { impl<T> From<Arc<T>> for PtrEqArc<T> {
......
use std::hash::{BuildHasher, BuildHasherDefault, Hash};
use parking_lot::{Mutex, MutexGuard};
use rustc_hash::FxHasher;
pub struct Sharded<T, H = BuildHasherDefault<FxHasher>> {
data: Box<[Mutex<T>]>,
hasher: H,
bitmask: u16,
}
impl<T, H> Sharded<T, H> {
pub fn new(mut shard_amount: usize) -> Self
where
T: Default,
H: Default,
{
assert!(shard_amount.is_power_of_two());
shard_amount = shard_amount.min(u16::MAX as usize + 1);
let data = (0..shard_amount)
.map(|_| Mutex::new(T::default()))
.collect::<Vec<_>>()
.into_boxed_slice();
Self {
data,
hasher: H::default(),
bitmask: (shard_amount - 1) as u16,
}
}
pub fn lock<K>(&self, key: K) -> MutexGuard<'_, T>
where
K: Hash,
H: BuildHasher,
{
let hash = self.hasher.hash_one(key);
let shard = hash as u16 & self.bitmask;
self.data[shard as usize].lock()
}
pub fn take(&self) -> Vec<T>
where
T: Default,
{
let locked = self.data.iter().map(|m| m.lock()).collect::<Vec<_>>();
locked
.into_iter()
.map(|mut m| std::mem::take(&mut *m))
.collect()
}
}
|_name, _initial| { |name, initial| {
turbo_tasks::TurboTasks::new(turbo_tasks_backend::TurboTasksBackend::new()) let path = std::path::PathBuf::from(format!(concat!(
env!("OUT_DIR"),
"/.cache/{}",
), name));
if initial {
let _ = std::fs::remove_dir_all(&path);
}
std::fs::create_dir_all(&path).unwrap();
turbo_tasks::TurboTasks::new(
turbo_tasks_backend::TurboTasksBackend::new(
Arc::new(turbo_tasks_backend::LmdbBackingStorage::new(
path.as_path()
).unwrap())
)
)
} }
...@@ -106,7 +106,7 @@ pub fn derive_key_value_pair(input: TokenStream) -> TokenStream { ...@@ -106,7 +106,7 @@ pub fn derive_key_value_pair(input: TokenStream) -> TokenStream {
)* )*
} }
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default, PartialEq, Eq)]
#vis enum #value_name { #vis enum #value_name {
#( #(
#variant_names { #variant_names {
......
...@@ -15,9 +15,12 @@ async fn basic() { ...@@ -15,9 +15,12 @@ async fn basic() {
assert_eq!(output1.await?.value, 123); assert_eq!(output1.await?.value, 123);
let input = Value { value: 42 }.cell(); let input = Value { value: 42 }.cell();
let output2 = func(input); let output2 = func_transient(input);
assert_eq!(output2.await?.value, 42); assert_eq!(output2.await?.value, 42);
let output3 = func_persistent(output1);
assert_eq!(output3.await?.value, 123);
anyhow::Ok(()) anyhow::Ok(())
}) })
.await .await
...@@ -30,13 +33,22 @@ struct Value { ...@@ -30,13 +33,22 @@ struct Value {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn func(input: Vc<Value>) -> Result<Vc<Value>> { async fn func_transient(input: Vc<Value>) -> Result<Vc<Value>> {
println!("func_transient");
let value = input.await?.value;
Ok(Value { value }.cell())
}
#[turbo_tasks::function]
async fn func_persistent(input: Vc<Value>) -> Result<Vc<Value>> {
println!("func_persistent");
let value = input.await?.value; let value = input.await?.value;
Ok(Value { value }.cell()) Ok(Value { value }.cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn func_without_args() -> Result<Vc<Value>> { async fn func_without_args() -> Result<Vc<Value>> {
println!("func_without_args");
let value = 123; let value = 123;
Ok(Value { value }.cell()) Ok(Value { value }.cell())
} }
...@@ -30,6 +30,7 @@ mopa = "0.2.0" ...@@ -30,6 +30,7 @@ mopa = "0.2.0"
once_cell = { workspace = true } once_cell = { workspace = true }
parking_lot = { workspace = true, features = ["serde"]} parking_lot = { workspace = true, features = ["serde"]}
pin-project-lite = { workspace = true } pin-project-lite = { workspace = true }
rayon = { workspace = true }
regex = { workspace = true } regex = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
serde = { workspace = true, features = ["rc", "derive"] } serde = { workspace = true, features = ["rc", "derive"] }
......
...@@ -529,9 +529,13 @@ pub trait Backend: Sync + Send { ...@@ -529,9 +529,13 @@ pub trait Backend: Sync + Send {
#[allow(unused_variables)] #[allow(unused_variables)]
fn stop(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {} fn stop(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {}
#[allow(unused_variables)]
fn stopping(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {}
#[allow(unused_variables)] #[allow(unused_variables)]
fn idle_start(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {} fn idle_start(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {}
#[allow(unused_variables)]
fn idle_end(&self, turbo_tasks: &dyn TurboTasksBackendApi<Self>) {}
fn invalidate_task(&self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>); fn invalidate_task(&self, task: TaskId, turbo_tasks: &dyn TurboTasksBackendApi<Self>);
......
...@@ -39,11 +39,11 @@ impl<T, F: Future<Output = T>> CaptureFuture<T, F> { ...@@ -39,11 +39,11 @@ impl<T, F: Future<Output = T>> CaptureFuture<T, F> {
} }
pub fn add_duration(duration: Duration) { pub fn add_duration(duration: Duration) {
EXTRA.with(|cell| cell.lock().unwrap().0 += duration); let _ = EXTRA.try_with(|cell| cell.lock().unwrap().0 += duration);
} }
pub fn add_allocation_info(alloc_info: AllocationInfo) { pub fn add_allocation_info(alloc_info: AllocationInfo) {
EXTRA.with(|cell| { let _ = EXTRA.try_with(|cell| {
let mut guard = cell.lock().unwrap(); let mut guard = cell.lock().unwrap();
guard.1 += alloc_info.allocations; guard.1 += alloc_info.allocations;
guard.2 += alloc_info.deallocations; guard.2 += alloc_info.deallocations;
......
...@@ -30,7 +30,7 @@ macro_rules! define_id { ...@@ -30,7 +30,7 @@ macro_rules! define_id {
/// # Safety /// # Safety
/// ///
/// The passed `id` must not be zero. /// The passed `id` must not be zero.
pub unsafe fn new_unchecked(id: $primitive) -> Self { pub const unsafe fn new_unchecked(id: $primitive) -> Self {
Self { id: unsafe { NonZero::<$primitive>::new_unchecked(id) } } Self { id: unsafe { NonZero::<$primitive>::new_unchecked(id) } }
} }
} }
......
use std::fmt::Debug;
pub trait KeyValuePair { pub trait KeyValuePair {
type Key: PartialEq + Eq + std::hash::Hash; type Key: Debug + Clone + PartialEq + Eq + std::hash::Hash;
type Value; type Value: Debug + Clone + Default + PartialEq + Eq;
fn key(&self) -> Self::Key; fn key(&self) -> Self::Key;
fn value(&self) -> Self::Value; fn value(&self) -> Self::Value;
fn from_key_and_value(key: Self::Key, value: Self::Value) -> Self; fn from_key_and_value(key: Self::Key, value: Self::Value) -> Self;
......
...@@ -64,6 +64,7 @@ mod raw_vc; ...@@ -64,6 +64,7 @@ mod raw_vc;
mod rcstr; mod rcstr;
mod read_ref; mod read_ref;
pub mod registry; pub mod registry;
mod scope;
mod serialization_invalidation; mod serialization_invalidation;
pub mod small_duration; pub mod small_duration;
mod state; mod state;
...@@ -97,17 +98,19 @@ pub use magic_any::MagicAny; ...@@ -97,17 +98,19 @@ pub use magic_any::MagicAny;
pub use manager::{ pub use manager::{
dynamic_call, dynamic_this_call, emit, mark_dirty_when_persisted, mark_finished, mark_stateful, dynamic_call, dynamic_this_call, emit, mark_dirty_when_persisted, mark_finished, mark_stateful,
prevent_gc, run_once, run_once_with_reason, spawn_blocking, spawn_thread, trait_call, prevent_gc, run_once, run_once_with_reason, spawn_blocking, spawn_thread, trait_call,
turbo_tasks, CurrentCellRef, ReadConsistency, TaskPersistence, TurboTasks, TurboTasksApi, turbo_tasks, turbo_tasks_scope, CurrentCellRef, ReadConsistency, TaskPersistence, TurboTasks,
TurboTasksBackendApi, TurboTasksBackendApiExt, TurboTasksCallApi, Unused, UpdateInfo, TurboTasksApi, TurboTasksBackendApi, TurboTasksBackendApiExt, TurboTasksCallApi, Unused,
UpdateInfo,
}; };
pub use native_function::{FunctionMeta, NativeFunction}; pub use native_function::{FunctionMeta, NativeFunction};
pub use output::OutputContent; pub use output::OutputContent;
pub use raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError}; pub use raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError};
pub use read_ref::ReadRef; pub use read_ref::ReadRef;
use rustc_hash::FxHasher; use rustc_hash::FxHasher;
pub use scope::scope;
pub use serialization_invalidation::SerializationInvalidator; pub use serialization_invalidation::SerializationInvalidator;
pub use state::{State, TransientState}; pub use state::{State, TransientState};
pub use task::{task_input::TaskInput, SharedReference}; pub use task::{task_input::TaskInput, SharedReference, TypedSharedReference};
pub use trait_ref::{IntoTraitRef, TraitRef}; pub use trait_ref::{IntoTraitRef, TraitRef};
pub use turbo_tasks_macros::{function, value_impl, value_trait, KeyValuePair, TaskInput}; pub use turbo_tasks_macros::{function, value_impl, value_trait, KeyValuePair, TaskInput};
pub use value::{TransientInstance, TransientValue, Value}; pub use value::{TransientInstance, TransientValue, Value};
......
...@@ -271,6 +271,9 @@ pub trait TurboTasksBackendApi<B: Backend + 'static>: TurboTasksCallApi + Sync + ...@@ -271,6 +271,9 @@ pub trait TurboTasksBackendApi<B: Backend + 'static>: TurboTasksCallApi + Sync +
/// should prefer the extension trait's version of this method. /// should prefer the extension trait's version of this method.
fn write_task_state_dyn(&self, func: &mut dyn FnMut(&mut B::TaskState)); fn write_task_state_dyn(&self, func: &mut dyn FnMut(&mut B::TaskState));
/// Returns true if the system is idle.
fn is_idle(&self) -> bool;
/// Returns a reference to the backend. /// Returns a reference to the backend.
fn backend(&self) -> &B; fn backend(&self) -> &B;
} }
...@@ -848,6 +851,7 @@ impl<B: Backend + 'static> TurboTasks<B> { ...@@ -848,6 +851,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
{ {
*self.start.lock().unwrap() = Some(Instant::now()); *self.start.lock().unwrap() = Some(Instant::now());
self.event_start.notify(usize::MAX); self.event_start.notify(usize::MAX);
self.backend.idle_end(self);
} }
} }
...@@ -1052,6 +1056,7 @@ impl<B: Backend + 'static> TurboTasks<B> { ...@@ -1052,6 +1056,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
} }
pub async fn stop_and_wait(&self) { pub async fn stop_and_wait(&self) {
self.backend.stopping(self);
self.stopped.store(true, Ordering::Release); self.stopped.store(true, Ordering::Release);
{ {
let listener = self.event.listen_with_note(|| "wait for stop".to_string()); let listener = self.event.listen_with_note(|| "wait for stop".to_string());
...@@ -1563,6 +1568,10 @@ impl<B: Backend + 'static> TurboTasksBackendApi<B> for TurboTasks<B> { ...@@ -1563,6 +1568,10 @@ impl<B: Backend + 'static> TurboTasksBackendApi<B> for TurboTasks<B> {
CURRENT_GLOBAL_TASK_STATE CURRENT_GLOBAL_TASK_STATE
.with(move |ts| func(ts.write().unwrap().backend_state.downcast_mut().unwrap())) .with(move |ts| func(ts.write().unwrap().backend_state.downcast_mut().unwrap()))
} }
fn is_idle(&self) -> bool {
self.currently_scheduled_tasks.load(Ordering::Acquire) == 0
}
} }
pub(crate) fn current_task(from: &str) -> TaskId { pub(crate) fn current_task(from: &str) -> TaskId {
...@@ -1660,6 +1669,10 @@ pub fn with_turbo_tasks<T>(func: impl FnOnce(&Arc<dyn TurboTasksApi>) -> T) -> T ...@@ -1660,6 +1669,10 @@ pub fn with_turbo_tasks<T>(func: impl FnOnce(&Arc<dyn TurboTasksApi>) -> T) -> T
TURBO_TASKS.with(|arc| func(arc)) TURBO_TASKS.with(|arc| func(arc))
} }
pub fn turbo_tasks_scope<T>(tt: Arc<dyn TurboTasksApi>, f: impl FnOnce() -> T) -> T {
TURBO_TASKS.sync_scope(tt, f)
}
pub fn with_turbo_tasks_for_testing<T>( pub fn with_turbo_tasks_for_testing<T>(
tt: Arc<dyn TurboTasksApi>, tt: Arc<dyn TurboTasksApi>,
current_task: TaskId, current_task: TaskId,
...@@ -1736,12 +1749,13 @@ pub fn emit<T: VcValueTrait + Send>(collectible: Vc<T>) { ...@@ -1736,12 +1749,13 @@ pub fn emit<T: VcValueTrait + Send>(collectible: Vc<T>) {
} }
pub async fn spawn_blocking<T: Send + 'static>(func: impl FnOnce() -> T + Send + 'static) -> T { pub async fn spawn_blocking<T: Send + 'static>(func: impl FnOnce() -> T + Send + 'static) -> T {
let turbo_tasks = turbo_tasks();
let span = trace_span!("blocking operation").or_current(); let span = trace_span!("blocking operation").or_current();
let (result, duration, alloc_info) = tokio::task::spawn_blocking(|| { let (result, duration, alloc_info) = tokio::task::spawn_blocking(|| {
let _guard = span.entered(); let _guard = span.entered();
let start = Instant::now(); let start = Instant::now();
let start_allocations = TurboMalloc::allocation_counters(); let start_allocations = TurboMalloc::allocation_counters();
let r = func(); let r = turbo_tasks_scope(turbo_tasks, func);
(r, start.elapsed(), start_allocations.until_now()) (r, start.elapsed(), start_allocations.until_now())
}) })
.await .await
......
use std::sync::Arc;
use crate::{turbo_tasks, turbo_tasks_scope, TurboTasksApi};
/// A wrapper around [`rayon::Scope`] that preserves the [`turbo_tasks_scope`].
pub struct Scope<'scope, 'a> {
scope: &'a rayon::Scope<'scope>,
handle: tokio::runtime::Handle,
turbo_tasks: Arc<dyn TurboTasksApi>,
span: tracing::Span,
}
impl<'scope> Scope<'scope, '_> {
pub fn spawn<Body>(&self, body: Body)
where
Body: FnOnce(&Scope<'scope, '_>) + Send + 'scope,
{
let span = self.span.clone();
let handle = self.handle.clone();
let turbo_tasks = self.turbo_tasks.clone();
self.scope.spawn(|scope| {
let _span = span.clone().entered();
let _guard = handle.enter();
turbo_tasks_scope(turbo_tasks.clone(), || {
body(&Scope {
scope,
span,
handle,
turbo_tasks,
})
})
});
}
}
/// A wrapper around [`rayon::in_place_scope`] that preserves the [`turbo_tasks_scope`].
pub fn scope<'scope, Op, R>(op: Op) -> R
where
Op: FnOnce(&Scope<'scope, '_>) -> R,
{
let span = tracing::Span::current();
let handle = tokio::runtime::Handle::current();
let turbo_tasks = turbo_tasks();
rayon::in_place_scope(|scope| {
op(&Scope {
scope,
span,
handle,
turbo_tasks,
})
})
}
...@@ -6,6 +6,6 @@ pub(crate) mod task_output; ...@@ -6,6 +6,6 @@ pub(crate) mod task_output;
pub use from_task_input::FromTaskInput; pub use from_task_input::FromTaskInput;
pub use function::{AsyncFunctionMode, FunctionMode, IntoTaskFn, TaskFn}; pub use function::{AsyncFunctionMode, FunctionMode, IntoTaskFn, TaskFn};
pub use shared_reference::SharedReference; pub use shared_reference::{SharedReference, TypedSharedReference};
pub use task_input::TaskInput; pub use task_input::TaskInput;
pub use task_output::TaskOutput; pub use task_output::TaskOutput;
...@@ -168,6 +168,10 @@ impl ValueType { ...@@ -168,6 +168,10 @@ impl ValueType {
} }
} }
pub fn is_serializable(&self) -> bool {
self.any_serialization.is_some()
}
pub fn get_magic_deserialize_seed(&self) -> Option<MagicAnyDeserializeSeed> { pub fn get_magic_deserialize_seed(&self) -> Option<MagicAnyDeserializeSeed> {
self.magic_serialization.map(|s| s.1) self.magic_serialization.map(|s| s.1)
} }
......
...@@ -69,6 +69,7 @@ pub static TRACING_TURBO_TASKS_TARGETS: Lazy<Vec<&str>> = Lazy::new(|| { ...@@ -69,6 +69,7 @@ pub static TRACING_TURBO_TASKS_TARGETS: Lazy<Vec<&str>> = Lazy::new(|| {
"turbo_tasks_fs=trace", "turbo_tasks_fs=trace",
"turbo_tasks_hash=trace", "turbo_tasks_hash=trace",
"turbo_tasks_memory=trace", "turbo_tasks_memory=trace",
"turbo_tasks_backend=trace",
], ],
] ]
.concat() .concat()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment