7 ms·
It's a bit humbling to think that my "quick hack" is yielding bandwidth savings measured in petabytes per day.
by cperciva 10y ago
It's a bit humbling to think that my "quick hack" is yielding bandwidth savings measured in petabytes per day.
- woodruffw 10y agoWithout even opening this article, I knew that they would be using bsdiff. Thanks, truly, for creating such a tremendously useful tool.
- rakoo 10y agoI don't want to diminish your work, but today's improvement is not in using bsdiff (which they already did), but in using it file-by-file. That's where bsdiff can really shine, because both inputs looks way more similar.
- cperciva 10y agoSure, but running file-by-file is how bsdiff was designed to operate. (I wrote it for FreeBSD Update, which operates on a file-by-file basis, because I was paranoid about the problem I'd seen on Windows systems where an update was registered as "installed" but the system had not in fact been properly updated.)
- i336_ 10y agoAh, that's where it got its name :) Really awesome utility.
- KMag 10y agoI believe it stands for Byte Subtraction Diff, or something like that. As I remember, something like Bentley McIlroy diff is used to identify identical runs, and where there are short runs of bytes separating two runs that are identical between the two files, the bytewise subtraction of the short run is stored. The key observation is that when performing updates, large runs of machine code will be identical, with only relative offsets and absolute addresses changing. Code changes tend to shift huge pieces of binary code in parallel (by the same offset), so the bytewise subtraction expresses these shifts as many repeats of the same bytewise difference, which is then more easily compressed by zlib DEFLATE (or maybe another compressor... I forget the details).
- js2 10y agoThese programs were originally named bdiff and bpatch, but the large number of other programs using those names lead to confusion; I'm not sure if the "bs" in refers to "binary software" (because bsdiff produces exceptionally small patches for executable files) or "bytewise subtraction" (which is the key to how well it performs). Feel free to offer other suggestions.
- rakoo 10y agoAh, thanks for the information. I must admit I have never used it and never looked at what makes it different from other diff algorithms. Will definitely have a look at it !
- CJefferson 10y agoI find bsdiff works fine on concatenated files, because it searches for common sections over the whole file, rather than a traditional diff which just searches in order.
- cperciva 10y agoIt can work on concatenated files (if you avoid compression, which screws up everything) but it's usually more efficient to run bsdiff on individual matched pairs. The heuristic bsdiff uses for identifying "mostly-matching" regions is just that -- a heuristic -- and the larger the amount of data you have the higher the chance that bsdiff will try to build a mostly-matching region out of a coincidental sequence of matching bytes.
- rakoo 10y agoIf I'm not mistaken, an APK file is a zip archive, meaning that bsdiff was previously run on compressed stuff. As you can see in the article compressing content tends to make the output greatly differ (so much that gzip has a special option to make it more easily diffable, typically for rsync use). So bsdiff wasn't previously run on a concatenation of file; it was not used optimally.
- user5994461 10y agoThe archive tools (like 7z) have a special flag to allow for diff over the entire archive by external tools. The flag will modify the storage format, -kinda packing files/chunk together instead of just compressing into a huge block- so that tools can detect diff and same sections over the full archive. It's not well know but it is an absolute must known. e.g. for backup archive that goes over rsync, and change little over time.
- adrianN 10y agoI looked in the 7z manual but couldn't find anything obviously related to this functionality. Would you mind giving a reference?
- 10y ago
- amelius 10y agoIt should in theory work similarly on a tar file, no? (tar without compression)
- tener 10y agoI wonder how it translates to the money savings for Google and end users. A quick estimate based on prices quoted by Google Cloud Engine for Egress transfers ($0.08/GB) gives $183 million in yearly savings. Surely Google pays much less than that for their own transfers, but even if we assume they are paying 1% of that price it is still respectable. Pretty sure they are paying more than that though. EDIT: Found better estimates - Amazon Cloudfront is charging as low as $0.02/GB (on demand pricing), which translates to $46 million. Given very good knowledge Google has about their users and their vast infrastructure I'm guessing their costs are fraction of this. Anyone with domain knowledge that can comment on this?
- reitzensteinm 10y agoI'm very much not in the know (my personal experience tops out at renting gigabit lines at 95th percentile), but it's my understanding that at extreme scale, you're doing peering arrangements directly with ISPs, and provisioning a fixed amount of bandwidth with them. It wouldn't surprise me if Google was scheduling the majority of updates to take place in off peak times, when the bandwidth would simply be otherwise unused. If so, the cost to Google would be a rounding error of your estimate based on GCE traffic prices.
- walrus01 10y agoFor end users: Google is well aware of how many android phones are being used in the developing world. Something like 97% of the smartphone market in Myanmar is on android 4.2 and later. 1GB of data paid via scratch card is a lot of money for some people.
- TorKlingberg 10y agoI just tried bsdiff, and can I complain a little? I tried to diff two 1 GB files, and within a few seconds bsdiff was using enough memory to lock up my Ubuntu desktop. 10 minutes later I managed to get a text console and kill it. Maybe I should blame Ubuntu for letting a single process hose the system, but it was still annoying. Edit: bsdiff is documented to use memory 17x the file size.
- mistermann 10y agoInteresting, I had assumed this (runaway process and unable to do anything) only happens on Windows. (speaking in general)
- aviraldg 10y agoThis happens to me quite often on Linux and I've always wondered if there's a way to fix it. Is there?
- adrianN 10y agoman ulimit?
- superflyguy 10y agossh to the box then kill the process.
- derefr 10y agoI've often been unable to connect to SSH on a host for lack of available CPU/memory to spawn the SSH receiver process + the shell. It's especially a problem with AWS's tN.micro instances: when something thrashes them for long enough, they ratchet down to such a low CPU allocation that it will likely take hours before SSHD gets context-switched to enough times to start your process. By then, all sorts of timeouts will likely have killed your session.
- 10y ago
- dunham 10y agoApple has also been using bsdiff for incremental app updates (on device). I discovered bsdiff while poking around in one of their update files.
- taralx 10y agoOne wonders how much more they'd save if they could use the more sophisticated version you developed. ;-)