]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: pahole optimization for DnsQuery
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 May 2021 09:28:17 +0000 (11:28 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 14 May 2021 14:31:16 +0000 (16:31 +0200)
Change from the last three commits:

/* size: 312, cachelines: 5, members: 46 */
/* sum members: 296, holes: 5, sum holes: 16 */
   ↓
/* size: 288, cachelines: 5, members: 46 */
/* sum members: 286, holes: 1, sum holes: 1 */

It's not a big difference, but we might have quite a few queries in flight,
so let' make this a bit more efficient.

src/resolve/resolved-dns-query.h

index fcc57a0e0d21219c5d2dd51d7ee319da61d36d8f..43a833a08a2bd6ef012b7e8f1cc0e2bac57ae6a8 100644 (file)
@@ -33,14 +33,6 @@ struct DnsQueryCandidate {
 struct DnsQuery {
         Manager *manager;
 
-        /* When resolving a service, we first create a TXT+SRV query, and then for the hostnames we discover
-         * auxiliary A+AAAA queries. This pointer always points from the auxiliary queries back to the
-         * TXT+SRV query. */
-        DnsQuery *auxiliary_for;
-        LIST_HEAD(DnsQuery, auxiliary_queries);
-        uint8_t n_auxiliary_queries;
-        int auxiliary_result;
-
         /* The question, formatted in IDNA for use on classic DNS, and as UTF8 for use in LLMNR or mDNS. Note
          * that even on classic DNS some labels might use UTF8 encoding. Specifically, DNS-SD service names
          * (in contrast to their domain suffixes) use UTF-8 encoding even on DNS. Thus, the difference
@@ -63,8 +55,12 @@ struct DnsQuery {
         uint64_t flags;
         int ifindex;
 
-        DnsTransactionState state;
-        uint8_t n_cname_redirects;
+        /* When resolving a service, we first create a TXT+SRV query, and then for the hostnames we discover
+         * auxiliary A+AAAA queries. This pointer always points from the auxiliary queries back to the
+         * TXT+SRV query. */
+        int auxiliary_result;
+        DnsQuery *auxiliary_for;
+        LIST_HEAD(DnsQuery, auxiliary_queries);
 
         LIST_HEAD(DnsQueryCandidate, candidates);
         sd_event_source *timeout_event_source;
@@ -76,18 +72,26 @@ struct DnsQuery {
         uint64_t answer_query_flags;
         DnsProtocol answer_protocol;
         int answer_family;
+        DnsPacket *answer_full_packet;
         DnsSearchDomain *answer_search_domain;
+
+        DnsTransactionState state;
         int answer_errno; /* if state is DNS_TRANSACTION_ERRNO */
-        bool previous_redirect_unauthenticated;
-        bool previous_redirect_non_confidential;
-        bool previous_redirect_non_synthetic;
-        DnsPacket *answer_full_packet;
+
+        unsigned block_ready;
+
+        uint8_t n_auxiliary_queries;
+        uint8_t n_cname_redirects;
+
+        bool previous_redirect_unauthenticated:1;
+        bool previous_redirect_non_confidential:1;
+        bool previous_redirect_non_synthetic:1;
+        bool request_address_valid:1;
 
         /* Bus + Varlink client information */
         sd_bus_message *bus_request;
         Varlink *varlink_request;
         int request_family;
-        bool request_address_valid;
         union in_addr_union request_address;
         unsigned block_all_complete;
         char *request_address_string;
@@ -102,12 +106,13 @@ struct DnsQuery {
 
         /* Completion callback */
         void (*complete)(DnsQuery* q);
-        unsigned block_ready;
 
         sd_bus_track *bus_track;
 
         LIST_FIELDS(DnsQuery, queries);
         LIST_FIELDS(DnsQuery, auxiliary_queries);
+
+        /* Note: fields should be ordered to minimize alignment gaps. Use pahole! */
 };
 
 enum {