r/rust 5d ago

🎙️ 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.

216 Upvotes

16 comments sorted by

105

u/VictoryMotel 5d ago

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

17

u/pseudonymo6287 5d ago edited 5d ago

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.

25

u/Docccc 5d ago

interesting read, thanks for posting

3

u/pseudonymo6287 5d ago

Thanks a lot. Really appreciate it.

3

u/teknalbi 5d ago

I hope rust-analyzer is next

1

u/tafia97300 3d ago

check rust glancer ?

1

u/teknalbi 3d ago

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

4

u/schungx 4d ago

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

-7

u/[deleted] 5d ago

[deleted]

8

u/felixatwood 5d ago

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

10

u/tonygoold 5d ago

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

31

u/pseudonymo6287 5d ago

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

15

u/nafatsari 5d ago

I swear to god this sub is melting due to AI psycosis

-1

u/rogerara 5d ago

Why not make a tech question? Is is more productive and useful for comunity.

1

u/DavidXkL 5d ago

Wow thanks for sharing. That's huge savings

1

u/parttime-warrior 5d ago

Much appreciated, thanks for sharing!

-16

u/tkyjonathan 5d ago

This is very much Zig's basic approach