Live data from Hacker News

Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

blog.cloudflare.com

151–160 of 305 posts

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#151
post #68

This is the right way to deliver software. Produce working product first, validate the idea, stabilize the business, start generating profit, and then you can start optimizing your costs. In fact optimization is by far the easiest part of the process because there are many system programming experts on this HN thread who consider these optimizations to be trivial.

Or optimize a bit earlier and prevent having to scale out to a bazillion systems.

You're never going to get promoted with that attitude!

I'm joking...but not entirely. It sounds impressive on a promo packet when you say you've saved 100 TB of RAM / $$$ through whatever technique. But it sounds a lot less impressive when you say if this system grows to this size in x years, I will have saved 100 TB, especially when no one yet knows how large the system will really be in that time or what the cost of RAM will be. I dunno, maybe if you say that x years ago, I made a decision that now is saving us 100 TB, that's kinda impressive, but you're also getting credit for it x years after you did the work. It also doesn't have the implication that it must be inherently complex/hard because some other smart person chose the other way. And there is a bias to care more about recent accomplishments. So I don't really think it'd be valued the same at all.

Also, in general big tech (at least Google) prefers growing the userbase over improving efficiency. Periodically efficiency is rewarded, e.g. when RAM cost suddenly balloons or some big must-have feature has suddenly used up capacity planned for something else. You get rewarded for doing efficiency work on demand, not eagerly.

I once got a $100 peer bonus for finding 100,000 cores that were essentially stranded by an accounting error in another team's migration script.

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#152
post #150
post #140

Earlier quoted context omitted.

My house is a ~700 sqft. condominium, gov. subsidized for lower income individuals, and even my mortgage is more than 300k… maybe I’m just basing my info off of coastal city prices, but is it possible to buy a reasonably nice home located in a reasonably nice amerikkkan city… for $300k in 2026?

That would buy you thousands of square feet and often several acres within 20 minute drive to a lot of US city downtown areas.

Not from what I've seen. The desirable neighborhoods are 500-600k. Suburbs outside major city

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#153
post #4

This is why system programming still matters. Looks like they're missing the obvious optimisation of putting the record data right after the CacheEntry members instead of allocating memory separately though. But that might just be me as a C-programmer talking and not be all that easy in Rust.

I wish more programming languages implemented record types as seen in databases, where dynamically sized fields are packed into a contiguous area of memory. The CloudFlare manually implemented a clumsy version of this. Wouldn’t it be nice for the compiler to manage this for you in the same way that your database engine does when it saves a “row”?

> dynamically sized fields are packed into a contiguous area of memory

Are you able to explain this? Do you mean an N sized array where each entry is either a value or a pointer to a value where the 'pointed-to' values are after the end of the array?

I'm trying to underatnd how you'd do this without having to parse M-1 elements to get the Mth entry if you did a [{size0, value0}, ....., {sizeN, valueN}] arrangement

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#154
post #96
post #52

Earlier quoted context omitted.

AFAIK (at least it worked like that some 10 years ago) the captive portal just intercepts the HTTP page load and inserts its own content (most often a 302). So it just has to be a http web page. Firefox uses http://detectportal.firefox.com/canonical.html Relevant support page, though light in details: https://support.mozilla.org/en-US/kb/captive-portal Edit: ah, yes, DNS can be hijacked too (requires intercepting out…

I've had reliable success by using http://neverssl.com to force a basic HTTP connection for kickstarting a public WiFi portal login, although I have to disable NextDNS (iOS) too.

I use good ol example.org

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#155
post #4

This is why system programming still matters. Looks like they're missing the obvious optimisation of putting the record data right after the CacheEntry members instead of allocating memory separately though. But that might just be me as a C-programmer talking and not be all that easy in Rust.

[deleted]

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#156
Not sure what they use to hold the cache key and entry. If a hashmap is used, then a radix tree (adaptive radix tree) would be better in saving memory space. Most of content of the qname field of the CacheKey is hostname, like www.site.com. The reverse version com.site.www fits nicely in navigation path of a radix tree. The common prefixes like "com." are shared and compressed in the parent nodes of the tree.

Even a BTree with compressed prefix keys can save space in the qname.

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#157
post #68

This is the right way to deliver software. Produce working product first, validate the idea, stabilize the business, start generating profit, and then you can start optimizing your costs. In fact optimization is by far the easiest part of the process because there are many system programming experts on this HN thread who consider these optimizations to be trivial.

Or optimize a bit earlier and prevent having to scale out to a bazillion systems.

You can build foundations that aren't extermely optimal but have future optimisations in mind.

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#158
post #150

Earlier quoted context omitted.

That would buy you thousands of square feet and often several acres within 20 minute drive to a lot of US city downtown areas.

Not from what I've seen. The desirable neighborhoods are 500-600k. Suburbs outside major city

You didn't read what I said.

I mentioned acres of land. You normally don't have multiple acres of land in the suburbs.

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#159
post #150

Earlier quoted context omitted.

That would buy you thousands of square feet and often several acres within 20 minute drive to a lot of US city downtown areas.

Not from what I've seen. The desirable neighborhoods are 500-600k. Suburbs outside major city

Desirable neighborhoods are by definition expensive. The trick is to find a neighborhood you like where your home can just be a home and not a top-heavy investment.

Acknowledging this isn’t always easy or possible, but just pointing out that this is a self reinforcing problem.

Re: Saving 100 terabytes of memory by optimizing 1.1.1.1's DNS cache

#160
post #70

Earlier quoted context omitted.

Unfortunately, Rust is not a good choice for this kind of tricks. This is where Zig shines. In Rust, you can’t even use proper arenas, which can help a ton with allocations. Cloudflare started to pick Zig recently, for projects, that have memory constraints.

> In Rust, you can’t even use proper arenas You definitely can and this is done a lot. What you might mean is that you can't use standard library's collections with them (this is getting stabilized soon!) and have to use third-party, but that is a different thing than "can't use arenas". > Rust is not a good choice for this kind of tricks. Rust can do those tricks, but it's true that it is hard than in C or Zig. That…

Stabilized soon, really? They did not stabilize it after 10 years and were thinking about different approach. I thought it’s dead.
Post reply on HN