How we saved 100 terabytes of memory by optimizing 1.1.1.1’s DNS cache
Cloudflare details five Rust memory-layout changes to its 1.1.1.1 DNS cache — dropping Vec/String capacity fields, merging record lists with u16 offsets, omitting owner names when they match the query key, boxing large enum variants, and storing record data as wire-format bytes — cutting per-entry memory 56% and freeing roughly 100 TB fleet-wide. Performance also improved (inserts +43%, lookups −19%), though each change carries tradeoffs: allocator overhead and poor locality from boxing, sequential-only access for wire-format buffers, and records no longer self-contained.