| ▲ | eviks 3 hours ago |
| > Once we store a DNS response in the cache, however, we never modify it again. The capacity field serves no purpose, but still costs 8 bytes per Vec Were there no design discussions/reviews when the system was setup to catch trivial things like this? |
|
| ▲ | r3trohack3r 2 hours ago | parent | next [-] |
| Rob Pikes 5 Rules of Programming: Rule 1. You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is. Rule 2. Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest. Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.) Rule 4. Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures. Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. https://web.archive.org/web/20260314210910/https://users.ece... |
| |
| ▲ | eviks 2 hours ago | parent [-] | | > Data structures, not algorithms, are central to programming So you agree that they should've designed the system to use the appropriate data structure from the beginning? | | |
| ▲ | ecnahc515 2 hours ago | parent | next [-] | | Notice rules are ordered. You don't optimize until you know you need it. They started with a data structure they though would be fine. Clearly it was fine since it worked and they decided it was later worth optimizing. | |
| ▲ | an hour ago | parent | prev | next [-] | | [deleted] | |
| ▲ | win311fwg an hour ago | parent | prev [-] | | The existence of 1.1.1.1 speaks to a much larger design problem. If you want to talk about what should have been done, you need to step much, much further back. | | |
| ▲ | eviks an hour ago | parent [-] | | I don't want to step back and go off topic | | |
| ▲ | win311fwg 27 minutes ago | parent [-] | | "Should" cannot be evaluated in a vacuum. The only thing that would be off-topic is pretending that it can be. |
|
|
|
|
|
| ▲ | lbriner 3 hours ago | parent | prev | next [-] |
| It is often not worth optimising in the early days. You don't know how popular it will become, you might not know how many DNS records you will hold, it was possibly written in an earlier language and ported as-is. At the point someone queries the 100TB of RAM, then maybe it is worth revisiting but even that has risks. You have to design the migration path, have fallback mechanisms etc. |
| |
| ▲ | eviks 3 hours ago | parent [-] | | It's also often that you can avoid all those future migration/fallback risks and pains if you invest a little bit of design thinking upfront. So how would you decide which path to take in situations like this? | | |
| ▲ | suriyaG 3 hours ago | parent [-] | | It only looks super obvious in hindsight and the well explained blog post. when a team of 5 is tasked with getting a completely new DNS up at the scale and integrate well with cloudflare. if you spend cycles on nitty gritty opinions like this time to market goes out further and further out. some napkin math, 130 gen13 servers cost "only" ~$2.6M. relative to the importance of the 1.1.1.1 and the market at the time. that is nothing to cloudflare. this is not to say good system design does not matter. it very much does, but making that call at that time would've butchered the prodcut very much similar to google+, youtube etc. | | |
| ▲ | eviks 2 hours ago | parent [-] | | This one also looks pretty obvious "in foresight" (using the same tools that existed back then. Maybe owner dedupe might be less obvious and require a bit of knowledge and probing into actual data, but for rw vs ro you are fine knowing nothing?) and you forgot the napkin math re. how much your precious "time to market" would have been delayed by. It's also not nothing, otherwise it would never be optimized away now, but left as is. After all, wasting time on optimization delays "time to market" for other useful features. I also don't get the reference to YouTube, it's a very successful product, how was it butchered by good system design??? |
|
|
|
|
| ▲ | mhitza 3 hours ago | parent | prev | next [-] |
| Premature optimization argument fits right in. Now that memory is up to 10x more expensive it is worth considering optimizing programs with large memory footprint. |
| |
| ▲ | toast0 3 hours ago | parent | next [-] | | Using obviously better data structures the first time isn't premature optimization. | | |
| ▲ | mayli 17 minutes ago | parent | next [-] | | Maybe it's not that obviously better when it's impltd. | |
| ▲ | mannyv 3 hours ago | parent | prev [-] | | There was a reason for that field, but that reason never panned out. | | |
| |
| ▲ | eviks 3 hours ago | parent | prev [-] | | How does that fit? What would be the evil of not wasting memory for many years at 1x? | | |
| ▲ | jgrahamc 3 hours ago | parent | next [-] | | One of the "evils" of premature optimization is how much time you spend on the optimization vs. the benefit you get from it. If your goal is correctness and shipping fast and you're not memory constrained then spending time using the least amount of memory is a waste of time specifically because you want to ship fast. Another interesting thing that happens is you don't necessarily know what form your actual optimizations will need to take. Later when your systems grow you discover the suboptimal parts you hadn't optimized for. Very early on at Cloudflare I worked on part of the DNS infrastructure that took DNS records from the UI and got them in a state for actual authoritative serving. The system had been constructed anticipating Cloudflare having millions of customers with unique domains, but it had not been constructed for a single customer with a single domain with millions of records. This caused a periodic slow down in DNS record updating while the system churned on that one customer. In a different job I worked on a piece of optimization software that needed to keep track of "node" A is reachable from node "B". This had been implemented as a matrix (literally a malloced NxN matrix of ints storing 0 or 1) which worked really well for small systems. But you'd be out of memory really fast on a large project. I replaced the matrix with a hash table and all was good because the matrix was actually really sparse. | | |
| ▲ | stickfigure 3 hours ago | parent [-] | | Absolutely true, but I will say that LLMs have changed the equation somewhat. With a rather short prompt, claude/codex will take your code, write a harness, profile it, build experiments, profile those, and give some pretty solid advice which one to pick. Then integrate the changes. It's the kind of goal-directed, bite-sized job that LLMs excel at. Extremely low-commitment. Except for the whole "making changes in production at scale" problem, of course. |
| |
| ▲ | gbear605 3 hours ago | parent | prev [-] | | Engineers are expensive, especially good system engineers who are trained in your code base. Very possible that this just hadn't gotten to the top of the priority list. | | |
| ▲ | eviks 3 hours ago | parent [-] | | I don't understand why you need training on your code base to design a cache format for read only vs rw workloads, but anyway yours is a comment about neglect, not the "evil" that would happen if you did that design | | |
| ▲ | Spooky23 3 hours ago | parent | next [-] | | I see your point but disagree. Engineering is about constraints. Time, materials, labor, scope. The “evil” of premature optimization is that it’s a misapplication of priority. If I have an acute medical problem that needs attention, it’s not the right time to talk about chloresterol and statins, get my broken leg set. There’s always a tension between engineering management who needs to deliver a solution to the business and engineers who want to deliver a beautiful object. | |
| ▲ | win311fwg 3 hours ago | parent | prev [-] | | > I don't understand why you need training on your code base to design a cache format Because anyone willing to come in just to design your cache format is going to expect payment that is many multiples more than the engineers you already cannot afford? Long-term employees cost less, which brings them closer to being affordable, but you have to be able to keep them busy for long periods of time to realize that reduction in cost. A engineer who doesn't understand your codebase isn't going to be useful for very long. | | |
| ▲ | eviks 3 hours ago | parent [-] | | You explained why it's beneficial for other workloads, but the original point was about this specific design |
|
|
|
|
|
|
| ▲ | scott_meyer 2 hours ago | parent | prev | next [-] |
| Discussing trivial optimizations is a waste of valuable design time. You're never going to "forget" an optimization. The running system will remind you when the optimization is actually needed. |
|
| ▲ | ratmice 2 hours ago | parent | prev | next [-] |
| Boxed slice isn't really the most well known type/optimization,
There usually aren't that many vec's that it makes a big difference. |
|
| ▲ | micromacrofoot 3 hours ago | parent | prev [-] |
| it was working so no one thought to check |