]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: vars: don't store the variable twice with set-var-fmt
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 06:48:35 +0000 (08:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 07:11:05 +0000 (09:11 +0200)
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.

src/vars.c

index ea78227701052fd59c3d4d2dbd9effa73449d67e..453c5f2edd9a8c87e6d81daafa7e4bb4acdf4cbd 100644 (file)
@@ -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 */