News for hackers. Stuff that matters.
Re:An Unbelievable Demo by cperciva on Friday June 04, 2021 @02:38AM (#27391200)
Reminds me of when Apple started providing "smaller size updates" to OS X. I was curious about the details since my doctorate had touched on the topic, so I worked my contacts (I had a few in Apple engineering from the FreeBSD / OS X relationship) and after a few months I got back as answer: "We're using a tool called bsdiff, are you familiar with it?" I was indeed, since I was the author of said tool.

(Just to be clear, there was no license violation involved in this case; just a lack of awareness of the provenance of the open source software they were using.)

Re:An Unbelievable Demo by vanderZwan on Friday June 04, 2021 @02:57AM (#27391305)
While I'm not the author of anything, I did on one occasion share Russ Cox' articles on regexes with a fellow developer, only for that developer to reply "that guy is making a mountain out of a molehill, just use re2".
Re:An Unbelievable Demo by jffry on Friday June 04, 2021 @08:43AM (#27393004)
For anybody who's lost: Russ Cox is the original author of re2, a fast C++ library implementing regular expressions that are guaranteed to run in linear-time.

There's a collection of articles they wrote talking about regexes and various pitfalls: https://swtch.com/~rsc/regexp/

Re:An Unbelievable Demo by deathanatos on Saturday June 05, 2021 @12:39AM (#27402237)
This is still relevant today, too. The last several JavaScript vulns. that people at my company have had to upgrade around were because of accidentally quadratic regex in JavaScript. One poor library[1] was attempting to match a header whose grammar was a whoppingly complex,

  1#token
(this is in the HTTP spec's notation: it means 1 or more `token`s, comma separated with optional whitespace around the comma) and hit this, by trying to split the incoming values with,

  / *, */
I was shocked that this wasn't compiled to a DFA. (I checked, too: my JS exhibited the behavior in the bug report.)

This is, I also think, another reason why "simple" text protocols are not really so simple. The grammar above is "trivial", and yet, this is the end result. I don't feel like the library is particularly at fault: I doubt I would have caught this in code review.

[1]: https://www.npmjs.com/advisories/1748

Re:An Unbelievable Demo by phkahler on Friday June 04, 2021 @09:23AM (#27393339)
>> "that guy is making a mountain out of a molehill, just use re2"

That's an odd thing about the tech world, it's accessible. As you get better in different areas you are actually more and more likely to make contact with important people (big names? people who did important stuff?). This can creep up on you if you're not aware what level you're operating at. It can be a small world.

Re:An Unbelievable Demo by toddmatthews on Friday June 04, 2021 @09:40AM (#27393480)
yep. i remember asking a question on google groups about some AppEngine query early on a Saturday morning thinking, "this will never be answered".

about 15 minutes later Guido van Rossum answered my question.

Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @10:17AM (#27393844)
Also, people who say so-and-so company (usually Google) is hard to contact for support, or that they require expensive support contracts before they'll talk to you, have likely never tried sending email to the appropriate mailing list for the product.

It's amazing how often doing this completely bypasses any corporate first-line-support structure in the way, and just puts the email right into the inbox of the line engineers working directly on the product. It's also amazing how quickly those line engineers reply. (It's as if they treat "replying to random messages on the product mailing list" as their highest-priority job. Or maybe it's just that they're technical people, and my questions are usually very nerd-snipe-y, and get them hooked.)

Re:An Unbelievable Demo by deanCommie on Friday June 04, 2021 @01:56PM (#27396596)
It's a great concept in theory, but in practice...find me the email list for Google Photos. Or Google Keep. These are two Google products that I use daily (including paying for one!)
Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @02:26PM (#27397110)
Well, yeah, there does have to be a public mailing list.

My point was that there are often public mailing lists, where engineers with real engineering problems could discuss those problems with the engineers responsible for the product/service; and yet the engineer with the problem nevertheless doesn't even think of using the mailing list to reach out, but instead decides to go through regular customer-service support channels to get their problem solved.

Re:An Unbelievable Demo by Silhouette on Friday June 04, 2021 @05:42PM (#27399407)
I've also got serious problems (as in, the service we're paying real money for is totally broken) solved by contacting a friend who worked at $BIG_COMPANY and the friend escalating internally.

The point is that I shouldn't have to bypass the official channels that way. These organisations are operating at the level of ad-hoc individual heroics, which is the lowest tier in terms of organisational maturity. In a start-up where everyone has to do everything and no-one has worked anything out yet, that's completely understandable. In a many-billions-of-dollars business with enough influence that someone's quality of life or the viability of some other business could be profoundly affected if the giant screwed up, we should be demanding better by now.

Re:An Unbelievable Demo by pvorb on Saturday June 05, 2021 @07:44PM (#27409364)
What I've seen so far is that companies in general don't get better at this as they grow. They add process over process and each level makes tackling 90 percent of support requests more efficient (for them) but the more difficult requests just don't make it to the person who could help.
Re:An Unbelievable Demo by Silhouette on Saturday June 05, 2021 @10:05PM (#27410094)
That is certainly one pattern we see repeating, but I don't think it's what is happening with many of the big tech companies. They're opting for the alternative where tackling 90% of support requests is highly efficient because those requests are simply routed to /dev/null.

In one sense, it's hard to blame them. After all, if no-one who matters to their revenue stream is actually going to change behaviour because of that dismissive policy, it saves them all the overheads of providing useful support and costs them practically nothing. It's just good business, right?

What is strange is how they've got away with it for so long and most people still don't seem to be switching to alternatives, even as the tech giants casually squash them without even noticing. At some point around here, the words "competition" and "regulation" enter the room.

Re:An Unbelievable Demo by filoleg on Friday June 04, 2021 @03:08PM (#27397755)
>Well, yeah, there does have to be a public mailing list.

Imo, this is not scalable or sustainable, and mailing lists are not a replacement for adequate customer support.

The only reason sending emails directly to mailing lists for specific Google products works is precisely because those mailing lists are not public and not flooded with bajillions of emails from the general public. So those who send the emails are already somewhat pre-screened in a way, because if you know that mailing list email address in the first place, you are very unlikely to send something like "my cousin couldn't remember password to their google photos account, can you fix this please". That's why everything there ends up being read and addressed. If those mailing lists were public, then they would be just as useless and ineffective as the current customer support routes currently are for Google.

Tl;dr: mailing lists for specific products are a nifty workaround for the time being, but they aren't a good sustainable solution for shitty customer support. Making those mailing lists public will not only not help solving the problem, it will just make those mailing lists as ineffective as the current customer support. There is no "one weird trick" to solve the customer support adequacy issues with Google,it has to be an actual customer solution that won't be easy and will take time.

Re:An Unbelievable Demo by derefr on Saturday June 05, 2021 @02:52PM (#27407604)
I'm confused about what you mean about "public." I'm just a regular guy with no connections to Google, other than being a GCP customer. I found the mailing list addresses for each GCP service listed directly in the support documentation. Literally anyone who has GCP problems would end up finding those addresses, if 1. they clicked on the "help" button and went through the workflow presented, and 2. didn't first pay for extended white-glove support and then immediately reach for it for any problem that came up.

By my thinking, that's a "public" mailing list. They're not hiding it from you. The opposite, really — they're trying to get everyone to know and use it, by making it free to any GCP customer, while the actual CSR kind of support requires paying for a subscription to a higher support tier. The mailing list, presented in Google Groups format, is literally what GCP calls their "support forum." It's supposed to take on all comers, including dumb customer asks.

Re:An Unbelievable Demo by vinodc on Sunday June 06, 2021 @03:06PM (#27415437)
I think the disconnect here is that Google engineers are much more likely to answer the low volume of technical "nerd-snipey" questions from other developers than the high volume of non-technical questions they'd get from the general public for something like Gmail.
Re:An Unbelievable Demo by zikzak on Saturday June 05, 2021 @09:57AM (#27405073)
Lately, I've seen a few open source projects go this way: GitHub issues, this gets unwieldy so they create a Discord, this descends into chaos so they nominate a community volunteer, issues are then filtered by thier preferences, etc.

I like Discord, especially in the early days, you can reach out to the principal dev, etc. But it soon seems like they either disappear to get work done (good) or spend all thier time on it (bad). Either way you end up with chaos.

Re:An Unbelievable Demo by derefr on Saturday June 05, 2021 @02:56PM (#27407635)
Our company has a Discord, but we employ a professional Community Manager for it. When community members bring issues up:

1. they're encouraged to do so in public, so that other community members can help if possible, and/or so bots can reply with suggested FAQ answers;

2. the Community Manager will answer with the company line for questions the company has set answers to (e.g. "when are you releasing X?" or "why is [abusive DoS-like pattern of requests to your service] not working?");

3. otherwise, if the Community Manager knows the answer for sure off the top of their head, they'll give the answer;

4. and if not, the Community Manager relays the question to an engineer in our Slack, where we either have an answer off the top of our heads, or we file it as an issue.

Seems to work just fine for us so far.

Some of the engineers are also sometimes in the Discord (and we're all registered to it), but other than the Community Manager, it's not our job to be in there.

Re:An Unbelievable Demo by mercer on Friday June 04, 2021 @11:19AM (#27394465)
I've more than once had one of the core developers of Elixir or Phoenix answer a question almost right after asking it in the Slack or IRC channel. I often felt a bit embarrassed to take up their time considering how 'basic' these questions were.

I've had similar experiences in other language/framework communities. It's amazing how helpful some of these very productive people can be to random chat visitors :)!

Re:An Unbelievable Demo by mst on Saturday June 05, 2021 @12:57PM (#27406652)
The trick is to remember that they're almost certainly working on that stuff because they enjoy making users happy, so they're also doing support for the same reason.

I do feel a little bit embarrassed if it turns out they're reading the docs to me, but I feel embarrassed about that whether it's an expert or a fellow n00b ;)

Re:An Unbelievable Demo by mercer on Sunday June 06, 2021 @05:06AM (#27411804)
Haha, I've found that to be good training to always read the docs first.
Re:An Unbelievable Demo by TimPC on Friday June 04, 2021 @12:10PM (#27395086)
It depends on your issue. We got good support emailing with the TF Lite team on a neural net bug. I think if you’re interacting with open source in a value add way google support is often quite good. If you’re looking for support for integrating for sales or classic customer support it can be terrible to non-existent.
Re:An Unbelievable Demo by shaftway on Friday June 04, 2021 @01:18PM (#27396059)
> If you’re looking for support for integrating for sales or classic customer support it can be terrible to non-existent.

> Maybe it's just that they're technical people, and my questions are usually very nerd-snipe-y, and get them hooked.

Integrating sales or classic customer support is boring.

I mean, I get that it pays the bills, but when I've got a million priorities, boring work that I don't really get credit for goes to the bottom of the pile.

Re:An Unbelievable Demo by rantwasp on Friday June 04, 2021 @12:07PM (#27395054)
no. there is a big difference between having support and having someone that is passionate about something helping you out. support should be there and should be available from the simplest issues to the most complicated things about A PRODUCT. you will not get much traction if you ask the same things to the people expert person on a mailing list.
Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @12:15PM (#27395141)
I guess I've never needed "support" in that sense.

I almost always solve problems with the products/services we use myself — up to and including forking the vendor's codebase to fix their shit for them — because it's almost always the fastest way to do things. I've already been working with their product for a while, and I already know exactly what my own problem is. Provided I also know the language their code is written in, that translates to being able to code a patch myself, faster than I can get someone on their end to comprehend the problem I'm having.

That applies up until the point where there's a problem surface that's just plain inaccessible to me (i.e. the inside of a proprietary mobile app or SaaS service), at which point I have to reach out to tell them that it's broken / missing something on their end. (And even then, if I have a spare hour and access to the offending binary, I'll reverse-engineer it a bit to see if I can hotpatch it while waiting for them to get back to me.)

I suppose, for people who don't think this way, there can be value in "support." But IMHO there's more value in just hiring some DevOps engineers who do think that way. Then all the easy "support" requests get handled in-house, and so you'll only ever need the kind of "support" that involves direct bug reports to the engineers from the vendor who built the thing.

Re:An Unbelievable Demo by rantwasp on Friday June 04, 2021 @03:23PM (#27397947)
you are by definition a power user. if your product is for power users that’s fine.

if your product is targeted to everyone but only power users can figure it out when there is an issue... well you have a problem.

also, being able to figure something out != you should figure it out. your time is limited and the complexity of remembering all those things that you figured out (even if you have the time) will quickly overwhelm you. unless it’s literally your job to support the product you should care about the interface of the product and what guarantees it makes

re: hiring devops engineers. i’m sorry, what? if my email suddenly does not work I’m supposed to hire a devops engineer now?

Re:An Unbelievable Demo by gowld on Friday June 04, 2021 @01:59PM (#27396649)
> forking the vendor's codebase to fix their shit for them

How well does that work for a hosted cloud service?

Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @02:21PM (#27397036)
I mean, if I know that some service is using e.g. Redis under the covers, and the problem is in Redis itself, then submitting a patch upstream to Redis; waiting for it to get upstreamed; and then telling the cloud host to update their Redis version to solve the problem — is usually a pretty reliable path.

But otherwise, like I said, that's when "the problem surface is inaccessible."

Re:An Unbelievable Demo by 0xEFF on Friday June 04, 2021 @11:16AM (#27394429)
The appropriate mailing list email address is often listed right at the bottom of the blog article too.
Re:An Unbelievable Demo by criddell on Friday June 04, 2021 @10:52AM (#27394167)
I read about a similar example this week. Some news orgs filed FOIA requests for Dr. Anthony Fauci's email and I was surprised at how many regular people just emailed him and got a response.

Apparently the guy answers about 1000 emails per day.

Re:An Unbelievable Demo by noir_lord on Sunday June 06, 2021 @09:10AM (#27412914)
Had this happen to me, I was complementing a particular debugger I liked on an IRC channel and some random id said "Thanks, it's a lot of work".

I didn't realise the author of that tool was in the channel - kinda neat that we have such a flat open structure at times.

Re:An Unbelievable Demo by nostrademons on Friday June 04, 2021 @12:29PM (#27395329)
Google interviewing lore is that there once was a candidate who was asked if they were familiar with MapReduce and replied "MapReduce? Is that like Hadoop?"

Reportedly, this was also a major factor in Google's strategy shift to open-source a lot of their infrastructure (GRPC, Bazel, TensorFlow, LevelDB, etc.)

Re:An Unbelievable Demo by YakBizzarro on Friday June 04, 2021 @02:55AM (#27391299)
I used and hacked bsdiff in the past. A very neat concept and tool, many many thanks for making and publishing it!
Re:An Unbelievable Demo by grupthink on Friday June 04, 2021 @07:25AM (#27392504)
Yeah, but did you win the Putnam?
Re:An Unbelievable Demo by mishraprince on Friday June 04, 2021 @09:55AM (#27393616)
That one reply in that flame war is still hilarious so many years later. To anyone who didn't get the reference of Putnam https://news.ycombinator.com/item?id=35079
Re:An Unbelievable Demo by abalaji on Friday June 04, 2021 @11:22AM (#27394493)
wow, that’s one helluva response. HN in 2007 seems like a wonderful place
Re:An Unbelievable Demo by libria on Friday June 04, 2021 @01:38PM (#27396333)
Like the featured article, HN threads - then and now - are pretty low-key in regards to participant introductions. Usernames are just text, no flair or qualifiers so the focus is on the speaker's content itself. `libria` is free to converse with `cperciva` as an equal peer which is nice, because most other IRL forums I'd be acutely aware that's not the case ;)
Re:An Unbelievable Demo by Hallucinaut on Friday June 04, 2021 @04:25PM (#27398690)
I like the part where someone calls cperciva's idea bad, he says what's bad about it then the founder of Dropbox replies saying they're just starting and it sounds like they're in the same space.

Pretty good bad idea

Re:An Unbelievable Demo by ksec on Friday June 04, 2021 @03:51PM (#27398319)
Interesting this reply and one above are from accounts that is rather new.
Re:An Unbelievable Demo by bredren on Friday June 04, 2021 @10:23AM (#27393902)
tldr;

In 2007, an academic argues with PG and others. After long exchange, academic defensively states their own achievements.

Another user challenges academic with GP question, to which academic provides unexpected affirmative response.

Re:An Unbelievable Demo by yuppiemephisto on Friday June 04, 2021 @11:30AM (#27394588)
I don't agree with that phrasing. A lot of people on that thread seemed sure cperciva was some arrogant dickhead bound for failure, but tarsnap is going a lot stronger than many of them are. Also people in the thread were amazingly rude to him, while he seemed pretty polite to me.
Re:An Unbelievable Demo by cperciva on Friday June 04, 2021 @12:14PM (#27395136)
I think you're giving cperciva too much credit. He was just as arrogant as people thought, and he was definitely defensive.
Re:An Unbelievable Demo by yjftsjthsd-h on Friday June 04, 2021 @12:17PM (#27395177)
I wonder how many people will downvote you without looking at your username?
Re:An Unbelievable Demo by belter on Friday June 04, 2021 @01:16PM (#27396012)
This thread is turning out to be better than the one from 2007...
Re:An Unbelievable Demo by ghoward on Saturday June 05, 2021 @12:39PM (#27406496)
I can't downvote, but I am glad you said something because I didn't look!
Re:An Unbelievable Demo by gowld on Friday June 04, 2021 @02:02PM (#27396706)
But does he refer to himself in the third-person? That's the pinnacle of arrogance.
Re:An Unbelievable Demo by cperciva on Friday June 04, 2021 @02:40PM (#27397350)
cperciva rarely refers to himself in the third person, but it does occasionally happen.

More often, we refer to ourselves in the first person plural.

Re:An Unbelievable Demo by yuppiemephisto on Friday June 04, 2021 @08:22PM (#27400729)
TIL. Sounded reasonable to me, so quite likely I'm arrogant too.

Tarsnap's still there though, so I'd say that's a good defense.

Re:An Unbelievable Demo by cperciva on Friday June 04, 2021 @09:56PM (#27401232)
I didn't say that I was wrong.

But I was having a bad day, and I said things in a different and more abrasive way than I normally would.

Re:An Unbelievable Demo by pjerem on Friday June 04, 2021 @10:53AM (#27394178)
I think you missed the point. Scroll up, it's the same guy :)
Re:An Unbelievable Demo by bredren on Friday June 04, 2021 @11:03AM (#27394287)
Haha. I did. That’s wonderful.
Re:An Unbelievable Demo by mercer on Friday June 04, 2021 @11:20AM (#27394476)
But just the once, though, huh?
Re:An Unbelievable Demo by eska on Sunday June 06, 2021 @04:44AM (#27411725)
I sent an email to a corporate Steam email address, asking whether I’d be allowed to post a screenshot from half-life in a computer graphics shading thesis. Ended up with a response from Gabe Newell, CEO, shortly after, and another engineer who invented skeletal animation, all excited to talk about it with some random kid
Re:An Unbelievable Demo by scrollaway on Friday June 04, 2021 @07:03PM (#27400075)
I first encountered bsdiff when working on reverse engineering Blizzard MPQs (their proprietary packaging format, long abandoned now in favour of other stuff). They started using it for mpq patches some time in … 2007 I want to say? I was 16, had just started to code.

10-ish years later, I'm doing other stuff but still working with Blizzard-related tooling sometimes. I was talking to a Battle.net engineer about their latest-and-greatest game update protocols. He tells me they're thinking of adopting this great thing called bsdiff for the next version. I giggled a bit.

Anyway, hi! I implemented a version of your algorithm when I still barely knew wtf I was doing. https://github.com/jleclanche/python-ptch

Re:An Unbelievable Demo by rubicon33 on Friday June 04, 2021 @02:47AM (#27391255)
I don't understand what bsdiff does, or is. I am a software developer and I frankly have no clue what I would ever use bsdiff for! I've read what it does (libraries for building and applying patches to binary files) and still don't really have a sense for what the purpose of this tool is.

What are some real life use cases for it? When does a developer need such a tool?

Re:An Unbelievable Demo by throwaway3699 on Friday June 04, 2021 @02:54AM (#27391294)
Implementing software updates where you don't want to ship entire binaries again (and only the diff) would be one. In some video games the assets are also packed into massive binaries, so you don't want to ship gigabytes of data because you replaced one icon. Sadly many games do this anyway nowadays.
Re:An Unbelievable Demo by OldTimeCoffee on Friday June 04, 2021 @08:48AM (#27393048)
There are other solutions to this problem that the game industry uses. Binary diff patching is slow, incremental, involves large diffs and has the possibility of corruption. It was used back in the mid 90's (RTPatch was the big name), but really isn't used anymore because of the drawbacks.

Games frequently use an override directory or file. The patch contains only the files that have changed and is loaded after the main index and replaces the entries in the index with the updated ones. This is the most common way of doing a patch if it's not just overwriting the original files.

Some games load their file as a virtual filesystem and then the patch just replaces the entries in the virtual store with new ones. Guild Wars 2 works this way. This is only common in MMOs though.

Re:An Unbelievable Demo by formerly_proven on Friday June 04, 2021 @12:55PM (#27395687)
Games also use this because it's a straightforward way to almost guarantee a physical ordering of the files in the VFS, which is/was a common optimization strategy in the days of CDs and hard drives (profile what order the game needs files, then put them in the archive in exactly that order = tada, loading 4000 files behaves like a sequential read).

Another reason is that certain operating systems originating in the state of Washington have performance problems when you access small files or directories containing many files.

Re:An Unbelievable Demo by spinax on Friday June 04, 2021 @09:02AM (#27393165)
Circa 1995: we (company) used RTPatch as the users at the time were floppy based via Post, but enjoyed BBSes (and Prodigy, etc.) as it was a social community due to the nature of the software/industry. We could upload small RTPatch based updates and bugfixes to our tiny company BBS, users could dial in and download a rtpatch a lot faster than a floppy in the mail (besides avoiding the usual corrupt floppies that plagued the tech).
Re:An Unbelievable Demo by codefreakxff on Friday June 04, 2021 @09:38AM (#27393458)
Fun fact. This is not a new concept. Doom used overrides with their WAD file format. Mod authors could release their mod files replacing or adding content without stealing the game level files.

There may be prior art to that, but as a young coder that was the first time I’d seen it

Re:An Unbelievable Demo by erosenbe0 on Friday June 04, 2021 @09:14AM (#27393269)
Yes, overrides. I've heard talks on this at conferences with a couple big publishers. A lot of effort is put into it but obviously if we were distributing OS security updates like Apple it would be a whole different ballgame.
Re:An Unbelievable Demo by smoldesu on Friday June 04, 2021 @10:26AM (#27393932)
To my knowledge, most developers have gone back to binary patching for obfuscation purposes. Bethesda does this now (and ID, by extension), as well as many other developers I've seen.
Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @10:52AM (#27394172)
For at least the Nintendo Switch (not sure other modern conosles), the digital distribution infrastructure is built in terms of overlay packfiles. Games, updates, and DLC on disk are all single-file archives / filesystem images. The OS, when launching a game, mounts the game + its updates + its DLCs together as a transparent overlay filesystem. The game just sees a unified representation of its newest version, with whatever DLC has been installed, sitting under (IIIRC) /title.

I wouldn't be surprised if the other consoles also do things this way. It's a very sensible way to manage updates — especially when a game is running off of physical media but the updates are held in local storage. It also means there's no point where the update gets "merged in" to the base image, which means updates can be an atomic thing — either you have the whole update file downloaded + sig-checked (and thus it gets added to the overlay-list at boot) or you don't.

And, if all the consoles are doing it, I wouldn't be surprised if studios that do a lot of work on console don't just use that update strategy even on PC, for uniformity of QA, rather than for "obfuscation."

Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @10:42AM (#27394093)
Different things.

Games are directories/packfiles containing many individual files, mostly binary art assets, plus one executable that takes up a negligible proportion of the total size. When binary art assets in the directory/packfile are updated between versions, they don't really "change" in the sense that a source-code file might be changed a git commit; instead, they get replaced. (I.e. every file change is essentially a 100% change.)

The "binary diff patching" you're talking about the game industry using, was just the result of xor-ing the old and new packfiles, and then RLE-encoding the result (so areas that were "the same" were then represented by an RLE symbol saying "run of zeros, length N"). For the particular choices being made, this is indeed much less bandwidth-efficient than just sending a new packfile containing the new assets, and then overlay-mounting the new packfile over the old packfile.

bsdiff isn't for directories full of files that get 100% rewritten on update. (There's already a pretty good solution to that — tar's differential archives, esp. as automated by a program like http://tardiff.sourceforge.net/tardiff-help.html .)

Instead, bsdiff is for updates to executable binaries themselves (think Chrome updates), or to disk images containing mostly executable binaries + library code (think OS sealed-base-image updates — like CoreOS; or, as mentioned above, macOS as of Catalina + APFS.)

In these cases, almost all the files that change, change partially rather than fully. Often with very small changes. The patches can be much smaller, if they're done on the level of e.g. individual compiled function that have changed within a library, rather than on the level of the entire library. (Also, more modern algorithms than xor+RLE can be used — and bsdiff does — but even xor + RLE would be a win here, given the shape of the data.)

There's also Google's Courgette (https://www.chromium.org/developers/design-documents/softwar...), which goes further in optimizing for this specific problem domain (diffing executable binaries), by having the diff tool understand the structure/format of executables well-enough to be able to create efficient patches for when functions are inserted, deleted, moved around, or updated such that their emitted code changes size — in other words, at times when the object code gets rearranged and jumps/pointers must be updated.

The goal of tools like bsdiff or Courgette isn't to reduce an update from 1GB to 200MB for ~10k customers. The goal is to reduce an update from 10MB to 50KB for 100 million customers. At those scales, you really don't want to be sending even a 10MB file if you can at-all help it. The server time required to crunch of the patch is more than paid off by your peering-bandwidth savings.

Re:An Unbelievable Demo by marcan_42 on Friday June 04, 2021 @11:37AM (#27394687)
XOR+RLE is almost useless for binaries, because almost any change will cause instructions to be added or deleted, offsetting the entire binary after the first change, making the xor fail to converge. On top of that, these changes cause changes in addresses in the first part of the binary, so you end up with a zillion similar-looking xor deltas in the first part of the file that won't compress well with RLE.

In fact, if you use smarter compression than RLE, I wouldn't be surprised if the update was larger than the original binaries after the xor, as an offset xor will likely increase chaos (entropy) in the file, making it compresss worse than the original.

bsdiff was specifically designed to intelligently handle these situations, which is why it works.

Just tested it on Chromium from my package server (90.0.4430.72 vs 90.0.4430.212):

- Original binary: 266MB

- Gzipped binary: 106MB

- Gzipped XOR "patch": 228MB

- bsdiff patch: 47MB

Re:An Unbelievable Demo by derefr on Friday June 04, 2021 @02:14PM (#27396914)
Pedantic point: it's not "almost useless for binaries." It's almost useless for compiled, PIC binaries in modern executable formats like PE or ELF that allow for lots of load-time address-space rearrangement.

XOR-and-RLE works well for binaries from non-HLL languages (assembler, mostly) where — due mostly to early assemblers' lack of support for forward-referencing subroutine labels from the data section — subroutines tend to ossify into having defined address-space positions.

You can observe this by the fact that IPS-patchfile representations (which, while a different algorithm, is basically equivalent to XOR-and-RLE in its results) of the deltas between different versions/releases of old game ROMs written in assembly, are actually rather small relative to the sizes of the ROM images themsleves. The v1.1 ROMs are almost always byte-for-byte identical in ROM-image layout to the v1.0 versions, except for where (presumably) explicit changes were made in the assembler source code. Translated releases are the same (sometimes, but not always, because they were actually done by the localization team bit-twiddling the original ROM, because they didn't have access to the original team's assembly code.)

(This is also why archives that contain all the various versions/releases of a given game ROM, are highly compressible using generic compressors like LZMA.)

Re:An Unbelievable Demo by marcan_42 on Friday June 04, 2021 @03:56PM (#27398408)
Yes, if we're talking about 8-bit era games, certainly things were different back then and things rarely moved around in memory between versions :-)
Re:An Unbelievable Demo by OldTimeCoffee on Saturday June 05, 2021 @08:38AM (#27404413)
bsdiff is pretty similar to RTPatch, which is what the game industry used in the past. I'm unaware of what you're describing ever being used in practice, especially among large game houses.

That said, patches aren't really downloaded as standalone patches anymore because of Steam distribution. The way Steam handles it is documented, and if you're interested, it's available here: https://partner.steamgames.com/doc/sdk/uploading#Building_Ef...

But as an overview, Steam splits files into 1MB chunks and only downloads the 1MB chunks that have changed. The 1MB chunks are compressed in transit. Steam also dedups the 1MB chunks. I would assume that this works fine to manage the tradeoffs between size and efficiency.

Re:An Unbelievable Demo by Riverheart on Friday June 04, 2021 @10:58AM (#27394241)
That's how Tales of Maj'Eyal (ToME) supports modding
Re:An Unbelievable Demo by maccard on Friday June 04, 2021 @03:32AM (#27391491)
One of the reasons games do this is the data is compressed, so a "patch" might be indistinguishable from a real update.

Also, as a dev, you have no idea what version your users are updating _from_. You either need to generate some number of patches for every version you could be updating from, and figure out if you should just download the whole thing again in any of those cases anyway.

Re:An Unbelievable Demo by kevincox on Friday June 04, 2021 @07:34AM (#27392549)
There are solutions to this!

The simplest one is generate patches for recent versions, where recent can be years in the past. It is a linear operation but you only run it on release so it probably isn't a huge cost. You can also use some heuristics such as if if diff is >20% of the file just stop and force users still on that version to do a full update.

A second option is using zsync[1]. zsync is basically a precomputed rolling checksum. The client can download this manifest and they download just the parts of the file they need. This way you don't care about the source, if there is any similarity they can save resources.

And of course these can be combined. Generate exact deltas for recent versions and a zsync manifest for fallback.

[1] http://zsync.moria.org.uk/

Side note: One nice thing about zsync is that the actual download happens from the original file using range requests. This is nice for caching as a proxy only needs to cache the new data once. Is there a diff tool that generates a similar manifest for exact diffs? So instead of storing the new data in the delta file it just references ranges of the new file.

Re:An Unbelievable Demo by mewse on Friday June 04, 2021 @05:23AM (#27391958)
We usually don’t compress the data on disk; decompression would make loading and file access slower.

Instead, we just pack the uncompressed files together (frequently using normal zip in a no-compression mode) so that we can avoid needing to ask the OS to open and close files for us or examining the contents of a directory, both of which can be kind of startlingly slow (by video game standards) on some common OSes. Instead, we will generally cache the directory data from the zip file and just use that rather than go to disk.

(of course, the whole download/patch would all be compressed for network transfer, but files would then be decompressed during the installation process)

Re:An Unbelievable Demo by maccard on Friday June 04, 2021 @05:43AM (#27392059)
> We usually don’t compress the data on disk; decompression would make loading and file access slower.

_You_ mightn't but the last three AAA games I worked on do/did. PS5 expectes compressed files, and does HW decompression (ahem, mostly) on the fly.

Re:An Unbelievable Demo by Danieru on Friday June 04, 2021 @10:03AM (#27393704)
On the switch the reads are so slow the fastest loading requires atbleast mild compression. At least it did when I was testing packaging for my latest switch release. Despite the weak cpu.

Ps4 also did the compressed packages by default thing if I remember right. The upside there being ample cpu for decompression such that no compression was never fastest.

Re:An Unbelievable Demo by sumtechguy on Friday June 04, 2021 @10:28AM (#27393950)
I could see that keeping one big file would still be advantageous too in that environment. As a fopen on a set of small sized files plus read plus close over and over does add up. Just in cpu time and memory slack. Whereas treating it as one giant packed backing store would have advantages in speed. But at a cost of dev time. Even if you are compressing it as well could be an advantage. But I would expect there to be some spot where it crosses over from being an advantage to a disadvantage. I suspect it would be on small files/objects. But that would just be for speed. You may have to optimize for size in some cases. In the end it is usually better to build some test code and find out. Sometimes the results are what you expect. Sometimes you are spending time on things that do not matter anymore but were a big deal 20 years ago.
Re:An Unbelievable Demo by mewse on Friday June 04, 2021 @08:57PM (#27400927)
Oh, definitely! I haven’t worked on anything targetting a console past the PS3 generation and it completely slipped my mind that the latest gen consoles are architected specifically for streaming compressed data.

On the Windows/Mac/Linux title I’m working on now, I definitely measure a sizeable improvement to performance when loading from an uncompressed zip rather than from a compressed one. But even that could be down to the particular set of libraries I’m using to handle it.

Re:An Unbelievable Demo by tialaramex on Friday June 04, 2021 @06:20AM (#27392221)
> We usually don’t compress the data on disk; decompression would make loading and file access slower.

Did you actually benchmark this? It probably makes sense in your head, but on any vaguely modern hardware it's very unlikely to actually be true because of how exponential the memory hierarchy is.

Re:An Unbelievable Demo by bsenftner on Friday June 04, 2021 @07:17AM (#27392461)
Console hardware tends to have fast processors & cache but extremely slow RAM. Benchmarking a console's memory vs cache access tends to be one of the first things a team of principal game devs do and that information becomes bible for their titles.
Re:An Unbelievable Demo by PeterisP on Friday June 04, 2021 @06:18AM (#27392214)
IIRC in a bunch of scenarios compression makes loading and file access faster, as you're I/O limited and it's quicker to read less data and decompress. You do need to choose simple/quick/not-that-much-compressing compression algorithms for that.
Re:An Unbelievable Demo by greyhair on Friday June 04, 2021 @07:19AM (#27392470)
I have worked on a number of embedded products which ran from compressed root file system from eMMC. The overhead was a wash because RAM is so much faster than eMMC. What you spent in decompression time was covered by reduced eMMC access time.
Re:An Unbelievable Demo by xmprt on Friday June 04, 2021 @04:00AM (#27391616)
If you know a user is on version 3 and need to update to version 5, then why not just send out all the patches between 3 and 5? Why do you need to generate a new patch for each pair of versions.

It feels a bit egregious when I have to download a 100MB update just because a few characters were buffed or nerfed. More involved changes end up being over 1GB.

Re:An Unbelievable Demo by maccard on Friday June 04, 2021 @05:30AM (#27391992)
Because it's not just version 3 to version 5, it's version 3 to version 84.

Not all versions are made equal either - one might be a character buff, another might reorder assets in the "big huge binary blob file" for performance improvements. At a certain point, rather than downloading 30MB per update for 25 versions, and applying each incrementally (remember that you have to do them in order too), just download the full 1GB once and overwrite the whole whing.

Re:An Unbelievable Demo by uuidgen on Friday June 04, 2021 @08:20AM (#27392859)
Microsoft made sure in windows 10 that it's almost unusable without SSD. SO you big binary blob file have random r/w access.

Most backup software is able to do good binary deltas of arbitrary data for decades. Even dumb checkpointing resolves problem of downloading 25 versions - you download latest checkpoint and deltas from there.

Don't excuse poor design and programming, when you know a file structure, creating a differential update should be short task. With a tiny bit of algorithmic knowledge you could even optimize the process to only download needed assets inside of you big binary blob - if the asset was changed 7 times during your last 25 version you only need to download the last one.

Re:An Unbelievable Demo by xmprt on Friday June 04, 2021 @04:54PM (#27398954)
I'd personally like to see a company put a little thought into innovating how they store data on disk so patches can be quickly applied like with git while also not requiring a full source recompilation.
Re:An Unbelievable Demo by milankragujevic on Friday June 04, 2021 @04:05AM (#27391639)
It can go worse - some cheap and badly designed Android phones which download updates from every month when you first buy it until the current month, so maybe 10+ updates, but they aren't deltas (diffs) but full images. Ridiculous on so many levels.
Re:An Unbelievable Demo by beagle3 on Friday June 04, 2021 @07:27AM (#27392514)
It’s because they only tested updates from one version to the next, and not every version to every newer version.

It is a complete image, but phones today have nontrivial state that may be a problem - e.g. your baseband processor might have its own rom with its own update protocol, which changed between image 2 and image 7, so image 10 after image 1 will be unable to update the baseband.

Re:An Unbelievable Demo by mst on Saturday June 05, 2021 @01:08PM (#27406750)
If it's a cheap phone, I'd rather them do something brute force but reliable than try and be clever when they know they don't have the budget to QA it.

I honestly consider that a pretty reasonable trade-off.

Re:An Unbelievable Demo by oblio on Friday June 04, 2021 @03:42AM (#27391543)
> One of the reasons games do this is the data is compressed, so a "patch" might be indistinguishable from a real update.

Does this happen with more advanced compression algorithms? I've rsynced zip files of different versions of internal software and the diff was always much, much smaller than the entire package.

Re:An Unbelievable Demo by sgtnoodle on Friday June 04, 2021 @04:20AM (#27391691)
Zip files have all the metadata in a footer rather than a header. As a result, compressed files can be added and overwritten by appending to the file without disturbing already compressed data. Additionally, the "deflate" compression likely does not span across files, so files that did not change from version to version would have a similar compressed byte sequence, regardless of the order they were added to the archive.

I'd argue that zip is a relatively simple compressed archive format. Its simplicity is its charm and the reason it's so popular. More space-efficient algorithms would be less likely to be "patchable" as there would be less redundancy / structure in the compressed representation to exploit (the best compression seems like it would have similar properties of random data.)

Re:An Unbelievable Demo by versteegen on Friday June 04, 2021 @05:04AM (#27391882)
> Additionally, the "deflate" compression likely does not span across files

Clarification: .zip (unlike .tar.gz for example, or "solid" .7z) compresses each file separately, that's nothing to do with the compression algorithm used. In addition, DEFLATE, the LZ77-based compression which is by far most commonly used in .zip (and also by gzip) has a window size of 32kB (uncompressed). So yes, even if you used DEFLATE on a solid stream (e.g. zipped a .tar archive) it couldn't remove any cross-file redundancy once it's gone past the first 32kB of each file.

Re:An Unbelievable Demo by beagle3 on Friday June 04, 2021 @07:32AM (#27392536)
On the other hand HIgh voltage sid collection (hvsc) distributes a zipped zip;

Each file is 1k-20k, of which there are 40,000 or so. But they are catalogued in 3-4 deep directories, so if you just zip them, the metadata takes 30% or so of the zip.

But the metadata does compress very well, so they zip it again.

Re:An Unbelievable Demo by BBC-vs-neolibs on Friday June 04, 2021 @04:45AM (#27391799)
zstd strikes a nice balance here. It can inject markers in the bytestream to make it "rsync friendly", but one could just as well say "binary diff friendly".

zstd itself also has the (pretty new) ability to use a shared file as shorthand during compression. What that means in practice is that diffs can be REALLY tiny if you have the previous archive download.

Hi dang.

Re:An Unbelievable Demo by kevincox on Friday June 04, 2021 @07:43AM (#27392595)
In general yes. After the first difference the compressed streams will be basically random compared to each other. However there are numerous things that may avoid this.

For zip files each individual file is compressed independently. So unchanged files and prefixes don't need to be resent, even if once a file changes the entire tail end of it needs to be resent.

Some times compression algorithms "reset" periodically. For example the `gzip --rsyncable` patch. This basically resets the compression stream so that a change will only affect part of the compressed file. This does have a cost in terms of compressed size because the compressor can't deduplicate across resets. However if the resets are infrequent you can maintain fairly good delta transfer with little space overhead.

Additionally some delta transfer tools detect common compression and decompress the file "in transfer", performing the delta checks on the original file.

Re:An Unbelievable Demo by whelming_wave on Friday June 04, 2021 @03:54AM (#27391587)
Kind of an aside from your question, but binary patches not being much smaller than the full thing might happen more with modern games?

Heresay, but from what I've heard modern games may ship multiple copies of some assets with different levels or features so they can be loaded as a sequential read off the disk. While a block-oriented compression algorithm might sync up more reliably, if you're packing 200MB of assets for a level and they're all compressed to take advantage of the fact they'll be read sequentially could mean a change 25MB in would still ship ~175MB of changes.

Re:An Unbelievable Demo by uuidgen on Friday June 04, 2021 @08:31AM (#27392934)
So far in in most of the world even platter disks (which have really poor performance with modern Windows) are faster than network. Which means you can download description of the difference and reorder the file locally much faster than downloading it. Yes it needs the file to made in a way that is update friendly - most current compression algorithms can be configured like that. Yes, compression will be slightly lower, but you will save on both download size AND disk space, because right now most patches require you to download patch and then apply it, requiring twice the space. If you have 5% larger asset file but can patch it with a few memcpy on a mapped file it is a win in every way imaginable.

It is just really poor programming, nothing more. And it's everywhere. If find source >/dev/null takes 6 seconds there is no reason for gradle to take 2 minutes on a rebuild. If the dev is used to that, why would they even think about patch optimisation?

Re:An Unbelievable Demo by erosenbe0 on Friday June 04, 2021 @09:23AM (#27393337)
Windows game devs just traditionally didn't treat things with such granularity as you might find in a *nix environment where every little thing is a file. Content is then managed as larger blobs and you have a database of offsets or mappings.
Re:An Unbelievable Demo by maccard on Friday June 04, 2021 @03:56AM (#27391600)
I can't say, I'm not sure what compression we used on the last two games I worked on, sorry!
Re:An Unbelievable Demo by wruza on Friday June 04, 2021 @04:52AM (#27391826)
It is very unlikely that it was a “continuous” compression anyway. Continuous archives disallow random file access property, and games require exactly that for assets. You can’t decompress few gb on average to fetch a sprite of a cat.

The reason games (and software in general) do full downloads instead of binary patches is purely overdefensive and/or stupid. Store software could just check checksums after a patch and re-download only if they fail.

Re:An Unbelievable Demo by maccard on Friday June 04, 2021 @05:31AM (#27392004)
it's a UE4 game so the code is available on Github, I believe it was a header, with an encrypted index into a large binary blob of compressed data.
Re:An Unbelievable Demo by BlueTemplar on Friday June 04, 2021 @06:12AM (#27392183)
Well, whether they use full versions or diffs is also going to depend on how much they care about bandwidth.
Re:An Unbelievable Demo by erosenbe0 on Friday June 04, 2021 @09:06AM (#27393206)
Speaking from experience, AAA games have quite a bit of architecture behind them that can date back a decade or two. So you end up with some tradeoffs. The code may be well-tuned, resource efficient, and mostly crash proof, but some elements can be a bit dated relative to the size and scale of modern assets.
Re:An Unbelievable Demo by rubicon33 on Friday June 04, 2021 @10:44PM (#27401570)
Ahh, thank you for the explanation. That's an awesome tool!

I actually could really see using it, now that I understand what it does.

I've worked on some firmware projects where we did OTA updates and were guilty of shipping the entire binary. Luckily, even the entire binary was rather small, but still it would have been very cool to be able to create a diff and ship only the diff!

Re:An Unbelievable Demo by cperciva on Friday June 04, 2021 @03:16AM (#27391407)
Does it help if I tell you that bsdiff has saved end users somewhere over 10,000 years of waiting for software updates to download?
Re:An Unbelievable Demo by throw14082020 on Friday June 04, 2021 @03:26AM (#27391466)
yea well thats not enough! Xcode should be using it too. They make us download 12GB for every update.

/s end open source entitlement section

Thanks for your great work

Re:An Unbelievable Demo by codeulike on Friday June 04, 2021 @04:36AM (#27391768)
Its old now but here's a description from Chromium about something they use called Courgette which is similar/related to bsdiff

https://blog.chromium.org/2009/07/smaller-is-faster-and-safe...

The explanation here is pretty fascinating

https://www.chromium.org/developers/design-documents/softwar...

Re:An Unbelievable Demo by kevincox on Friday June 04, 2021 @07:46AM (#27392621)
The really cool TL;DR here is that courgette "disassembles" the binary before diffing. Basically turning internal references into symbolic references. This way adding an extra instruction to a function won't affect all of the relative addresses in surrounding code.
Re:An Unbelievable Demo by faeyanpiraat on Friday June 04, 2021 @02:53AM (#27391287)
If you have a game, where you have large packs of files (like a 2GB sized textures.pak), and in a patch you want to add 2 small things, you can just ship the differencd between the old anc new pack file, and skip transferring the rest.
Re:An Unbelievable Demo by OldTimeCoffee on Friday June 04, 2021 @08:54AM (#27393094)
They do this, but not as a binary diff. The new files are just shipped as an override of the old files that are loaded after the old files. It's substainally faster than applying a binary diff and file sizes really aren't a concern for the most part.

The game industry really hasn't used binary diffs and patching since the 90s when they used RTPatch.

Re:An Unbelievable Demo by mcguire on Friday June 04, 2021 @09:22AM (#27393327)
I've noticed.

Flight Simulator downloads tens of GB every time I start it. :-/

Re:An Unbelievable Demo by nix23 on Friday June 04, 2021 @04:28AM (#27391732)
Chrome and Chromium used bsdiff for updates:

https://www.chromium.org/developers/design-documents/softwar...

Re:An Unbelievable Demo by codeulike on Friday June 04, 2021 @04:35AM (#27391763)
The page says they use something called Courgette which is similar to bsdiff
Re:An Unbelievable Demo by nix23 on Friday June 04, 2021 @04:42AM (#27391788)
They used bsdiff before and now Courgette.
Re:An Unbelievable Demo by masklinn on Friday June 04, 2021 @05:07AM (#27391896)
> I don't understand what bsdiff does, or is.

It‘s a binary diff/patch utility.

> What are some real life use cases for it? When does a developer need such a tool?

Incrementally update binary files e.g. assets or runnable binaries instead if having to re-send the entire thing on every update so e.g. games, browsers, package managers, …

The standard diff/patch utilities are text-based and even when they do extend to binary data their algorithms and heuristics tend to be biased towards textual contents.

Bsdiff was built specifically with an eye towards executables.

Re:An Unbelievable Demo by gowld on Friday June 04, 2021 @02:07PM (#27396780)
Nowadays, Apple ships the whole 4GB OS, even when they have to ship 3 point updates in one month for small bugs.
Re:An Unbelievable Demo by warrenm on Friday June 11, 2021 @08:49AM (#27472571)
You obviously haven't done macOS updates in many years