pika-org / pika

pika is a C++ tasking library built on std::execution with fibers, CUDA, HIP, and MPI support.
https://pikacpp.org
Boost Software License 1.0
63 stars 10 forks source link

Strange gaps in trace when a thread is scheduling tasks #603

Open rasolca opened 1 year ago

rasolca commented 1 year ago

Using the default scheduler blank gaps appear in the trace when one of the threads is scheduling the tasks. The gaps disappear immediately after the scheduling task finished.

Screenshot 2023-02-21 at 13 22 43

I tested the shared priority queue scheduler (@msimberg advice) and blanks disappeared Screenshot 2023-02-21 at 13 23 00

Note: the execution time is only slightly affected (2-3% faster with shared scheduler)

msimberg commented 1 year ago

Possibly related: #511. The shared_priority_queue_scheduler schedules new tasks by default on the current worker thread. While not necessarily always better, it does lead to different contention on the queues, and could explain part of the differences.

msimberg commented 1 year ago

This was my minimal change to test scheduling on the current thread in the default scheduler: https://github.com/pika-org/pika/compare/main...schedule-current-thread. It didn't seem to make a difference when I tested it but the algorithms in DLA-Future might have changed enough by then that it makes a difference now.