Skip to content

Commit

Permalink
feat(turbo-tasks): Optionally schedule ResolveNative/ResolveTrait tas…
Browse files Browse the repository at this point in the history
…ks as local tasks
  • Loading branch information
bgw committed Aug 29, 2024
1 parent a00965d commit 694aa77
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 52 deletions.
25 changes: 10 additions & 15 deletions turbopack/crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,33 +744,31 @@ impl Task {
),
TaskType::Persistent { ty, .. } | TaskType::Transient { ty, .. } => match &***ty {
CachedTaskType::Native {
fn_type: native_fn,
fn_type: native_fn_id,
this,
arg,
} => {
let func = registry::get_function(*native_fn);
let func = registry::get_function(*native_fn_id);
let span = func.span();
let entered = span.enter();
let future = func.execute(*this, &**arg);
drop(entered);
(future, span)
}
CachedTaskType::ResolveNative {
fn_type: ref native_fn_id,
fn_type: native_fn_id,
this,
arg,
} => {
let native_fn_id = *native_fn_id;
let func = registry::get_function(native_fn_id);
let func = registry::get_function(*native_fn_id);
let span = func.resolve_span();
let entered = span.enter();
let turbo_tasks = turbo_tasks.pin();
let future = Box::pin(CachedTaskType::run_resolve_native(
native_fn_id,
*native_fn_id,
*this,
&**arg,
self.id.persistence(),
turbo_tasks,
turbo_tasks.pin(),
));
drop(entered);
(future, span)
Expand All @@ -781,19 +779,16 @@ impl Task {
this,
arg,
} => {
let trait_type_id = *trait_type_id;
let trait_type = registry::get_trait(trait_type_id);
let trait_type = registry::get_trait(*trait_type_id);
let span = trait_type.resolve_span(name);
let entered = span.enter();
let name = name.clone();
let turbo_tasks = turbo_tasks.pin();
let future = Box::pin(CachedTaskType::run_resolve_trait(
trait_type_id,
name,
*trait_type_id,
name.clone(),
*this,
&**arg,
self.id.persistence(),
turbo_tasks,
turbo_tasks.pin(),
));
drop(entered);
(future, span)
Expand Down
1 change: 1 addition & 0 deletions turbopack/crates/turbo-tasks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ bench = false
default = []
tokio_tracing = ["tokio/tracing"]
hanging_detection = []
local_resolution = []

[lints]
workspace = true
Expand Down
Loading

0 comments on commit 694aa77

Please sign in to comment.