4 ms·
I can just imagine a HN article 'Check out the crazy reason that this protocol is limited to 512MB!'
by chrisseaton 10y ago
I can just imagine a HN article 'Check out the crazy reason that this protocol is limited to 512MB!'
- Dylan16807 10y agoThere's barely any difference between a limit of 512MB vs. a limit of 2GB/4GB. Almost nobody is going to split that hair. You either design for reasonably-small messages, or you design for 'unlimited' size and go with a 64 bit size field. Either way shaving a few bits off the top is harmless. But you shouldn't be allocating 100MB+ upfront anyway. No matter how big of a message you allow.
- kccqzy 10y agoThis reminds me of the other article on HN recently. Using calloc makes it cheap because it's using the kernel's CoW. Of course you probably want to use that CoW functionality explicitly in this case.
- PhasmaFelis 10y agoYeah, everybody goes "640K OUGHT TO BE ENOUGH FOR ANYBODY, LOL." But if you're designing (say) a custom in-house protocol for transmitting telemetry, then "what happens in 20 years when someone tries use it for bulk data transfer for some reason" really shouldn't be higher on your list of priorities than "what happens when it receives literally any data besides what it was expecting." Hypothetical future expandability is good to consider, but not as important as present-day intended use.