mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-24 04:11:02 +01:00
OPTIM: stick-table: avoid atomic ops in stktable_requeue_exp() when possible
Since the task's time resolution is the millisecond we know there will not be more than 1000 useful updates per second, so there's no point in doing a CAS and a task_queue() for each call, better first check if we're going to change the date. Now we're certain not to perform such operations more than 1000 times a second for a given table. The loop was modified because this improvement will also be used to fix a bug later.
This commit is contained in:
parent
6342714052
commit
3238f79d12
@ -550,11 +550,17 @@ void stktable_requeue_exp(struct stktable *t, const struct stksess *ts)
|
||||
|
||||
/* set the task's expire to the newest expiration date. */
|
||||
old_exp = HA_ATOMIC_LOAD(&t->exp_task->expire);
|
||||
do {
|
||||
new_exp = tick_first(expire, old_exp);
|
||||
|
||||
/* let's not go further if we're already up to date */
|
||||
if (new_exp == old_exp)
|
||||
return;
|
||||
|
||||
while (new_exp != old_exp &&
|
||||
!HA_ATOMIC_CAS(&t->exp_task->expire, &old_exp, new_exp)) {
|
||||
__ha_cpu_relax();
|
||||
new_exp = tick_first(expire, old_exp);
|
||||
} while (new_exp != old_exp &&
|
||||
!HA_ATOMIC_CAS(&t->exp_task->expire, &old_exp, new_exp) &&
|
||||
__ha_cpu_relax());
|
||||
}
|
||||
|
||||
task_queue(t->exp_task);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user