From: Willy Tarreau Date: Mon, 30 Nov 2026 18:56:25 +0000 (+0100) Subject: OPTIM: acl: only reset ctx and flags, not the whole sample X-Git-Url: https://git.kaiwu.me/web/%7B@url%7D?a=commitdiff_plain;h=903405ce3c3c09352503423cb67117a7e95a518d;p=haproxy.git OPTIM: acl: only reset ctx and flags, not the whole sample When evaluating an ACL, each expression starts with a memset(0) on the local sample before calling sample_process(). This is a waste, as the comment clearly says that the goal is to reset ctx and flags (i.e. 52 bytes), not the whole 144 (no need to erase a possibly older IPv6 address). Let's just do precisely that, because tests with many ACLs show that up to 1.5% CPU is spent there with a few tens of rules, and this memset() alone is responsible for 12-20% of the whole function's time for short matches. --- diff --git a/src/acl.c b/src/acl.c index 806aab4cf..2e069d631 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1083,7 +1083,8 @@ enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct acl_res = ACL_TEST_FAIL; list_for_each_entry(expr, &acl->expr, list) { /* we need to reset context and flags */ - memset(&smp, 0, sizeof(smp)); + memset(&smp.ctx, 0, sizeof(smp.ctx)); + smp.flags = smp.opt = 0; fetch_next: if (!sample_process(px, sess, strm, opt, expr->smp, &smp)) { /* maybe we could not fetch because of missing data */