Skip to content

Zstd announcement#76

Draft
erikjee wants to merge 7 commits into
mainfrom
zstd-announcement
Draft

Zstd announcement#76
erikjee wants to merge 7 commits into
mainfrom
zstd-announcement

Conversation

@erikjee
Copy link
Copy Markdown
Member

@erikjee erikjee commented May 27, 2026

No description provided.

@erikjee erikjee requested a review from LisetRoos May 27, 2026 10:01
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md

Using zstd in rust is already supported via the [zstd](https://crates.io/crates/zstd) crate, so why bother with a whole new implementation?

One practical advantage of rust is that it is straightforward to write portable software. Currently the `zstd` crate compiles the C code from source, which requires a C toolchain for the target and for the target to be supported at all. Setting up a C toolchain on windows or for webassembly can be a challenge, and isn't needed with a pure-rust implementation. For rust programmers, using dependencies written in rust is a superior experience.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
One practical advantage of rust is that it is straightforward to write portable software. Currently the `zstd` crate compiles the C code from source, which requires a C toolchain for the target and for the target to be supported at all. Setting up a C toolchain on windows or for webassembly can be a challenge, and isn't needed with a pure-rust implementation. For rust programmers, using dependencies written in rust is a superior experience.
### Portability
One practical advantage of rust is that it is straightforward to write portable software. Currently the `zstd` crate compiles the C code from source, which requires a C toolchain for the target and for the target to be supported at all. Setting up a C toolchain on windows or for webassembly can be a challenge, and isn't needed with a pure-rust implementation. For rust programmers, using dependencies written in rust is a superior experience.

Comment thread content/blog/Announcing Zstandard in Rust.md Outdated

By default decompression performance of our implementation is a couple percent slower than the C reference implementation. We believe we can justify this though, because with the `unsafe-performance-experimental` feature flag enabled we match C performance.

This feature flag disables 4 bounds checks where data from the input is used to index into a data structure. For most users a ~3% performance regression is likely an acceptable price to pay for increased memory safety. If you really need that last bit of performance, you can enable the flag at your own risk. Its behavior matches C which also does not check the bounds and appears to run just fine in many production systems.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe note how the number of unsafe operations relates to the unsafety of the C impl.
This can read as "you're back to the unsafety of the C impl"


### The cost of memory safety

By default decompression performance of our implementation is a couple percent slower than the C reference implementation. We believe we can justify this though, because with the `unsafe-performance-experimental` feature flag enabled we match C performance.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to benchmark suite?

Comment thread content/blog/Announcing Zstandard in Rust.md
@erikjee erikjee requested a review from folkertdev May 27, 2026 10:11
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated

The reference implementation was initially translated using [`c2rust`](https://c2rust.com/) , and we have since completed the cleanup work for decompression and the dictionary builder.

We test our rust code (compiled into a C static library) with the the reference implementation's test suite. We additionally use fuzz testing and Miri, so we're fairly confident in the correctness of our implementation.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We test our rust code (compiled into a C static library) with the the reference implementation's test suite. We additionally use fuzz testing and Miri, so we're fairly confident in the correctness of our implementation.
We test our Rust code (compiled into a C static library) with the the reference implementation's test suite. We additionally use fuzz testing and Miri, so we're fairly confident in the correctness of our implementation.

Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Co-authored-by: Erik Jonkers <erik@tweedegolf.com>
Co-authored-by: Liset <116883252+LisetRoos@users.noreply.github.com>
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
Comment thread content/blog/Announcing Zstandard in Rust.md

We test our rust code (compiled into a C static library) with the the reference implementation's test suite. We additionally use fuzz testing and Miri, so we're confident in the correctness of our implementation.

The release is available here: <TODO: link to release>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have https://crates.io/crates/libzstd-rs-sys/0.0.1-prerelease.1 which is what google uses. Do we want something more official? I'd still classify the current code as beta, there is still more unsafe in there than we'd like, and it's not yet seen serious third-party testing (google is working on it, from what I understand)

@folkertdev folkertdev force-pushed the zstd-announcement branch from 9f83091 to 50bd389 Compare May 28, 2026 09:22
Comment thread content/blog/Announcing Zstandard in Rust.md Outdated

We test our Rust code (compiled into a C static library) with the the reference implementation's test suite. We additionally use fuzz testing and Miri, so we're confident in the correctness of our implementation.

The pre-release is available here: <TODO: link to release>.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add link after release of ~ 0.0.1.prelease2

Comment thread content/blog/Announcing Zstandard in Rust.md Outdated
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.

3 participants