mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
MINOR: listener: resync with the thread index before heavy calculations
During heavy accept competition, the CAS will occasionally fail and we'll have to go through all the calculation again. While the first two loops look heavy, they're almost never taken so they're quite cheap. However the rest of the operation is heavy because we have to consult connection counts and queue indexes for other threads, so better double-check if the index is still valid before continuing. Tests show that it's more efficient do retry half-way like this.
This commit is contained in:
parent
b657492680
commit
77e33509c8
@ -1324,6 +1324,16 @@ void listener_accept(struct listener *l)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* tests show that it's worth checking that other threads have not
|
||||||
|
* already changed the index to save the rest of the calculation,
|
||||||
|
* or we'd have to redo it anyway.
|
||||||
|
*/
|
||||||
|
n1 = _HA_ATOMIC_LOAD(thr_idx_ptr);
|
||||||
|
if (n0 != n1) {
|
||||||
|
n0 = n1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* here we have (r1,g1,t1) that designate the first receiver, its
|
/* here we have (r1,g1,t1) that designate the first receiver, its
|
||||||
* thread group and local thread, and (r2,g2,t2) that designate
|
* thread group and local thread, and (r2,g2,t2) that designate
|
||||||
* the second receiver, its thread group and local thread.
|
* the second receiver, its thread group and local thread.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user