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