From: Willy Tarreau Date: Thu, 30 Apr 2026 06:48:35 +0000 (+0200) Subject: BUG/MINOR: vars: don't store the variable twice with set-var-fmt X-Git-Tag: v3.4-dev11~95 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=37b1f15d851bac39395cc6b5a29fbad868a45637;p=haproxy.git BUG/MINOR: vars: don't store the variable twice with set-var-fmt In 2.5, commit 9a621ae76d ("MEDIUM: vars: add a new "set-var-fmt" action") introduced the set-var-fmt action. However the storage (by then sample_store_stream() now var_set()) was added for this specific branch without any return, leaving the sample copied again over the variable via the final call, meaning that the variable name is looked up twice and for proc scope, the lock is taken twice for each call to set-var-fmt. This patch removes the first call. Tests show that proc operations now jump from 1.1M to 1.67M/s on a 64-core CPU (lower lock contention), while other scopes only observe a modest improvement with few vars (10 goes from 43.3M to 44M/s). This could be backported. --- diff --git a/src/vars.c b/src/vars.c index ea7822770..453c5f2ed 100644 --- a/src/vars.c +++ b/src/vars.c @@ -1050,7 +1050,6 @@ static enum act_return action_store(struct act_rule *rule, struct proxy *px, smp_set_owner(&smp, px, sess, s, 0); smp.data.type = SMP_T_STR; smp.data.u.str = *fmtstr; - var_set(&rule->arg.vars.desc, &smp, rule->arg.vars.conditions); } else { /* an expression is used */