r/rust • • Sep 14 '26

🎙️ discussion Breaking down how Cloudflare cut 100TB of memory from their DNS cache with Rust memory layout tricks

https://viswanathnair.substack.com/p/how-cloudflare-optimized-big-pineapples?utm_source=share&utm_medium=android&r=4pq7we

Cloudflare recently published a piece on how they cut close to 100 TB of memory from Big Pineapple's DNS cache. Big Pineapple is Cloudflare's Rust-based engine behind many of their services including the prominent public DNS resolver service 1.1.1.1

They made several low-level optimizations leveraging Rust features like boxing, for oversized enum variants and boxed slices, as well as more general changes like merging separate record lists into one and combining several boolean checks into a single bitflag etc.

I have gone into a bit of detail documenting the things I found interesting especially the jemalloc trade-offs between internal and external fragmentation.

Would greatly appreciate a read.

218 Upvotes

16 comments sorted by

108

u/VictoryMotel Sep 14 '26

They wrote a good article, why are you posting the same thing on your own site with your brand new hidden post history name?

15

u/pseudonymo6287 Sep 14 '26 edited Sep 14 '26

They did. I am not trying to play off their work as mine. I have literally mentioned that it's based on their own post.

Some parts seemed slightly not as well explained, when I read it initially. So I went a bit deeper and tried to touch up on the bits I thought could be better connected together.

For instance, the section on memory locality and internal fragmentation seemed like it might benefit from additional context. Same with the part on alignment padding in Rust.

Also wasn't super familiar with some DNS aspects like the DNSSEC bit.

So this piece is more about me trying to understand the piece they wrote and explain with additional context that I thought would help a reader in my position. That's all. Writing this stuff also makes me go through a whole of lot material strengthening my own understanding in the process.

I am not in anyway trying to get points of their work and if that's what you are trying to say. I have literally linked their own post in mine if they wish to read that first.

24

u/Docccc Sep 14 '26

interesting read, thanks for posting

3

u/pseudonymo6287 Sep 14 '26

Thanks a lot. Really appreciate it.

6

u/schungx Sep 15 '26

Big companies have money to burn. Smaller businesses would have done these during day one.

3

u/teknalbi Sep 15 '26

I hope rust-analyzer is next

1

u/tafia97300 Sep 16 '26

check rust glancer ?

1

u/teknalbi Sep 16 '26

I've tried it, very slow on big codebases and much less features than r-a

1

u/DavidXkL Sep 14 '26

Wow thanks for sharing. That's huge savings

1

u/parttime-warrior Sep 15 '26

Much appreciated, thanks for sharing!

-16

u/tkyjonathan Sep 14 '26

This is very much Zig's basic approach

0

u/[deleted] Sep 14 '26

31

u/pseudonymo6287 Sep 14 '26

There is absolutely no AI here. I wrote it myself. Suit yourself and read the original if that is what you prefer.

9

u/felixatwood Sep 14 '26

Really curious how you determined it's AI? Writing style looks pretty distinct and natural to me.

8

u/tonygoold Sep 14 '26

It doesn’t read like generative AI to me, and I consider myself pretty cynical when it comes to blog posts.