Unverified Commit 4674a435 authored by Matt Mastracci's avatar Matt Mastracci Committed by GitHub

Turbopack: Make the priority_runner testcase deterministic (#88651)

# What

Fixes the `test_mixed_cpu_bound_and_waiting_tasks` to avoid flakes.

# Why

The `test_mixed_cpu_bound_and_waiting_tasks` was non-deterministic and relied on thread scheduling order.

The previous test relied on timing-based synchronization using sleep() calls with varying durations to simulate CPU-bound and async work. This approach was inherently flaky because:                                            

  1. Thread scheduling is non-deterministic - a task sleeping for 10ms might complete before one sleeping for 5ms  
  depending on OS scheduler behaviour                                                                               
  2. The assertions depended on specific completion ordering that wasn't guaranteed by the timing                  
  3. Test behaviour could vary based on system load, available cores, and Tokio runtime scheduling                  

# How

he new approach uses std::sync::Barrier pairs (start, finish) for each task, giving the test explicit control over when tasks can proceed.

Because this is a priority-ordered system, we know which barriers should be available at any given time and can release them. If the given task is not current waiting on its own corresponding barrier, the test will fail.
parent aa8754c3
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