Skip to content

dmg: add opt-in pure-Rust sirocco UDZO encoder - #71

Open
rmitz wants to merge 2 commits into
KarpelesLab:masterfrom
rmitz:sirocco-opt-in
Open

rmitz wants to merge 2 commits into
KarpelesLab:masterfrom
rmitz:sirocco-opt-in

Conversation

@rmitz

@rmitz rmitz commented Nov 11, 2026 •

Copy link
Copy Markdown

UDZO images are compressed as independent 1 MiB zlib chunks. Add the optional
dmg-write-zlib-sirocco feature to encode those chunks with the pure-Rust
sirocco crate instead of compcol.

The feature is opt-in. codecs and dmg-write-zlib keep compcol, the level
default is unchanged, and the read side still uses compcol; images written by
either build re-open with either build. CHANGELOG.md is left to the release
tooling.

Depends on #70. This branch currently includes 79ff9e7 so it compiles against
current libc; after #70 merges I will rebase it away, leaving only the encoder
commit.

Performance (integration-branch measurements)

Codec-only, independent 1 MiB chunks, single thread:

level compcol sirocco output
6 40.8 MiB/s 56.1 MiB/s ~same
4 54.3 MiB/s 138.8 MiB/s same to reported precision

At the preserved default level 6 the codec gain is about 1.38×; at level 4
it is 2.56×. The larger 3.4× figure compares level-4 sirocco against
level-6 compcol and is not the default-level gain.

Method: Synology DS1019+, Intel Celeron J3455 (4 cores, 1.5 GHz, no AVX2),
7.8 GB RAM, Linux 4.4; a zero-stripped slice of a real Time Machine image;
1 MiB UDIF chunks; fat LTO. The 3-thread/encrypted end-to-end numbers come from
the larger integration branch, which also contains the parallel and encryption
pipeline work absent from this PR; they are context, not evidence for this
branch. A CI-safe benchmark harness is not included yet.

Compatibility

  • Output is ordinary zlib in normal UDIF; plain images pass hdiutil verify
    and attach.
  • Pure Rust, no C toolchain; the no_std core is unaffected.
  • New dependencies: sirocco 0.3.1, adler32furious 0.1.1,
    crc32fast 1.5.5. All are MIT/Apache-2.0, MSRV ≤ 1.89, have no build
    script or C code. sirocco’s encoder denies unsafe; its inflate decoder
    contains unsafe code, and adler32furious uses runtime-dispatched SIMD
    intrinsics. This is source inspection, not a security audit; the full audit
    with checksums and inspection commands is available on request.

Tests

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --features dmg-write-zlib-sirocco -- -D warnings
cargo test --release --target x86_64-unknown-linux-musl --lib
cargo test --release --target x86_64-unknown-linux-musl \
  --features dmg-write-zlib-sirocco --lib

Full lib suite: 1736 passed, 2 ignored in both modes; 64/64 writer tests.

libc 0.2.173+ changed the ioctl request type; the untyped constant no longer matches on musl/host builds.
@rmitz

rmitz commented Nov 11, 2026

Copy link
Copy Markdown
Author

Dependency note: this branch currently includes #70 (79ff9e7) so it compiles against current libc. After #70 merges I will rebase it away, leaving only d076032.

UDZO is encoded as independent 1 MiB zlib chunks. Add dmg-write-zlib-sirocco to encode them with the pure-Rust sirocco crate instead of compcol. The feature is opt-in: codecs and dmg-write-zlib keep compcol, the level default is unchanged, and the read side still uses compcol. Images written by either build re-open with either build.
@rmitz

rmitz commented Nov 11, 2026

Copy link
Copy Markdown
Author

Rebased to 98a007d: removed the CHANGELOG.md hunk (release tooling owns it) and expanded the dependency/benchmark notes in the body. Still depends on #70; the branch includes 79ff9e7 until that merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant