News for hackers. Stuff that matters.
Re:Saving Data: Reducing the Size of App Updates by 65% by rakoo on Wednesday December 07, 2016 @02:38AM (#13121113)
I 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.
Re:Saving Data: Reducing the Size of App Updates by 65% by cperciva on Wednesday December 07, 2016 @03:10AM (#13121192)
Sure, 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.)
Re:Saving Data: Reducing the Size of App Updates by 65% by i336_ on Wednesday December 07, 2016 @04:49AM (#13121494)
Ah, that's where it got its name :)

Really awesome utility.

Re:Saving Data: Reducing the Size of App Updates by 65% by KMag on Wednesday December 07, 2016 @10:31AM (#13123207)
I 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).

Re:Saving Data: Reducing the Size of App Updates by 65% by js2 on Wednesday December 07, 2016 @10:58AM (#13123459)
These 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.
Re:Saving Data: Reducing the Size of App Updates by 65% by rakoo on Wednesday December 07, 2016 @04:50AM (#13121500)
Ah, 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 !
Re:Saving Data: Reducing the Size of App Updates by 65% by CJefferson on Wednesday December 07, 2016 @03:38AM (#13121283)
I 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.
Re:Saving Data: Reducing the Size of App Updates by 65% by cperciva on Wednesday December 07, 2016 @03:59AM (#13121344)
It 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.
Re:Saving Data: Reducing the Size of App Updates by 65% by user5994461 on Wednesday December 07, 2016 @05:44AM (#13121679)
The 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.

Re:Saving Data: Reducing the Size of App Updates by 65% by adrianN on Wednesday December 07, 2016 @06:37AM (#13121847)
I looked in the 7z manual but couldn't find anything obviously related to this functionality. Would you mind giving a reference?
Re:Saving Data: Reducing the Size of App Updates by 65% by user5994461 on Wednesday December 07, 2016 @10:19AM (#13123107)
'gzip --rsyncable' for gzip.

I couldn't find the equivalent for 7z in a quick glance. It supports at least 5 compression algorithms so there is probably not a general option. Maybe one has to play with the advanced settings per algorithm, if they support it.

Re:Saving Data: Reducing the Size of App Updates by 65% by JoshTriplett on Wednesday December 07, 2016 @10:54AM (#13123428)
gzip --rsyncable does make gzip set boundaries so one change doesn't affect the entire rest of the file, just one block.

However, the resulting differences don't seem nearly as amenable to the bsdiff algorithm as the changes to the underlying uncompressed data. In almost all cases, you'll likely get better results with bsdiff on the uncompressed data (and bsdiff internally compresses its result).

Re:Saving Data: Reducing the Size of App Updates by 65% by user5994461 on Wednesday December 07, 2016 @05:07PM (#13126703)
Don't know about how bsdiff operate, maybe it's naive.

Good deduplication and diff algorithms have adaptive block size detection.

Re:Saving Data: Reducing the Size of App Updates by 65% by rakoo on Wednesday December 07, 2016 @04:44AM (#13121481)
If 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.
Re:Saving Data: Reducing the Size of App Updates by 65% by amelius on Wednesday December 07, 2016 @05:23AM (#13121623)
It should in theory work similarly on a tar file, no? (tar without compression)