diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-14 17:31:26 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-14 17:34:38 +0200 |
commit | 421b1f0a4126f4bc4dace3a892c9e59d6c54e590 (patch) | |
tree | 53a987244c3637449ed1d9364c111d7bc052c659 /src/resolve/resolved-dns-packet.h | |
parent | 9aeb1a541bbb08616af1b4e5495d4bd4bfed6490 (diff) | |
download | systemd-421b1f0a4126f4bc4dace3a892c9e59d6c54e590.tar.gz |
resolved: optimize layout of DnsPacket
We obviously have lots of those, so even small savings add up.
Bitfields are dropped because they don't give any memory savings due to
alignment requirements (but would still require more complex to access).
/* size: 184, cachelines: 3, members: 28 */
/* sum members: 172, holes: 1, sum holes: 4 */
/* sum bitfield members: 4 bits (0 bytes) */
/* padding: 7 */
/* bit_padding: 4 bits */
↓
/* size: 176, cachelines: 3, members: 28 */
Diffstat (limited to 'src/resolve/resolved-dns-packet.h')
-rw-r--r-- | src/resolve/resolved-dns-packet.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h index e9820795c0..6e7175c754 100644 --- a/src/resolve/resolved-dns-packet.h +++ b/src/resolve/resolved-dns-packet.h @@ -71,21 +71,23 @@ struct DnsPacket { DnsAnswer *answer; DnsResourceRecord *opt; + /* For support of truncated packets */ + DnsPacket *more; + /* Packet reception metadata */ + usec_t timestamp; /* CLOCK_BOOTTIME (or CLOCK_MONOTONIC if the former doesn't exist) */ int ifindex; int family, ipproto; union in_addr_union sender, destination; uint16_t sender_port, destination_port; uint32_t ttl; - usec_t timestamp; /* CLOCK_BOOTTIME (or CLOCK_MONOTONIC if the former doesn't exist) */ - /* For support of truncated packets */ - DnsPacket *more; + bool on_stack; + bool extracted; + bool refuse_compression; + bool canonical_form; - bool on_stack:1; - bool extracted:1; - bool refuse_compression:1; - bool canonical_form:1; + /* Note: fields should be ordered to minimize alignment gaps. Use pahole! */ }; static inline uint8_t* DNS_PACKET_DATA(const DnsPacket *p) { |