OPTIM: resolvers: move the eb32 node before the data in the answer_item

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.
This commit is contained in:
Willy Tarreau 2021-10-21 14:45:28 +02:00
parent dd362b7b24
commit 9628c42284

View File

@ -111,6 +111,7 @@ struct resolv_answer_item {
uint16_t weight; /* SRV type weight */ uint16_t weight; /* SRV type weight */
uint16_t port; /* SRV type port */ uint16_t port; /* SRV type port */
uint16_t data_len; /* number of bytes in the <data> field below */ uint16_t data_len; /* number of bytes in the <data> field below */
struct eb32_node link; /* linking node */
union { union {
struct sockaddr_in in4; /* IPv4 address for RTYPE_A */ struct sockaddr_in in4; /* IPv4 address for RTYPE_A */
struct sockaddr_in6 in6; /* IPv6 address for RTYPE_AAAA */ 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 */ 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 resolv_answer_item *ar_item; /* pointer to a RRset from the additional section, if exists */
struct list attached_servers; /* attached server head */ struct list attached_servers; /* attached server head */
struct eb32_node link; /* linking node */
}; };
struct resolv_response { struct resolv_response {