]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stktable: index table names using compact trees
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 11:50:03 +0000 (13:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2025 07:23:46 +0000 (09:23 +0200)
Here we're saving 64 bytes per stick-table, from 3392 to 3328, and the
change was really straightforward so there's no reason not to do it.

include/haproxy/stick_table-t.h
src/stick_table.c

index 572ed96fec5343d04d90a3447b9c35dfacbb0caf..19dc600885dea5c08f72aa2220ec9ba3ecf3f684 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef _HAPROXY_STICK_TABLE_T_H
 #define _HAPROXY_STICK_TABLE_T_H
 
+#include <import/cebtree.h>
 #include <import/ebtree-t.h>
 
 #include <haproxy/api-t.h>
@@ -166,13 +167,13 @@ struct stksess {
 
 /* stick table */
 struct stktable {
-       char *id;                 /* local table id name. */
-       size_t idlen;     /* local table id name length. */
+       char *id;                 /* local table id name, indexed by <id_node> below. */
+       size_t idlen;             /* local table id name length. */
        char *nid;                /* table id name sent over the network with peers protocol. */
        struct stktable *next;    /* The stick-table may be linked when belonging to
                                   * the same configuration section.
                                   */
-       struct ebpt_node name;    /* Stick-table are lookup by name here. */
+       struct ceb_node  id_node; /* Stick-table are lookup by name here, indexes <id> above. */
        struct pool_head *pool;   /* pool used to allocate sticky sessions */
        struct task *exp_task;    /* expiration task */
        struct task *sync_task;   /* sync task */
index b3ff76878d329269664126e46d4f86bd31966a4d..73352d8776ee2b4a79c39ff4f9c0af13f913cba9 100644 (file)
@@ -14,9 +14,9 @@
 #include <string.h>
 #include <errno.h>
 
+#include <import/cebis_tree.h>
 #include <import/ebmbtree.h>
 #include <import/ebsttree.h>
-#include <import/ebistree.h>
 
 #include <haproxy/api.h>
 #include <haproxy/applet.h>
@@ -64,7 +64,7 @@ static THREAD_LOCAL struct stktable_key static_table_key;
 static int (*smp_fetch_src)(const struct arg *, struct sample *, const char *, void *);
 struct pool_head *pool_head_stk_ctr __read_mostly = NULL;
 struct stktable *stktables_list;
-struct eb_root stktable_by_name = EB_ROOT;
+struct ceb_root *stktable_by_name = NULL;
 
 #define round_ptr_size(i) (((i) + (sizeof(void *) - 1)) &~ (sizeof(void *) - 1))
 
@@ -74,23 +74,12 @@ struct eb_root stktable_by_name = EB_ROOT;
  */
 void stktable_store_name(struct stktable *t)
 {
-       t->name.key = t->id;
-       ebis_insert(&stktable_by_name, &t->name);
+       cebis_item_insert(&stktable_by_name, id_node, id, t);
 }
 
 struct stktable *stktable_find_by_name(const char *name)
 {
-       struct ebpt_node *node;
-       struct stktable *t;
-
-       node = ebis_lookup(&stktable_by_name, name);
-       if (node) {
-               t = container_of(node, struct stktable, name);
-               if (strcmp(t->id, name) == 0)
-                       return t;
-       }
-
-       return NULL;
+       return cebis_item_lookup(&stktable_by_name, id_node, id, name, struct stktable);
 }
 
 /*