Unverified Commit 5033dcb9 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: run unit tests in multi threaded runtime (#82665)

### What?

run unit tests in multi threaded runtime

fix cache hit tracking
parent 116770b8
...@@ -1267,7 +1267,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1267,7 +1267,6 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
return task_id; return task_id;
} }
self.track_cache_miss(&task_type);
let tx = self let tx = self
.should_restore() .should_restore()
.then(|| self.backing_storage.start_read_transaction()) .then(|| self.backing_storage.start_read_transaction())
...@@ -1279,6 +1278,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1279,6 +1278,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
.forward_lookup_task_cache(tx.as_ref(), &task_type) .forward_lookup_task_cache(tx.as_ref(), &task_type)
.expect("Failed to lookup task id") .expect("Failed to lookup task id")
} { } {
self.track_cache_hit(&task_type);
let _ = self.task_cache.try_insert(Arc::new(task_type), task_id); let _ = self.task_cache.try_insert(Arc::new(task_type), task_id);
task_id task_id
} else { } else {
...@@ -1287,12 +1287,14 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1287,12 +1287,14 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
let task_id = if let Err(existing_task_id) = let task_id = if let Err(existing_task_id) =
self.task_cache.try_insert(task_type.clone(), task_id) self.task_cache.try_insert(task_type.clone(), task_id)
{ {
self.track_cache_hit(&task_type);
// Safety: We just created the id and failed to insert it. // Safety: We just created the id and failed to insert it.
unsafe { unsafe {
self.persisted_task_id_factory.reuse(task_id); self.persisted_task_id_factory.reuse(task_id);
} }
existing_task_id existing_task_id
} else { } else {
self.track_cache_miss(&task_type);
task_id task_id
}; };
if let Some(log) = &self.persisted_task_cache_log { if let Some(log) = &self.persisted_task_cache_log {
...@@ -1327,10 +1329,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1327,10 +1329,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
return task_id; return task_id;
} }
self.track_cache_miss(&task_type);
let task_type = Arc::new(task_type); let task_type = Arc::new(task_type);
let task_id = self.transient_task_id_factory.get(); let task_id = self.transient_task_id_factory.get();
if let Err(existing_task_id) = self.task_cache.try_insert(task_type, task_id) { if let Err(existing_task_id) = self.task_cache.try_insert(task_type.clone(), task_id) {
self.track_cache_hit(&task_type);
// Safety: We just created the id and failed to insert it. // Safety: We just created the id and failed to insert it.
unsafe { unsafe {
self.transient_task_id_factory.reuse(task_id); self.transient_task_id_factory.reuse(task_id);
...@@ -1339,6 +1341,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> { ...@@ -1339,6 +1341,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
return existing_task_id; return existing_task_id;
} }
self.track_cache_miss(&task_type);
self.connect_child(parent_task, task_id, turbo_tasks); self.connect_child(parent_task, task_id, turbo_tasks);
task_id task_id
......
...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn all_in_one() { async fn all_in_one() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<u32> = Vc::cell(4242); let a: Vc<u32> = Vc::cell(4242);
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn basic() { async fn basic() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let output1 = func_without_args(); let output1 = func_without_args();
......
...@@ -24,7 +24,7 @@ struct TaskSpec { ...@@ -24,7 +24,7 @@ struct TaskSpec {
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct TasksSpec(Vec<TaskSpec>); struct TasksSpec(Vec<TaskSpec>);
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn graph_bug() { async fn graph_bug() {
// see https://github.com/vercel/next.js/pull/79451 // see https://github.com/vercel/next.js/pull/79451
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
......
...@@ -33,7 +33,7 @@ pub struct TaskSpec { ...@@ -33,7 +33,7 @@ pub struct TaskSpec {
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct Iteration(State<usize>); struct Iteration(State<usize>);
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn graph_bug() { async fn graph_bug() {
run(&REGISTRATION, move || async move { run(&REGISTRATION, move || async move {
let spec = vec![ let spec = vec![
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn functions() { async fn functions() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
assert_eq!(*fn_plain().await?, 42); assert_eq!(*fn_plain().await?, 42);
...@@ -53,7 +53,7 @@ async fn async_fn_vc_arg(n: Vc<u32>) -> Result<Vc<u32>> { ...@@ -53,7 +53,7 @@ async fn async_fn_vc_arg(n: Vc<u32>) -> Result<Vc<u32>> {
Ok(Vc::cell(*n.await?)) Ok(Vc::cell(*n.await?))
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn methods() { async fn methods() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
assert_eq!(*Value::static_method().await?, 42); assert_eq!(*Value::static_method().await?, 42);
...@@ -106,7 +106,7 @@ impl Value { ...@@ -106,7 +106,7 @@ impl Value {
} }
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn trait_methods() { async fn trait_methods() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
assert_eq!(*Value::static_trait_method().await?, 42); assert_eq!(*Value::static_trait_method().await?, 42);
......
...@@ -14,7 +14,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -14,7 +14,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn transitive_emitting() { async fn transitive_emitting() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("")); let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!(""));
...@@ -32,7 +32,7 @@ async fn transitive_emitting() { ...@@ -32,7 +32,7 @@ async fn transitive_emitting() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn transitive_emitting_indirect() { async fn transitive_emitting_indirect() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("")); let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!(""));
...@@ -50,7 +50,7 @@ async fn transitive_emitting_indirect() { ...@@ -50,7 +50,7 @@ async fn transitive_emitting_indirect() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn multi_emitting() { async fn multi_emitting() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_multi_emitting_function(); let result_op = my_multi_emitting_function();
...@@ -68,7 +68,7 @@ async fn multi_emitting() { ...@@ -68,7 +68,7 @@ async fn multi_emitting() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn taking_collectibles() { async fn taking_collectibles() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_collecting_function(); let result_op = my_collecting_function();
...@@ -84,7 +84,7 @@ async fn taking_collectibles() { ...@@ -84,7 +84,7 @@ async fn taking_collectibles() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn taking_collectibles_extra_layer() { async fn taking_collectibles_extra_layer() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_collecting_function_indirect(); let result_op = my_collecting_function_indirect();
...@@ -100,7 +100,7 @@ async fn taking_collectibles_extra_layer() { ...@@ -100,7 +100,7 @@ async fn taking_collectibles_extra_layer() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn taking_collectibles_parallel() { async fn taking_collectibles_parallel() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("a")); let result_op = my_transitive_emitting_function(rcstr!(""), rcstr!("a"));
...@@ -142,7 +142,7 @@ async fn taking_collectibles_parallel() { ...@@ -142,7 +142,7 @@ async fn taking_collectibles_parallel() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn taking_collectibles_with_resolve() { async fn taking_collectibles_with_resolve() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let result_op = my_transitive_emitting_function_with_resolve(rcstr!("resolve")); let result_op = my_transitive_emitting_function_with_resolve(rcstr!("resolve"));
......
...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn primitive_debug() { async fn primitive_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<u32> = Vc::cell(42); let a: Vc<u32> = Vc::cell(42);
...@@ -20,7 +20,7 @@ async fn primitive_debug() { ...@@ -20,7 +20,7 @@ async fn primitive_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn transparent_debug() { async fn transparent_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<Transparent> = Transparent(42).cell(); let a: Vc<Transparent> = Transparent(42).cell();
...@@ -32,7 +32,7 @@ async fn transparent_debug() { ...@@ -32,7 +32,7 @@ async fn transparent_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn enum_none_debug() { async fn enum_none_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<Enum> = Enum::None.cell(); let a: Vc<Enum> = Enum::None.cell();
...@@ -44,7 +44,7 @@ async fn enum_none_debug() { ...@@ -44,7 +44,7 @@ async fn enum_none_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn enum_transparent_debug() { async fn enum_transparent_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<Enum> = Enum::Transparent(Transparent(42).resolved_cell()).cell(); let a: Vc<Enum> = Enum::Transparent(Transparent(42).resolved_cell()).cell();
...@@ -60,7 +60,7 @@ async fn enum_transparent_debug() { ...@@ -60,7 +60,7 @@ async fn enum_transparent_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn enum_inner_vc_debug() { async fn enum_inner_vc_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<Enum> = Enum::Enum(Enum::None.resolved_cell()).cell(); let a: Vc<Enum> = Enum::Enum(Enum::None.resolved_cell()).cell();
...@@ -76,7 +76,7 @@ async fn enum_inner_vc_debug() { ...@@ -76,7 +76,7 @@ async fn enum_inner_vc_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn struct_unit_debug() { async fn struct_unit_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<StructUnit> = StructUnit.cell(); let a: Vc<StructUnit> = StructUnit.cell();
...@@ -87,7 +87,7 @@ async fn struct_unit_debug() { ...@@ -87,7 +87,7 @@ async fn struct_unit_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn struct_transparent_debug() { async fn struct_transparent_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<StructWithTransparent> = StructWithTransparent { let a: Vc<StructWithTransparent> = StructWithTransparent {
...@@ -106,7 +106,7 @@ async fn struct_transparent_debug() { ...@@ -106,7 +106,7 @@ async fn struct_transparent_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn struct_vec_debug() { async fn struct_vec_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<StructWithVec> = StructWithVec { vec: vec![] }.cell(); let a: Vc<StructWithVec> = StructWithVec { vec: vec![] }.cell();
...@@ -135,7 +135,7 @@ async fn struct_vec_debug() { ...@@ -135,7 +135,7 @@ async fn struct_vec_debug() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn struct_ignore_debug() { async fn struct_ignore_debug() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: Vc<StructWithIgnore> = StructWithIgnore { let a: Vc<StructWithIgnore> = StructWithIgnore {
......
...@@ -15,7 +15,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -15,7 +15,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_spawns_detached() -> anyhow::Result<()> { async fn test_spawns_detached() -> anyhow::Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
// HACK: The watch channel we use has an incorrect implementation of `TraceRawVcs`, just // HACK: The watch channel we use has an incorrect implementation of `TraceRawVcs`, just
...@@ -82,7 +82,7 @@ async fn spawns_detached( ...@@ -82,7 +82,7 @@ async fn spawns_detached(
Vc::cell(()) Vc::cell(())
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_spawns_detached_changing() -> anyhow::Result<()> { async fn test_spawns_detached_changing() -> anyhow::Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
// HACK: The watch channel we use has an incorrect implementation of `TraceRawVcs` // HACK: The watch channel we use has an incorrect implementation of `TraceRawVcs`
......
...@@ -11,7 +11,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -11,7 +11,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn dirty_in_progress() { async fn dirty_in_progress() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let cases = [ let cases = [
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn recompute() { async fn recompute() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = ChangingInput { let input = ChangingInput {
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn filtered_trait_method_args() -> Result<()> { async fn filtered_trait_method_args() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let uses_arg = UsesArg.cell(); let uses_arg = UsesArg.cell();
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn hidden_mutate() { async fn hidden_mutate() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = create_input().resolve().await?; let input = create_input().resolve().await?;
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_local_task_id() -> Result<()> { async fn test_local_task_id() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let local_vc = get_local_task_id(); let local_vc = get_local_task_id();
......
...@@ -26,7 +26,7 @@ fn use_operations() -> Vc<i32> { ...@@ -26,7 +26,7 @@ fn use_operations() -> Vc<i32> {
forty_two.connect() forty_two.connect()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_use_operations() -> Result<()> { async fn test_use_operations() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
assert_eq!(*use_operations().await?, 42); assert_eq!(*use_operations().await?, 42);
......
...@@ -25,7 +25,7 @@ static FILE_PATH_REGEX: LazyLock<Regex> = ...@@ -25,7 +25,7 @@ static FILE_PATH_REGEX: LazyLock<Regex> =
// //
// This test depends on the process-wide global panic handler. This test must be run in its own // This test depends on the process-wide global panic handler. This test must be run in its own
// process in isolation of any other tests. // process in isolation of any other tests.
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_panic_hook() { async fn test_panic_hook() {
let prev_hook = take_hook(); let prev_hook = take_hook();
set_hook(Box::new(move |info| { set_hook(Box::new(move |info| {
......
...@@ -142,7 +142,7 @@ fn check_skip() -> bool { ...@@ -142,7 +142,7 @@ fn check_skip() -> bool {
false false
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_many_children() { async fn many_calls_to_many_children() {
if check_skip() { if check_skip() {
return; return;
...@@ -157,7 +157,7 @@ async fn many_calls_to_many_children() { ...@@ -157,7 +157,7 @@ async fn many_calls_to_many_children() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_uncached_many_children() { async fn many_calls_to_uncached_many_children() {
if check_skip() { if check_skip() {
return; return;
...@@ -189,7 +189,7 @@ fn run_big_graph_test(counts: Vec<u32>) -> impl Future<Output = Result<()>> + Se ...@@ -189,7 +189,7 @@ fn run_big_graph_test(counts: Vec<u32>) -> impl Future<Output = Result<()>> + Se
) )
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_1() { async fn many_calls_to_big_graph_1() {
if check_skip() { if check_skip() {
return; return;
...@@ -199,7 +199,7 @@ async fn many_calls_to_big_graph_1() { ...@@ -199,7 +199,7 @@ async fn many_calls_to_big_graph_1() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_2() { async fn many_calls_to_big_graph_2() {
if check_skip() { if check_skip() {
return; return;
...@@ -211,7 +211,7 @@ async fn many_calls_to_big_graph_2() { ...@@ -211,7 +211,7 @@ async fn many_calls_to_big_graph_2() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_3() { async fn many_calls_to_big_graph_3() {
if check_skip() { if check_skip() {
return; return;
...@@ -221,7 +221,7 @@ async fn many_calls_to_big_graph_3() { ...@@ -221,7 +221,7 @@ async fn many_calls_to_big_graph_3() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_4() { async fn many_calls_to_big_graph_4() {
if check_skip() { if check_skip() {
return; return;
...@@ -231,7 +231,7 @@ async fn many_calls_to_big_graph_4() { ...@@ -231,7 +231,7 @@ async fn many_calls_to_big_graph_4() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_5() { async fn many_calls_to_big_graph_5() {
if check_skip() { if check_skip() {
return; return;
...@@ -243,7 +243,7 @@ async fn many_calls_to_big_graph_5() { ...@@ -243,7 +243,7 @@ async fn many_calls_to_big_graph_5() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_6() { async fn many_calls_to_big_graph_6() {
if check_skip() { if check_skip() {
return; return;
...@@ -255,7 +255,7 @@ async fn many_calls_to_big_graph_6() { ...@@ -255,7 +255,7 @@ async fn many_calls_to_big_graph_6() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_7() { async fn many_calls_to_big_graph_7() {
if check_skip() { if check_skip() {
return; return;
...@@ -270,7 +270,7 @@ async fn many_calls_to_big_graph_7() { ...@@ -270,7 +270,7 @@ async fn many_calls_to_big_graph_7() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_8() { async fn many_calls_to_big_graph_8() {
if check_skip() { if check_skip() {
return; return;
...@@ -282,7 +282,7 @@ async fn many_calls_to_big_graph_8() { ...@@ -282,7 +282,7 @@ async fn many_calls_to_big_graph_8() {
.unwrap(); .unwrap();
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn many_calls_to_big_graph_9() { async fn many_calls_to_big_graph_9() {
if check_skip() { if check_skip() {
return; return;
......
...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn random_change() { async fn random_change() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let state = make_state(); let state = make_state();
......
...@@ -10,7 +10,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -10,7 +10,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn read_ref() { async fn read_ref() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let counter = Counter::cell(Counter { let counter = Counter::cell(Counter {
......
...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -8,7 +8,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn recompute() { async fn recompute() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = ChangingInput { let input = ChangingInput {
...@@ -58,7 +58,7 @@ async fn recompute() { ...@@ -58,7 +58,7 @@ async fn recompute() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn immutable_analysis() { async fn immutable_analysis() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = ChangingInput { let input = ChangingInput {
......
...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -9,7 +9,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn recompute() { async fn recompute() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = ChangingInput::new(1).resolve().await?; let input = ChangingInput::new(1).resolve().await?;
......
...@@ -23,7 +23,7 @@ fn assert_resolved(input: ResolvedVc<u32>) { ...@@ -23,7 +23,7 @@ fn assert_resolved(input: ResolvedVc<u32>) {
assert!(input_vc.is_resolved()); assert!(input_vc.is_resolved());
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_conversion() -> Result<()> { async fn test_conversion() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let unresolved: Vc<u32> = Vc::cell(42); let unresolved: Vc<u32> = Vc::cell(42);
...@@ -38,7 +38,7 @@ async fn test_conversion() -> Result<()> { ...@@ -38,7 +38,7 @@ async fn test_conversion() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_cell_construction() -> Result<()> { async fn test_cell_construction() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let a: ResolvedVc<u32> = ResolvedVc::cell(42); let a: ResolvedVc<u32> = ResolvedVc::cell(42);
...@@ -50,7 +50,7 @@ async fn test_cell_construction() -> Result<()> { ...@@ -50,7 +50,7 @@ async fn test_cell_construction() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_resolved_vc_as_arg() -> Result<()> { async fn test_resolved_vc_as_arg() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let unresolved: Vc<u32> = returns_int(42); let unresolved: Vc<u32> = returns_int(42);
...@@ -62,7 +62,7 @@ async fn test_resolved_vc_as_arg() -> Result<()> { ...@@ -62,7 +62,7 @@ async fn test_resolved_vc_as_arg() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_into_future() -> Result<()> { async fn test_into_future() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let mut resolved = ResolvedVc::cell(42); let mut resolved = ResolvedVc::cell(42);
...@@ -78,7 +78,7 @@ async fn test_into_future() -> Result<()> { ...@@ -78,7 +78,7 @@ async fn test_into_future() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_sidecast() -> Result<()> { async fn test_sidecast() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let concrete_value = ImplementsAAndB.resolved_cell(); let concrete_value = ImplementsAAndB.resolved_cell();
......
...@@ -11,7 +11,7 @@ static REGISTRATION: Registration = register!(); ...@@ -11,7 +11,7 @@ static REGISTRATION: Registration = register!();
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct Wrapper(Vec<u32>); struct Wrapper(Vec<u32>);
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_shrink_to_fit() -> Result<()> { async fn test_shrink_to_fit() -> Result<()> {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
// `Vec::shrink_to_fit` is implicitly called when a cell is constructed. // `Vec::shrink_to_fit` is implicitly called when a cell is constructed.
......
...@@ -13,7 +13,7 @@ use turbo_tasks_testing::{Registration, register, run_without_cache_check}; ...@@ -13,7 +13,7 @@ use turbo_tasks_testing::{Registration, register, run_without_cache_check};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_simple_task() -> Result<()> { async fn test_simple_task() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
...@@ -39,7 +39,7 @@ async fn test_simple_task() -> Result<()> { ...@@ -39,7 +39,7 @@ async fn test_simple_task() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_await_same_vc_multiple_times() -> Result<()> { async fn test_await_same_vc_multiple_times() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
...@@ -61,7 +61,7 @@ async fn test_await_same_vc_multiple_times() -> Result<()> { ...@@ -61,7 +61,7 @@ async fn test_await_same_vc_multiple_times() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_vc_receiving_task() -> Result<()> { async fn test_vc_receiving_task() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
...@@ -93,7 +93,7 @@ async fn test_vc_receiving_task() -> Result<()> { ...@@ -93,7 +93,7 @@ async fn test_vc_receiving_task() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_trait_methods() -> Result<()> { async fn test_trait_methods() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
...@@ -130,7 +130,7 @@ async fn test_trait_methods() -> Result<()> { ...@@ -130,7 +130,7 @@ async fn test_trait_methods() -> Result<()> {
.await .await
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_dyn_trait_methods() -> Result<()> { async fn test_dyn_trait_methods() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
...@@ -174,7 +174,7 @@ async fn test_dyn_trait_methods() -> Result<()> { ...@@ -174,7 +174,7 @@ async fn test_dyn_trait_methods() -> Result<()> {
} }
// creates Vcs, but doesn't ever execute them // creates Vcs, but doesn't ever execute them
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_no_execution() -> Result<()> { async fn test_no_execution() -> Result<()> {
run_without_cache_check(&REGISTRATION, async move { run_without_cache_check(&REGISTRATION, async move {
enable_stats(); enable_stats();
......
...@@ -18,7 +18,7 @@ Adder::add_method (read cell of type turbo-tasks@TODO::::primitives::u64) ...@@ -18,7 +18,7 @@ Adder::add_method (read cell of type turbo-tasks@TODO::::primitives::u64)
unknown transient task (read cell of type turbo-tasks@TODO::::primitives::u16) unknown transient task (read cell of type turbo-tasks@TODO::::primitives::u16)
unknown transient task (read cell of type turbo-tasks@TODO::::primitives::u32)"; unknown transient task (read cell of type turbo-tasks@TODO::::primitives::u32)";
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_trace_transient() { async fn test_trace_transient() {
let result = run_without_cache_check(&REGISTRATION, async { let result = run_without_cache_check(&REGISTRATION, async {
read_incorrect_task_input_operation(IncorrectTaskInput( read_incorrect_task_input_operation(IncorrectTaskInput(
......
...@@ -10,7 +10,7 @@ use turbo_tasks_testing::{Registration, register, run}; ...@@ -10,7 +10,7 @@ use turbo_tasks_testing::{Registration, register, run};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn trait_ref() { async fn trait_ref() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let counter = Counter::cell(Counter { let counter = Counter::cell(Counter {
......
...@@ -9,7 +9,7 @@ static REGISTRATION: Registration = register!(); ...@@ -9,7 +9,7 @@ static REGISTRATION: Registration = register!();
// Test that with `cell = "shared"`, the cell will be re-used as long as the // Test that with `cell = "shared"`, the cell will be re-used as long as the
// value is equal. // value is equal.
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_trait_ref_shared_cell_mode() { async fn test_trait_ref_shared_cell_mode() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = CellIdSelector { let input = CellIdSelector {
...@@ -44,7 +44,7 @@ async fn test_trait_ref_shared_cell_mode() { ...@@ -44,7 +44,7 @@ async fn test_trait_ref_shared_cell_mode() {
// Test that with `cell = "new"`, the cell will is never re-used, even if the // Test that with `cell = "new"`, the cell will is never re-used, even if the
// value is equal. // value is equal.
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_trait_ref_new_cell_mode() { async fn test_trait_ref_new_cell_mode() {
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
let input = CellIdSelector { let input = CellIdSelector {
......
...@@ -10,7 +10,7 @@ static REGISTRATION: Registration = register!(); ...@@ -10,7 +10,7 @@ static REGISTRATION: Registration = register!();
const EXPECTED_MSG: &str = const EXPECTED_MSG: &str =
"Collectible is transient, transient collectibles cannot be emitted from persistent tasks"; "Collectible is transient, transient collectibles cannot be emitted from persistent tasks";
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_transient_emit_from_persistent() { async fn test_transient_emit_from_persistent() {
let result = run_without_cache_check(&REGISTRATION, async { let result = run_without_cache_check(&REGISTRATION, async {
emit_incorrect_task_input_operation(IncorrectTaskInput(U32Wrapper(123).resolved_cell())) emit_incorrect_task_input_operation(IncorrectTaskInput(U32Wrapper(123).resolved_cell()))
......
...@@ -7,7 +7,7 @@ use turbo_tasks_testing::{Registration, register, run_without_cache_check}; ...@@ -7,7 +7,7 @@ use turbo_tasks_testing::{Registration, register, run_without_cache_check};
static REGISTRATION: Registration = register!(); static REGISTRATION: Registration = register!();
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn test_transient_vc() -> Result<()> { async fn test_transient_vc() -> Result<()> {
run_without_cache_check(&REGISTRATION, async { run_without_cache_check(&REGISTRATION, async {
test_transient_operation(TransientValue::new(123)) test_transient_operation(TransientValue::new(123))
......
...@@ -18,7 +18,7 @@ static REGISTRATION: Registration = register!(turbo_tasks_fetch::register); ...@@ -18,7 +18,7 @@ static REGISTRATION: Registration = register!(turbo_tasks_fetch::register);
/// acquire and hold this lock to prevent potential flakiness. /// acquire and hold this lock to prevent potential flakiness.
static GLOBAL_TEST_LOCK: TokioMutex<()> = TokioMutex::const_new(()); static GLOBAL_TEST_LOCK: TokioMutex<()> = TokioMutex::const_new(());
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn basic_get() { async fn basic_get() {
let _guard = GLOBAL_TEST_LOCK.lock().await; let _guard = GLOBAL_TEST_LOCK.lock().await;
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
...@@ -49,7 +49,7 @@ async fn basic_get() { ...@@ -49,7 +49,7 @@ async fn basic_get() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn sends_user_agent() { async fn sends_user_agent() {
let _guard = GLOBAL_TEST_LOCK.lock().await; let _guard = GLOBAL_TEST_LOCK.lock().await;
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
...@@ -85,7 +85,7 @@ async fn sends_user_agent() { ...@@ -85,7 +85,7 @@ async fn sends_user_agent() {
// This is temporary behavior. // This is temporary behavior.
// TODO: Implement invalidation that respects Cache-Control headers. // TODO: Implement invalidation that respects Cache-Control headers.
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn invalidation_does_not_invalidate() { async fn invalidation_does_not_invalidate() {
let _guard = GLOBAL_TEST_LOCK.lock().await; let _guard = GLOBAL_TEST_LOCK.lock().await;
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
...@@ -130,7 +130,7 @@ fn get_issue_context() -> Vc<FileSystemPath> { ...@@ -130,7 +130,7 @@ fn get_issue_context() -> Vc<FileSystemPath> {
DiskFileSystem::new(rcstr!("root"), rcstr!("/")).root() DiskFileSystem::new(rcstr!("root"), rcstr!("/")).root()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn errors_on_failed_connection() { async fn errors_on_failed_connection() {
let _guard = GLOBAL_TEST_LOCK.lock().await; let _guard = GLOBAL_TEST_LOCK.lock().await;
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
...@@ -161,7 +161,7 @@ async fn errors_on_failed_connection() { ...@@ -161,7 +161,7 @@ async fn errors_on_failed_connection() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn errors_on_404() { async fn errors_on_404() {
let _guard = GLOBAL_TEST_LOCK.lock().await; let _guard = GLOBAL_TEST_LOCK.lock().await;
run(&REGISTRATION, || async { run(&REGISTRATION, || async {
...@@ -196,7 +196,7 @@ async fn errors_on_404() { ...@@ -196,7 +196,7 @@ async fn errors_on_404() {
.unwrap() .unwrap()
} }
#[tokio::test] #[tokio::test(flavor = "multi_thread")]
async fn client_cache() { async fn client_cache() {
// a simple fetch that should always succeed // a simple fetch that should always succeed
async fn simple_fetch(path: &str, client: FetchClient) -> anyhow::Result<()> { async fn simple_fetch(path: &str, client: FetchClient) -> anyhow::Result<()> {
......
...@@ -272,7 +272,7 @@ fn test_cases() {} ...@@ -272,7 +272,7 @@ fn test_cases() {}
#[apply(test_cases)] #[apply(test_cases)]
fn node_file_trace_noop_backing_storage(#[case] input: CaseInput) { fn node_file_trace_noop_backing_storage(#[case] input: CaseInput) {
node_file_trace(input, "noop_backing_storage", false, 1, 120, |_| { node_file_trace(input, "noop_backing_storage", 1, 120, |_| {
TurboTasks::new(TurboTasksBackend::new( TurboTasks::new(TurboTasksBackend::new(
turbo_tasks_backend::BackendOptions::default(), turbo_tasks_backend::BackendOptions::default(),
turbo_tasks_backend::noop_backing_storage(), turbo_tasks_backend::noop_backing_storage(),
...@@ -282,7 +282,7 @@ fn node_file_trace_noop_backing_storage(#[case] input: CaseInput) { ...@@ -282,7 +282,7 @@ fn node_file_trace_noop_backing_storage(#[case] input: CaseInput) {
#[apply(test_cases)] #[apply(test_cases)]
fn node_file_trace_persistent(#[case] input: CaseInput) { fn node_file_trace_persistent(#[case] input: CaseInput) {
node_file_trace(input, "persistent_cache", false, 2, 240, |directory_path| { node_file_trace(input, "persistent_cache", 2, 240, |directory_path| {
TurboTasks::new(TurboTasksBackend::new( TurboTasks::new(TurboTasksBackend::new(
turbo_tasks_backend::BackendOptions::default(), turbo_tasks_backend::BackendOptions::default(),
turbo_tasks_backend::default_backing_storage( turbo_tasks_backend::default_backing_storage(
...@@ -302,31 +302,18 @@ fn node_file_trace_persistent(#[case] input: CaseInput) { ...@@ -302,31 +302,18 @@ fn node_file_trace_persistent(#[case] input: CaseInput) {
#[cfg(feature = "bench_against_node_nft")] #[cfg(feature = "bench_against_node_nft")]
#[apply(test_cases)] #[apply(test_cases)]
fn bench_against_node_nft_st(#[case] input: CaseInput) { fn bench_against_node_nft(#[case] input: CaseInput) {
bench_against_node_nft_inner(input, false); bench_against_node_nft_inner(input);
} }
#[cfg(feature = "bench_against_node_nft")] #[cfg(feature = "bench_against_node_nft")]
#[apply(test_cases)] fn bench_against_node_nft_inner(input: CaseInput) {
fn bench_against_node_nft_mt(#[case] input: CaseInput) { node_file_trace(input, "noop_backing_storage", 1, 120, |_| {
bench_against_node_nft_inner(input, true); TurboTasks::new(TurboTasksBackend::new(
} turbo_tasks_backend::BackendOptions::default(),
turbo_tasks_backend::noop_backing_storage(),
#[cfg(feature = "bench_against_node_nft")] ))
fn bench_against_node_nft_inner(input: CaseInput, multi_threaded: bool) { });
node_file_trace(
input,
"noop_backing_storage",
multi_threaded,
1,
120,
|_| {
TurboTasks::new(TurboTasksBackend::new(
turbo_tasks_backend::BackendOptions::default(),
turbo_tasks_backend::noop_backing_storage(),
))
},
);
} }
#[turbo_tasks::function(operation)] #[turbo_tasks::function(operation)]
...@@ -401,7 +388,6 @@ fn node_file_trace<B: Backend + 'static>( ...@@ -401,7 +388,6 @@ fn node_file_trace<B: Backend + 'static>(
expected_stderr, expected_stderr,
}: CaseInput, }: CaseInput,
mode: &str, mode: &str,
multi_threaded: bool,
run_count: i32, run_count: i32,
timeout_len: u64, timeout_len: u64,
create_turbo_tasks: impl Fn(&Path) -> Arc<TurboTasks<B>>, create_turbo_tasks: impl Fn(&Path) -> Arc<TurboTasks<B>>,
...@@ -410,15 +396,9 @@ fn node_file_trace<B: Backend + 'static>( ...@@ -410,15 +396,9 @@ fn node_file_trace<B: Backend + 'static>(
LazyLock::new(|| Arc::new(Mutex::new(Vec::new()))); LazyLock::new(|| Arc::new(Mutex::new(Vec::new())));
let r = &mut { let r = &mut {
let mut builder = if multi_threaded { let mut builder = tokio::runtime::Builder::new_multi_thread();
tokio::runtime::Builder::new_multi_thread()
} else {
tokio::runtime::Builder::new_current_thread()
};
builder.enable_all(); builder.enable_all();
if !multi_threaded { builder.max_blocking_threads(20);
builder.max_blocking_threads(20);
}
builder.build().unwrap() builder.build().unwrap()
}; };
r.block_on(async move { r.block_on(async move {
...@@ -490,12 +470,7 @@ fn node_file_trace<B: Backend + 'static>( ...@@ -490,12 +470,7 @@ fn node_file_trace<B: Backend + 'static>(
bench_suites_lock.push(BenchSuite { bench_suites_lock.push(BenchSuite {
suite: input suite: input
.trim_start_matches("node-file-trace/integration/") .trim_start_matches("node-file-trace/integration/")
.to_string() .to_string(),
+ (if multi_threaded {
" (multi-threaded)"
} else {
""
}),
is_faster, is_faster,
rust_duration, rust_duration,
node_duration, node_duration,
......
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