]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: sample: reduce struct sample by filling a hole
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Nov 2026 18:55:00 +0000 (19:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 1 Dec 2026 07:17:13 +0000 (08:17 +0100)
The struct sample keeps a 32-bit hole at the beggining after the flags,
and ends up with a 32-bit member (opt) that imposes extra padding.
Let's just move opt into the hole and reduce it from 152 to 144 bytes.
That counts more than it seems because a lot of expression processing
creates copies of samples or memset() them (e.g. in every pattern match
in ACLs).

include/haproxy/sample-t.h

index 631959558e5e72a69c7975e948d38d03f1c28cbe..6d3f92b1f87a657f727c422cfaae92cddfbc0b1d 100644 (file)
@@ -248,6 +248,7 @@ union smp_ctx {
  */
 struct sample {
        unsigned int flags;       /* SMP_F_* */
+       unsigned int opt; /* fetch options (SMP_OPT_*) */
        struct sample_data data;
        union smp_ctx ctx;
 
@@ -259,7 +260,6 @@ struct sample {
        struct proxy *px;
        struct session *sess;
        struct stream *strm; /* WARNING! MAY BE NULL! (eg: tcp-request connection) */
-       unsigned int opt; /* fetch options (SMP_OPT_*) */
 };
 
 /* Descriptor for a sample conversion */