From 45963b3d0cad83aa385f7356a47d079e2d902143 Mon Sep 17 00:00:00 2001 From: Abdulmalik Alquwayfili Date: Tue, 15 Sep 2026 09:34:17 +0300 Subject: [PATCH] test: assert default-scope tasks spread across workers (#663) The unit tests pin the pressure term in the cost formula, but nothing ran tasks end to end and checked placement, which is how #663 shipped unnoticed. Add a behavioral check: 40 sleeping tasks over 4 workers land [1 => 40] when the pressure term is dead and spread across workers when it is live. Verified failing on 59081dcb (pre-#744) and passing on master. --- test/scheduler.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/scheduler.jl b/test/scheduler.jl index 509ed158c..211abd0cb 100644 --- a/test/scheduler.jl +++ b/test/scheduler.jl @@ -849,3 +849,14 @@ end @test timedwait(()->istaskdone(b), 60) == :ok istaskdone(b) && @test fetch(b) == 42 end + +@testset "Load balancing across workers" begin + # Issue #663: without per-processor pressure in the task cost, every + # default-scope task lands on the scheduler's own worker ([1 => 40]); + # with it, tasks spread across workers. + if nprocs() > 1 + slowid = i -> (sleep(0.1); myid()) + ids = fetch.([Dagger.@spawn slowid(i) for i in 1:40]) + @test length(unique(ids)) > 1 + end +end