PitchHut
Log in / Sign up
bidiff
18 views
Efficient binary patching in safe Rust.
Pitch

Introducing bidiff, a powerful Rust library for generating and applying binary patches. Designed for software updates, it offers efficient memory use, supports large files, and is compatible with multiple compression formats. With rigorous fuzz testing and 100% safe Rust code, bidiff ensures reliable performance while minimizing update sizes.

Description

bidiff is an innovative set of Rust crates designed to generate and apply patches for arbitrary binary files, offering significant advantages for software deployment and updates. Built entirely in safe Rust, bidiff emphasizes safety, performance, and low resource consumption, while also supporting large inputs exceeding 2 GiB and incorporating multiple compression formats like Brotli and Zstandard through the comde crate.

Key Features:

  • 100% Safe Rust: Ensures memory safety and concurrency without sacrificing performance.
  • Extensive Fuzzing: Thorough testing strengthens security and reliability.
  • Efficient Memory Usage: Designed to minimize resource consumption for optimal performance.
  • Large File Support: Seamlessly manages patches for files over 2 GiB.
  • Multiple Compression Options: Choose from various advanced compression methods for efficient patching.

Performance Benchmarks:

bidiff has demonstrated superior performance when generating patch files compared to traditional methods like zstd. Below are benchmark results showcasing the efficiency and speed of bidiff against popular software sources:

OlderNewerNewer SizeNaive SizeNaive TimeBidiff SizeBidiff Time
Wine 4.18 sources4.19 sources201 MiB21.96 MiB81.300s182.26 KiB5.220s
Linux 5.3.13 sources5.4 sources894.68 MiB106.73 MiB448.145s6.14 MiB57.799s
Chromium 78 (build 97)(build 108)257.04 MiB79.73 MiB116.975s12.81 MiB158.867s
Firefox 71 (build 11)(build 12)192.49 MiB54.64 MiB78.039s6.56 MiB81.847s

Repository Structure:

The bidiff repository comprises three essential crates:

  • crates/bidiff: Contains the core diff algorithm with an optional serialization feature.
  • crates/bipatch: Facilitates the reading and applying of patches generated by bidiff.
  • crates/bic: A demonstration command-line interface for utilizing the above functions, utilizing comde for compression.

Advanced Algorithm:

Inspired by the bsdiff algorithm, bidiff distinguishes itself with efficiency improvements and memory optimizations.

  • Suffix Sorting: Utilizes a hand-optimized Rust implementation of the divsufsort algorithm for superior performance at reduced memory costs.
  • Parallel Processing: Capable of parallelizing both the sorting and scanning phases, maximizing resource utilization and enhancing speed during the diff process.

In summary, bidiff not only matches the high standards set by its predecessors but surpasses them, offering a faster, safer, and more efficient solution for binary file patching. Dive into bidiff to experience the power of modern Rust programming in practical applications!