When using a low hash-balance-factor value, it's possible to loop
many times trying to find the best server. Figures in the order of
100-300 times were observed for 1000 servers with a factor of 101
(which seems a bit excessive for such a large farm). Given that
there's nothing in that function that prevents multiple threads
from working in parallel, let's switch to a read lock. Tests on
8 threads show roughly a 2% performance increase with this.
unsigned int dn, dp;
int loop;
- HA_RWLOCK_WRLOCK(LBPRM_LOCK, &p->lbprm.lock);
+ HA_RWLOCK_RDLOCK(LBPRM_LOCK, &p->lbprm.lock);
if (p->srv_act)
root = &p->lbprm.chash.act;
}
out:
- HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &p->lbprm.lock);
+ HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &p->lbprm.lock);
return nsrv;
}