← Back to Blog

Introducing zig-bsdiff

We just pulled zig-bsdiff out into its own open source project. It’s the SIMD-accelerated, lightning fast, zstd-powered binary diff/patch tool behind Electrobun’s differential updater, now available for any app pipeline or simple CLI use without bringing the whole runtime along.

Repo: github.com/blackboardsh/zig-bsdiff

Why we built it

Electrobun apps ship small updates (as small as 4KB) by diffing the tarballs of two versions and downloading only the patch. Traditional bsdiff leans on bzip2; we wanted tighter patches and quicker apply times. zig-bsdiff keeps the proven bsdiff/bspatch shape, but swaps in zstd and SIMD-friendly paths to cut size and accelerate diff time.

We've also updated the suffix sort to use multi-threaded libsais which is up to 450x faster than the original quick suffix sort

When shipping Co(lab) updates github's CI runner diffs two 350MB tar files in 30 seconds generating an average patch size of 28KB. Save your bandwidth.

What’s inside

  • zstd compression. Smaller patches and ~2-3x faster decompression than bzip2.
  • SIMD-accelerated hot paths. Tuned for speed when generating and applying patches.
  • TRDIFF10 format. A zstd-backed flavor compatible with our update flow; still supports classic bsdiff patches.
  • Cross-platform builds. macOS (arm64/x64), Linux (arm64/x64), Windows (x64) binaries via releases.
  • CLI + library. Use the shipped binaries or import the Zig code into your own projects.

How to use it

Grab a release from GitHub to get the bsdiff and bspatch binaries:

./bsdiff oldfile newfile patchfile --use-zstd
./bspatch oldfile newfile patchfile

Format detection is automatic (zstd vs bzip2). Want to tinker? Clone the repo, run bun run setup, then bun run build or bun run build:release; tests live under bun run zig-test and bun run test.

Where it fits

zig-bsdiff is now a shared building block alongside Electrobun and GoldfishDB. If you need fast, small binary patches—for app updates, asset packs, or data files—give it a try and let us know how it performs on your workloads.