Skip to content

Commit 694aa77

Browse files
committed
feat(turbo-tasks): Optionally schedule ResolveNative/ResolveTrait tasks as local tasks
1 parent a00965d commit 694aa77

File tree

5 files changed

+315
-52
lines changed

5 files changed

+315
-52
lines changed

turbopack/crates/turbo-tasks-memory/src/task.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,33 +744,31 @@ impl Task {
744744
),
745745
TaskType::Persistent { ty, .. } | TaskType::Transient { ty, .. } => match &***ty {
746746
CachedTaskType::Native {
747-
fn_type: native_fn,
747+
fn_type: native_fn_id,
748748
this,
749749
arg,
750750
} => {
751-
let func = registry::get_function(*native_fn);
751+
let func = registry::get_function(*native_fn_id);
752752
let span = func.span();
753753
let entered = span.enter();
754754
let future = func.execute(*this, &**arg);
755755
drop(entered);
756756
(future, span)
757757
}
758758
CachedTaskType::ResolveNative {
759-
fn_type: ref native_fn_id,
759+
fn_type: native_fn_id,
760760
this,
761761
arg,
762762
} => {
763-
let native_fn_id = *native_fn_id;
764-
let func = registry::get_function(native_fn_id);
763+
let func = registry::get_function(*native_fn_id);
765764
let span = func.resolve_span();
766765
let entered = span.enter();
767-
let turbo_tasks = turbo_tasks.pin();
768766
let future = Box::pin(CachedTaskType::run_resolve_native(
769-
native_fn_id,
767+
*native_fn_id,
770768
*this,
771769
&**arg,
772770
self.id.persistence(),
773-
turbo_tasks,
771+
turbo_tasks.pin(),
774772
));
775773
drop(entered);
776774
(future, span)
@@ -781,19 +779,16 @@ impl Task {
781779
this,
782780
arg,
783781
} => {
784-
let trait_type_id = *trait_type_id;
785-
let trait_type = registry::get_trait(trait_type_id);
782+
let trait_type = registry::get_trait(*trait_type_id);
786783
let span = trait_type.resolve_span(name);
787784
let entered = span.enter();
788-
let name = name.clone();
789-
let turbo_tasks = turbo_tasks.pin();
790785
let future = Box::pin(CachedTaskType::run_resolve_trait(
791-
trait_type_id,
792-
name,
786+
*trait_type_id,
787+
name.clone(),
793788
*this,
794789
&**arg,
795790
self.id.persistence(),
796-
turbo_tasks,
791+
turbo_tasks.pin(),
797792
));
798793
drop(entered);
799794
(future, span)

turbopack/crates/turbo-tasks/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bench = false
1212
default = []
1313
tokio_tracing = ["tokio/tracing"]
1414
hanging_detection = []
15+
local_resolution = []
1516

1617
[lints]
1718
workspace = true

0 commit comments

Comments
 (0)