MXS-1948: Do round-robin worker assignment
Due to the skewed accept distribution without SO_REUSEPORT, we use round-robin assignment of workers for new client connections. This provides better performance as work is more likely to be evenly distributed across all threads. Using a least-busy-worker algorithm would provide a more stable result but this is not trivially simple to implement. For this reason, the round-robin based approach was chosen for 2.2.
This commit is contained in:
@ -582,6 +582,13 @@ void Worker::set_maxwait(unsigned int maxwait)
|
||||
this_unit.max_poll_sleep = maxwait;
|
||||
}
|
||||
|
||||
// static
|
||||
int Worker::pick_worker_id()
|
||||
{
|
||||
static int id_generator = 0;
|
||||
return atomic_add(&id_generator, 1) % this_unit.n_workers;
|
||||
}
|
||||
|
||||
bool Worker::post(Task* pTask, Semaphore* pSem, enum execute_mode_t mode)
|
||||
{
|
||||
// No logging here, function must be signal safe.
|
||||
|
||||
Reference in New Issue
Block a user