Bug #78479 MTS COORDINATOR AND WORKER THREAD SYNCHRONIZATION LIMITS PARALLELISM
Submitted: 18 Sep 2015 14:47 Modified: 8 Oct 2015 13:52
Reporter: Vitor Oliveira Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.8 OS:Any
Assigned to: CPU Architecture:Any

[18 Sep 2015 14:47] Vitor Oliveira
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.
[8 Oct 2015 13:52] David Moss
This seems to be related to internal code only. I don't see anything here that might apply to the docs so I'm closing it.