- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.7k
Description
Cf discourse https://discourse.julialang.org/t/is-the-operation-scheduling-a-task-blocking/133372
Consider
$ julia +1.11 -t 4 -e "t=Task(()->Threads.threadid()); t.sticky=false; schedule(t); println(fetch(t))"
3
$ julia +1.12 -t 4 -e "t=Task(()->Threads.threadid()); t.sticky=false; schedule(t); println(fetch(t))"
1
I think the responsible PR is Fix enq_work behavior when single-threaded by kpamnany · Pull Request #48702 · JuliaLang/julia · GitHub
This was a probably unintended breaking change because up to julia 1.11, the official and documented API for spawning a task in the :default threadpool was t=Task(fun); t.sticky=false; #= do some other setup =# schedule(t);.
Now, 1.12 silently changed the behavior (without deprecation warnings, not even with documentation update) such that this task now sticks to the threadpool. Hence, lots of old code will now silently degrade in performance / latency, in a way that unit tests are unlikely to notice. And some 1.12-era code will rely on the new (imo bad) behavior for correctness 😱
Sticky-ness now has 3 values: Stick-to-thread, Stick-to-pool, and unsticky, while we previously only had 2 values: Stick-to-thread and unsticky, and the update silently mapped unsticky->stick-to-pool.