]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: resolvers: move the eb32 node before the data in the answer_item
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Oct 2021 12:45:28 +0000 (14:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Oct 2021 13:28:24 +0000 (15:28 +0200)
perf top shows that we spend a lot of time trying to read item->type in
the lookup loop, because the node is placed after the very long name,
so when the node is found, no data is in the cache yet. Let's simply
move the node upper in the struct. This results in the CPU usage of
resolv_validate_dns_response() to drop by 4 points.

include/haproxy/resolvers-t.h

index 48bff0c73aa184ecf2f52f740eadbde190c92a42..2e53d918cd5a989dc04145fad56b52a3dd7f6c44 100644 (file)
@@ -111,6 +111,7 @@ struct resolv_answer_item {
        uint16_t        weight;                      /* SRV type weight */
        uint16_t        port;                        /* SRV type port */
        uint16_t        data_len;                    /* number of bytes in the <data> field below */
+       struct eb32_node link;                       /* linking node */
        union {
                struct sockaddr_in in4;              /* IPv4 address for RTYPE_A */
                struct sockaddr_in6 in6;             /* IPv6 address for RTYPE_AAAA */
@@ -119,7 +120,6 @@ struct resolv_answer_item {
        unsigned int    last_seen;                   /* When was the answer was last seen */
        struct resolv_answer_item *ar_item;          /* pointer to a RRset from the additional section, if exists */
        struct list     attached_servers;            /* attached server head */
-       struct eb32_node link;                       /* linking node */
 };
 
 struct resolv_response {