5 ms·
Reading through the post they seem to have been hyper focused on compression ratios and reducing the payload size/network bandwidth as much as possible, but I d
by paxys 2y ago
Reading through the post they seem to have been hyper focused on compression ratios and reducing the payload size/network bandwidth as much as possible, but I don't see a single mention of CPU time or evidence of any actual measureable improvement for the end user. I have been involved with a few such efforts at my own company, and the conclusion always was that the added compression/decompression overhead on both sides resulted in worse performance. Especially considering we are talking about packets at the scale of bytes or a few kilobytes at most.
- xnx 2y agoDo the packets transmit through Discord's servers? Reducing their bill may be more important to them than user performance.
- bri3d 2y agoThey're going from 2+MB (for some reason) to 300KB - even if decompression is "slow," that's going to be a win for their bandwidth costs and for perceived speed for _most_ users. I was surprised to see little server-side CPU benchmarking too, though. While I'd expect overall client timing for (transfer + decompress) to be improved dramatically unless the user was on a ridiculously fast network connection, I can't imagine server load not being affected in a meaningful way.
- usernamear 2y agoThere already was compression before, through zlib. The findings, as showed in the post, was that Zstandard was also a lot more efficient than zlib from a cpu time standpoint.
- paxys 2y agoBandwidth costs for text messages, maybe, but how much data is that really compared to images, audio, video or even just the app's JS bundle?
- bri3d 2y agoPresumably that's all CDNed and therefore a lot cheaper to serve.
- bguebert 2y agoProbably not for live shared audio/video
- toast0 2y agoThe bandwidth probably doesn't really matter, but a 2MB must have blob vs a 300kB must have blob at the start of a connection is a big difference. The start of a tcp connection is limited by round trip times more than bandwidth. Especially for mobile, optimizing to reduce the number of round trips required is pretty handy.
- jhgg 2y agoThe 2mb case is pathological - an account on MANY servers with no local cache state (the READY payload works to only send data that's changed between when you've reconnected by having the client send hashes of data it knows.)
- BoorishBears 2y agoThey might have been getting murdered by egress fees in which case they'd be willing to make that sacrifice
- usernamear 2y agoSome of those payloads are much larger than a few kilobytes (READY, MESSAGE_CREATE etc.) There is a section and data on "time to compress". No time to decompress though.
- hiddencost 2y agoIt's almost certainly about hosting costs, not user facing value.
- ihumanable 2y ago> zstandard streaming significantly outperforms zlib both in time to compress and compression ratio. Time to compress is a measure of how long the CPU spends compressing. So this is in the blogpost
- koito17 2y agoI think the person is concerned with client-side compute, not just server-side compute. The article does not mention whether zstd has additional decompression overhead compared to zlib. Client-side compute may sound like a contrived issue, but Discord runs on a wide variety of devices. Many of these devices are not necessarily the latest flagship smartphones, or a computer with a recent CPU. I am going to guess that zstd decompression is roughly as expensive as zlib, since (de)compression time was a motivating factor in the development of zstd. Also the reason to prefer zstd over xz, despite the latter providing better compression efficiency.
- colechristensen 2y agozstd has faster decompression though I always thought lz4 to be the sweet spot for anything requiring speed, somewhat less compression ratio in exchange for very fast compression and decompression
- TulliusCicero 2y ago> I don't see a single mention of CPU time > Looking once again at MESSAGE_CREATE, the compression time per byte of data is significantly lower for zstandard streaming than zlib, with zlib taking around 100 microseconds per byte and zstandard taking 45 microseconds.
- lilyball 2y agoThat's compression time, the parent is talking about the end user so we want decompression time instead.
- monocasa 2y agoZstd is generally known for markedly faster decompression (as well as compression) than zlib. https://gregoryszorc.com/blog/2017/03/07/better-compression-with-zstandard/ https://gregoryszorc.com/blog/2017/03/07/better-compression-...
- dgfitz 2y agoI imagine it correlates with the end-user device specs, no?
- jhgg 2y agoI think one thing this blog post did not mention was the historical context of moving from uncompressed to compressed traffic (using zlib), something I worked on in 2017. IIRC, the bandwidth savings were massive (75%). It did use more server side CPU, and negligible client side CPU, so we went for it anyways as bandwidth is a very precious thing to optimize for especially with cloud bandwidth costs. Either way the incremental improvements here are great - and it's important to consider optimization both from transport level (compression, encoding) and also from a protocol level (the messages actually sent over the wire.) Also one thing not mentioned is client side decompression on desktop used to use a JS implementation of zlib (pako) to a native implementation, that's exposed to the client via napi bindings.
- Moru 2y agoCan't remember last time I had to worry about bandwidth for the servers. It only came up when talking about iPhones in the start because everyone was on realy slow mobile networks. Our company is usually very cost sensitive but all our server hotels so far has had unmetered bandwidth connected to a 100 Mbps interface. Has had zero complaints during the last 20 years even though we fill that one now and then. But we don't use any of the usual cloud offerings, only smaller local companies.
- dumbo-octopus 2y agoThe explicitly mention compression time. It’s actually lower in the new approach. > the compression time per byte of data is significantly lower for zstandard streaming than zlib, with zlib taking around 100 microseconds per byte and zstandard taking 45 microseconds
- yuliyp 2y agoI am fairly sure those should have been per kilobyte, not per byte.
- dvh 2y agoThose are atrocious numbers, that's only 23kB/s for the faster variant. It should have been GB/s not kB.
- refulgentis 2y agoFirst, let's establish a cheery mood: Happy Friday!!!! Second, I noticed we're extrapolating from a tossed out measurement in "microseconds per byte" here, of extremely small payloads, probably included fixed-cost overhead of doing anything at all. All leading up to: Is "atrocious" the right word choice here? :) More directly: do you really think Discord rolled out a compression algorithm that does 23 KB/s for payloads in the megabytes? Even more directly, avoiding being passive and just adopting your tone: this is atrocious analysis that glibly chooses to create obviously wrong numbers, then criticizes them as if they are real.
- Starlevel004 2y ago> More directly: do you really think Discord rolled out a compression algorithm that does 23 KB/s for payloads in the megabytes? yes, actually
- refulgentis 2y agothat's "yngmi" bait; you're suggesting it takes 2 minutes per intro payload. (2 MB / 20 KB/s ≈ 100 seconds = 1m40s)
- zarzavat 2y agoPerformance is probably the wrong lens. Mobile data is often expensive in terms of money, whereas compression is cheap in terms of CPU time. More compression is almost always the right answer for users of mobile apps.