Zstandard.Native.Runtimes 0.2.0-rc.2

This is a prerelease version of Zstandard.Native.Runtimes.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Zstandard.Native.Runtimes --version 0.2.0-rc.2
                    
NuGet\Install-Package Zstandard.Native.Runtimes -Version 0.2.0-rc.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zstandard.Native.Runtimes" Version="0.2.0-rc.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zstandard.Native.Runtimes" Version="0.2.0-rc.2" />
                    
Directory.Packages.props
<PackageReference Include="Zstandard.Native.Runtimes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zstandard.Native.Runtimes --version 0.2.0-rc.2
                    
#r "nuget: Zstandard.Native.Runtimes, 0.2.0-rc.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zstandard.Native.Runtimes@0.2.0-rc.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zstandard.Native.Runtimes&version=0.2.0-rc.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Zstandard.Native.Runtimes&version=0.2.0-rc.2&prerelease
                    
Install as a Cake Tool

Zstandard.Native

Ultra-fast Native AOT-safe Zstandard wrapper for .NET 8, .NET 9, and .NET 10 — zero-allocation Span<byte> APIs, source-generated [LibraryImport] P/Invoke, and hardware-accelerated buffer paths via AVX-512 / AVX10.2 and ARM64 SVE.

Install

dotnet add package Zstandard.Native

You also need a libzstd binary on the loader path. See Native runtime binaries for options (companion runtime package, bring-your-own, or system package manager).

Quick start

One-shot compress / decompress

using Zstandard.Native;

ReadOnlySpan<byte> src = File.ReadAllBytes("data.bin");

byte[] compressed = new byte[ZstdCompressor.GetCompressBound(src.Length)];
int n = ZstdCompressor.Compress(src, compressed, compressionLevel: 3);

byte[] back = new byte[src.Length];
ZstdCompressor.Decompress(compressed.AsSpan(0, n), back);

Streaming with context reuse

using var compressor = new ZstdStreamCompressor(compressionLevel: 3);
Span<byte> outBuf = stackalloc byte[ZstdStreamCompressor.RecommendedOutputSize];

foreach (var frame in frames)
{
    compressor.Reset(); // reuses ZSTD_CCtx — no allocation
    var r = compressor.Compress(frame.Span, outBuf, ZstdEndDirective.End);
    sink.Write(outBuf[..r.BytesWritten]);
}

Features

  • Zero allocations on the hot path — Span<byte>-only public API
  • Native AOT compatible — every IL2xxx/IL3xxx warning is an error in CI; no reflection, no marshalling shims
  • SafeHandle lifetime management for ZSTD_CCtx / ZSTD_DCtx — finalizer-safe even on process abort
  • Streaming with Reset() context reuse — skips ZSTD_createCCtx per frame
  • Hardware acceleration via Vector512 (AVX-512 / AVX10.2) and SVE (ARM64 variable-width) for buffer scrub operations
  • Targets libzstd ≥ 1.5.0 on win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64

Performance highlights

Scenario Runtime Throughput Allocated
Stream compress, context reuse, 1 MiB NativeAOT 10.0 12 510 MB/s 0 B
Stream compress, context reuse, 64 KB NativeAOT 10.0 12 015 MB/s 0 B
One-shot compress vs ZstdSharp, 64 KB level 3 AOT 10.0 +37% faster 0 B vs 64 B
One-shot compress vs ZstdSharp, 1 MiB level 1 AOT 10.0 +37% faster 0 B vs 65 B

Full benchmark tables →

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 43 5/30/2026
1.0.0-rc.1 45 5/26/2026
0.2.0-rc.2 32 5/26/2026
0.2.0-rc.1 41 5/26/2026