mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-03 02:32:03 +00:00
MINOR: threads/queue: Get rid of THREAD_WANT_SYNC in the queue code.
Now that we can wake one thread sleeping in the poller, we don't have to use THREAD_WANT_SYNC any more. This gives a significant performance boost on highly contended accesses (servers with maxconn 1), showing a jump from 21k to 31k conn/s on a test involving 8 threads.
This commit is contained in:
parent
79321b95a8
commit
ecfe673f61
21
src/queue.c
21
src/queue.c
@ -200,7 +200,6 @@ static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
|
|||||||
{
|
{
|
||||||
struct pendconn *p = NULL;
|
struct pendconn *p = NULL;
|
||||||
struct server *rsrv;
|
struct server *rsrv;
|
||||||
int remote;
|
|
||||||
|
|
||||||
rsrv = srv->track;
|
rsrv = srv->track;
|
||||||
if (!rsrv)
|
if (!rsrv)
|
||||||
@ -240,11 +239,9 @@ static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
|
|||||||
px->lbprm.server_take_conn(srv);
|
px->lbprm.server_take_conn(srv);
|
||||||
__stream_add_srv_conn(p->strm, srv);
|
__stream_add_srv_conn(p->strm, srv);
|
||||||
|
|
||||||
remote = !(p->strm->task->thread_mask & tid_bit);
|
|
||||||
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
||||||
|
|
||||||
/* Returns 1 if the current thread can process the stream, otherwise returns 2. */
|
return 1;
|
||||||
return remote ? 2 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manages a server's connection queue. This function will try to dequeue as
|
/* Manages a server's connection queue. This function will try to dequeue as
|
||||||
@ -253,7 +250,7 @@ static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
|
|||||||
void process_srv_queue(struct server *s)
|
void process_srv_queue(struct server *s)
|
||||||
{
|
{
|
||||||
struct proxy *p = s->proxy;
|
struct proxy *p = s->proxy;
|
||||||
int maxconn, remote = 0;
|
int maxconn;
|
||||||
|
|
||||||
HA_SPIN_LOCK(PROXY_LOCK, &p->lock);
|
HA_SPIN_LOCK(PROXY_LOCK, &p->lock);
|
||||||
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
|
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
|
||||||
@ -262,13 +259,9 @@ void process_srv_queue(struct server *s)
|
|||||||
int ret = pendconn_process_next_strm(s, p);
|
int ret = pendconn_process_next_strm(s, p);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
remote |= (ret == 2);
|
|
||||||
}
|
}
|
||||||
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
||||||
HA_SPIN_UNLOCK(PROXY_LOCK, &p->lock);
|
HA_SPIN_UNLOCK(PROXY_LOCK, &p->lock);
|
||||||
|
|
||||||
if (remote)
|
|
||||||
THREAD_WANT_SYNC();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adds the stream <strm> to the pending connection list of server <strm>->srv
|
/* Adds the stream <strm> to the pending connection list of server <strm>->srv
|
||||||
@ -333,7 +326,6 @@ int pendconn_redistribute(struct server *s)
|
|||||||
{
|
{
|
||||||
struct pendconn *p, *pback;
|
struct pendconn *p, *pback;
|
||||||
int xferred = 0;
|
int xferred = 0;
|
||||||
int remote = 0;
|
|
||||||
|
|
||||||
/* The REDISP option was specified. We will ignore cookie and force to
|
/* The REDISP option was specified. We will ignore cookie and force to
|
||||||
* balance or use the dispatcher. */
|
* balance or use the dispatcher. */
|
||||||
@ -349,13 +341,9 @@ int pendconn_redistribute(struct server *s)
|
|||||||
__pendconn_unlink(p);
|
__pendconn_unlink(p);
|
||||||
p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
|
p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
|
||||||
|
|
||||||
remote |= !(p->strm->task->thread_mask & tid_bit);
|
|
||||||
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
||||||
}
|
}
|
||||||
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
||||||
|
|
||||||
if (remote)
|
|
||||||
THREAD_WANT_SYNC();
|
|
||||||
return xferred;
|
return xferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +356,6 @@ int pendconn_grab_from_px(struct server *s)
|
|||||||
{
|
{
|
||||||
struct pendconn *p, *pback;
|
struct pendconn *p, *pback;
|
||||||
int maxconn, xferred = 0;
|
int maxconn, xferred = 0;
|
||||||
int remote = 0;
|
|
||||||
|
|
||||||
if (!srv_currently_usable(s))
|
if (!srv_currently_usable(s))
|
||||||
return 0;
|
return 0;
|
||||||
@ -382,14 +369,10 @@ int pendconn_grab_from_px(struct server *s)
|
|||||||
__pendconn_unlink(p);
|
__pendconn_unlink(p);
|
||||||
p->target = s;
|
p->target = s;
|
||||||
|
|
||||||
remote |= !(p->strm->task->thread_mask & tid_bit);
|
|
||||||
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
task_wakeup(p->strm->task, TASK_WOKEN_RES);
|
||||||
xferred++;
|
xferred++;
|
||||||
}
|
}
|
||||||
HA_SPIN_UNLOCK(PROXY_LOCK, &s->proxy->lock);
|
HA_SPIN_UNLOCK(PROXY_LOCK, &s->proxy->lock);
|
||||||
|
|
||||||
if (remote)
|
|
||||||
THREAD_WANT_SYNC();
|
|
||||||
return xferred;
|
return xferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user