Description:
On MTS (logical clock), the coordinator thread assigns transactions to
each worker one-by-one. When it finds that there are no worker threads
whose work queue is not empty it waits with a my_sleep call.
The worker thread, on the other side, waits for transactions in the
it's own work queue, gets the element on top, executes the transaction
and only then releases the work queue.
This coordination between the threads introduces some delays that can
be seen in the execution profile, and can be reduced.
How to repeat:
Profile the execution of the slave applier with 4 threads in a
database on ramdisk, using a benchmark such as Sysbench RW.
Check the pop_jobs_item execution time in the worker thread and
the Mts_submode_logical_clock::get_least_occupied_worker on the
coordinator thread.
Suggested fix:
Change the code so that:
1) there is no my_sleep in the coordinator thread but a busy-wait loop;
2) the work queue is release on the slave as soon as possible, so that
the coordinator can introduce more work on it while current transaction
is being executed;
3) there are more than one transactions on the thread work queue.