-
-
Notifications
You must be signed in to change notification settings - Fork 3
Zstd announcement #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
erikjee
wants to merge
7
commits into
main
Choose a base branch
from
zstd-announcement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d139bb
Initial version. Folkert's draft + sponsor section
erikjee d2261eb
Updates to data compression and libzstd pages
erikjee 037d136
Apply suggestions from code review
folkertdev 50bd389
tweaks
folkertdev de34149
Apply suggestion from @erikjee
erikjee e8d35e1
Apply suggestion from @erikjee
erikjee afa6d5b
Apply suggestion from @erikjee
erikjee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| +++ | ||
| title = "Announcing Zstandard in Rust" | ||
| slug = "announcing-zstandard-in-rust" | ||
| authors = ["Folkert de Vries"] | ||
| date = "2026-05-28" | ||
|
|
||
| [taxonomies] | ||
| tags = ["libzstd-rs", "announcement"] | ||
|
|
||
| +++ | ||
|
|
||
| Over the past year, we've been silently working on our third compression project. After [zlib](https://github.com/trifectatechfoundation/zlib-rs) and [bzip2](https://github.com/trifectatechfoundation/libbzip2-rs) we're now taking on zstd with [libzstd-rs-sys](https://github.com/trifectatechfoundation/libzstd-rs-sys), and are proud to announce its first release. | ||
|
|
||
| <!-- more --> | ||
|
|
||
| Zstd is a compression format that has been designed with modern CPUs in mind. It is both much faster and able to compress better than gzip. It is already widely used, and we expect that it will continue to gradually replace gzip for web traffic. | ||
|
|
||
| ## Why though? | ||
|
|
||
| Using zstd in Rust is already supported via the [zstd](https://crates.io/crates/zstd) crate, so why bother with a whole new implementation? | ||
|
|
||
| ### 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. | ||
|
|
||
| ### Drop-in replacement | ||
|
|
||
| Additionally, like with zlib and bzip2, we support compiling `libzstd-rs-sys` into a drop-in compatible C library. Hence we are, or aim to be, an alternative to the C reference implementation. | ||
|
folkertdev marked this conversation as resolved.
|
||
|
|
||
| ### Strengthening the ecosystem | ||
|
|
||
| The [C reference implementation](https://github.com/facebook/zstd) is maintained by Meta, and requires signing a contributor agreement with them in order to contribute. We believe that an independent, performant and compatible implementation strengthens the open source ecosystem. | ||
|
folkertdev marked this conversation as resolved.
|
||
|
|
||
| ## Current state | ||
|
|
||
| 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 confident in the correctness of our implementation. | ||
|
|
||
| The pre-release is available here: <TODO: link to release>. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add link after release of ~ 0.0.1.prelease2 |
||
|
|
||
| This work has also had ecosystem benefits: we've found several limitations of Miri (that are now resolved) and made contributions to Clippy. A more complete write-up of our recent contributions can be found [here](https://trifectatech.org/blog/fixing-our-own-problems-in-the-rust-compiler/). | ||
|
|
||
| ### The cost of memory safety | ||
|
|
||
| By default decompression performance of our implementation is a few percent slower than the C reference implementation. We benchmark each merge in to `main` in our [benchmark suite](https://trifectatechfoundation.github.io/libzstd-rs-sys-bench/). | ||
|
|
||
| We believe we can justify this regression 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 do need that last bit of performance, you can enable the flag at your own risk. Its behavior in these four locations matches C which also does not check the bounds and appears to run just fine in many production systems. | ||
|
|
||
| ## Future | ||
|
|
||
| We are looking for funding of the compression portion of this library. | ||
|
|
||
| Because of code sharing between compression and decompression, we have looked at the compression code a bit, but most of the cleanup work still needs to be done. We did set up benchmarks to ensure compression performance does not unexpectedly regress, and as mentioned we already use the reference implementation's test suite to check that we produce the correct result. | ||
|
|
||
| ### Ecosystem integration | ||
|
|
||
| We have our own fork of the `zstd` that uses `libzstd-rs-sys` instead of the C library. We'd like to upstream this at some point. | ||
|
|
||
| For the most commonly-used APIs this is straightforward. For the `experimental` features we run into some mismatches where `zstd-safe` uses an enum but we must use a `struct` for FFI safety. | ||
|
|
||
| ## Thanks to our sponsors | ||
|
|
||
| The work on the decompression side has been funded by [Chainguard](https://www.chainguard.dev/), [Astral](https://astral.sh/) and [NLnet Foundation](https://nlnet.nl/), and we're grateful for their support! [Sovereign Tech Agency](https://sovereign.tech) invested in the dictionary builder; thank you! | ||
|
|
||
| --- | ||
|
|
||
| ### About | ||
|
|
||
| [**Trifecta Tech Foundation**](https://trifectatech.org) is a non-profit and a Public Benefit Organisation (501(c)(3) equivalent) that creates open-source building blocks for critical infrastructure software. Our initiatives on data compression, time synchronization, and privilege boundary, impact the digital security of millions of people. If you’d like to support our work, please contact us; see [trifectatech.org/support](https://trifectatech.org/support/). | ||
|
|
||
| [**Astral**](https://astral.sh/) builds high-performance developer tools for the Python ecosystem: | ||
| - Ruff, an extremely fast Python linter, written in Rust. | ||
| - uv, an extremely fast Python package manager, written in Rust. | ||
|
|
||
| Astral's mission is to make the Python ecosystem more productive. Learn more at [astral.sh](https://astral.sh/). | ||
|
|
||
| [**NLnet Foundation**](https://nlnet.nl/) is a recognised philanthropic non-profit foundation. The foundation stimulates network research and development in the domain of Internet technology. The articles of association for the NLnet Foundation state: "to promote the exchange of electronic information and all that is related or beneficial to that purpose". The prefered instrument of NLnet is awarding microgrants to small, independent projects supporting independent researchers and developers. Read more on [nlnet.nl](https://nlnet.nl/). | ||
|
|
||
| [**Chainguard**](https://www.chainguard.dev/) builds trusted open source software for a secure-by-default stack. Read more on [chainguard.dev](https://www.chainguard.dev/) | ||
|
|
||
| ### Further Information | ||
|
|
||
| - [Data compression initiative on Trifecta Tech Foundation](https://trifectatech.org/initiatives/data-compression) | ||
| - [libzstd-rs GitHub Repository](https://github.com/trifectatechfoundation/libzstd-rs-sys) | ||
|
|
||
| *For inquiries, please contact Erik Jonkers, [contact@trifectatech.org](mailto:contact@trifectatech.org)* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.