Happy Monday! ☀️

Welcome to the 107 new hungry minds who have joined us since last Monday!

If you aren't subscribed yet, join smart, curious, and hungry folks by subscribing here.

Cloudflare's Big Pineapple platform manages over 250 billion DNS cache entries across its fleet. At that scale, a single wasted byte per entry costs 250+ gigabytes of memory. Through five successive optimizations to how cache entries are stored, the team cut per-entry memory footprint by over 50%, freeing roughly 100 terabytes across the fleet—equivalent to 130 Gen 13 servers worth of RAM.

The best part? They didn't trade speed for space. Insert throughput rose 43% and lookup latency dropped 19%. Fewer allocations and better memory locality meant the cache got faster while shrinking dramatically.

The challenge: DNS cache entries use types carrying unnecessary overhead—Vec<T> reserves capacity for growth that never happens, multiple separate lists waste pointers and padding, and DNS records stored as enums waste 120+ bytes padding per common record type.

Implementation highlights:

  1. Box over Vec: Replaced Vec and String with Box<[T]> and Box<str>, eliminating unused capacity fields and over-allocated heap space. Saved 64 bytes per entry and over 15 terabytes fleet-wide.

  2. Consolidated record sections: Merged answer, authority, and additional sections into a single list with u16 offsets instead of separate Box<[T]> lists with 8-byte pointers. Saved 28 bytes per entry.

  3. Optional record owners: Stored Option<Box<Name>> for record owners, omitting the owner when identical to the queried domain. Avoided heap allocations for the majority of records by inferring ownership at read time.

  4. Boxed large enum variants: Moved large DNS record types like NAPTR to heap allocations while keeping common types (A, AAAA) inline. Eliminated 120+ bytes of padding per common record.

  5. Wire format encoding: Stored record data as raw bytes in a single Box<[u8]> buffer with length prefixes, eliminating per-variant enum overhead and improving CPU cache locality. Most record types copy directly to responses without re-serialization.

Results and learnings:

  • Memory freed: 100 terabytes across the fleet by reducing per-entry footprint by over 50%, proving that at billion-entry scale, struct optimization matters enormously.

  • Performance gained: Insert throughput improved 43%, lookup latency dropped 19%—better packing and fewer allocations meant better CPU cache utilization and fewer pointer chases.

  • Tradeoff wisdom: Trading random access for sequential iteration through records added minimal complexity since DNS responses contain few records per entry, validating middle-ground solutions over all-or-nothing approaches.

The lesson: when you're caching a quarter trillion things, every byte counts—and sometimes squeezing memory actually makes your hot path faster. It's the rare optimization where you can have your cake, eat it too, and serve it in DNS wire format.

ARTICLE (compiler brain hacks)
An unlikely experiment

ARTICLE (django backend renaissance)
Some more things about Django I've been enjoying

ARTICLE (animations need physics)
CSS vs. JavaScript

ARTICLE (postgres goes kaboom)
Problems with large tables in Postgres

Want to reach 200,000+ engineers?

Let’s work together! Whether it’s your product, service, or event, we’d love to help you connect with this awesome community.

Brief: Anthropic released the Model Hardware Standard, a set of standardized drivers enabling AI agents to interface with and control physical devices beyond digital environments.

Brief: Meta scrapped its "Project OT" plan to slash teams by 60% with AI agents after they caused large-scale disruptions.

Brief: Apple refreshed Mac Studio and Mac mini with new M6 and M5 Ultra chips optimized for local AI inference, building on growing developer demand for on-device machine learning.

Brief: Hugging Face unveiled the Microduck, a $399 open-source duck robot with AI capabilities that ships before Christmas and can be trained using reinforcement learning.

This week’s tip:

Streaming data deduplication with probabilistic data structures - Use HyperLogLog and Bloom filters to detect duplicates in unbounded streams without materializing full state, enabling real-time data quality with minimal memory overhead.

Wen?

  • When processing high-volume event streams where exact deduplication is impossible

  • When storage or memory budgets prohibit maintaining full seen-set tables

  • When false negatives (duplicate misses) are tolerable but false positives cause data loss

When the root is strong, the fruit is sweet.
Bob Marley

That’s it for today! ☀️

Enjoyed this issue? Send it to your friends here to sign up, or share it on Twitter!

If you want to submit a section to the newsletter or tell us what you think about today’s issue, reply to this email or DM me on Twitter! 🐦

Thanks for spending part of your Monday morning with Hungry Minds.
See you in a week — Alex.

Icons by Icons8.

*I may earn a commission if you get a subscription through the links marked with “aff.” (at no extra cost to you).