Unverified Commit f145b8fa authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test(turbo-tasks): avoid wasm runtime shutdown wait

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: 's avatarLuke Sandberg <210140+lukesandberg@users.noreply.github.com>
parent 332b0c51
......@@ -359,14 +359,18 @@ mod tests {
/// Helpers must actually add parallelism when threads are available: jobs that each block
/// briefly should complete in far less than their serial sum.
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
// Node Worker startup makes the native timing bound too strict on wasm. A later layer uses a
// platform-aware bound that still distinguishes parallel from serial execution.
#[cfg_attr(
target_family = "wasm",
ignore = "timing bound is too strict for Node Worker startup"
)]
async fn test_scope_runs_in_parallel() {
#[test]
fn test_scope_runs_in_parallel() {
let runtime = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_all()
.build()
.unwrap();
runtime.block_on(test_scope_runs_in_parallel_impl());
runtime.shutdown_background();
}
async fn test_scope_runs_in_parallel_impl() {
const JOBS: usize = 16;
const PER_JOB: Duration = Duration::from_millis(50);
let started = Instant::now();
......@@ -385,10 +389,14 @@ mod tests {
.unwrap();
let elapsed = started.elapsed();
assert_eq!(results.len(), JOBS);
// Half the serial time is a loose bound on purpose: 4 threads should beat it comfortably,
// so a slow machine won't make this flaky.
let serial_time = JOBS as u32 * PER_JOB;
#[cfg(not(target_family = "wasm"))]
let deadline = serial_time / 2;
// Node Worker startup is expensive, but the test must still finish faster than serial work.
#[cfg(target_family = "wasm")]
let deadline = serial_time - PER_JOB;
assert!(
elapsed < (JOBS as u32 * PER_JOB) / 2,
elapsed < deadline,
"scope_bounded took {elapsed:?}; expected parallel speedup across worker threads"
);
}
......
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