FsstSharp 1.0.0

This package has a SemVer 2.0.0 package version: 1.0.0+23ef13e.
dotnet add package FsstSharp --version 1.0.0
                    
NuGet\Install-Package FsstSharp -Version 1.0.0
                    
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="FsstSharp" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FsstSharp" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="FsstSharp" />
                    
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 FsstSharp --version 1.0.0
                    
#r "nuget: FsstSharp, 1.0.0"
                    
#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 FsstSharp@1.0.0
                    
#: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=FsstSharp&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=FsstSharp&version=1.0.0
                    
Install as a Cake Tool

FsstSharp

NuGet License: MIT

A high-performance C# implementation of the FSST (Fast Static Symbol Table) compression algorithm, optimized for .NET 10 with modern APIs and SIMD support.

What is FSST?

FSST is a compression algorithm specifically designed for string/text data that allows random access to compressed data. Unlike block-based algorithms like GZip or LZ4, FSST can decompress individual strings without touching surrounding data.

Key Features:

  • 🚀 Fast compression and decompression - Optimized for text, JSON, and structured data
  • 🎯 Random access - Decompress individual strings without full block decompression
  • 📦 Stream-based API - Compatible with standard .NET compression streams
  • Zero-allocation techniques - Uses Span<byte>, Memory<byte>, and unsafe code
  • 🔧 SIMD optimizations - Automatic CPU feature detection (AVX2, SSE2, ARM NEON)
  • 🎨 Modern C# APIs - Built for .NET 10 with latest language features

Installation

Install via NuGet:

dotnet add package FsstSharp

Or via Package Manager:

Install-Package FsstSharp

Quick Start

Basic Compression/Decompression

using FsstSharp;

// Sample data for training the encoder
var samples = new[]
{
    "user_id: 123, name: John"u8.ToArray(),
    "user_id: 456, name: Jane"u8.ToArray()
};

// Create encoder and decoder
var encoder = FsstEncoder.Create(samples);
var decoder = encoder.GetDecoder();

// Compress data
var input = "user_id: 789, name: Bob"u8.ToArray();
var compressed = new byte[input.Length * 2];
int compressedSize = encoder.Compress(input, compressed);

// Decompress data
var decompressed = new byte[input.Length * 2];
int decompressedSize = decoder.Decompress(
    compressed.AsSpan(0, compressedSize), 
    decompressed);

Stream-based Compression

using System.IO;
using System.IO.Compression;
using FsstSharp;

var originalData = "user_id: 789, name: Bob"u8.ToArray();

// Compress with on-the-fly learning
var compressedStream = new MemoryStream();
using (var fsstStream = new FsstStream(compressedStream, CompressionMode.Compress, leaveOpen: true))
{
    fsstStream.Write(originalData, 0, originalData.Length);
}

// Decompress
compressedStream.Position = 0;
var decompressedStream = new MemoryStream();
using (var fsstStream = new FsstStream(compressedStream, CompressionMode.Decompress))
{
    fsstStream.CopyTo(decompressedStream);
}

Use Cases

FSST is ideal for:

  • Database systems - Compress string columns with random access
  • Data file formats - Parquet, ORC, or custom formats
  • JSON/XML processing - Better compression than general-purpose algorithms
  • Log aggregation - Compress structured log data
  • Network protocols - Reduce bandwidth for text-heavy APIs

Performance

Benchmarks on realistic JSON data (~12KB):

Operation Mean Time Compression Ratio
FSST Compress 327 µs ~64% of original
FSST Decompress 52 µs -
GZip Decompress 16 µs Better (no random access)

Building from Source

Prerequisites

Build

git clone https://github.com/reedz/FsstSharp.git
cd FsstSharp/src
dotnet build -c Release

Run Tests

cd src
dotnet test -c Release

Run Benchmarks

cd src/FsstSharp.Benchmarks

# Standard compression benchmarks (FSST vs GZip vs LZ4)
dotnet run -c Release

# Sample data effect analysis
dotnet run -c Release -- sample-effect

# Sample count analysis (0, 1, 5, 10, 20, 50, 100, 500 samples)
dotnet run -c Release -- sample-count

See SAMPLE_DATA_ANALYSIS.md for detailed analysis of how training data affects compression.

Create NuGet Package

cd src/FsstSharp
dotnet pack -c Release

The package will be created in bin/Release/FsstSharp.{version}.nupkg

Projects

  • FsstSharp - Core compression library
  • FsstSharp.Cli - Command-line tool for file compression
  • FsstSharp.Tests - NUnit test suite
  • FsstSharp.Benchmarks - BenchmarkDotNet performance tests

Documentation

For detailed documentation, see:

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

This project maintains the MIT License from the original FSST implementation:

Copyright (c) 2018-2020, CWI, TU Munich, FSU Jena

See LICENSE for full details.

Original FSST

This is a C# port of the original FSST algorithm:

Acknowledgments

Special thanks to the original FSST authors for creating this innovative compression algorithm.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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 51 12/30/2025

Initial release of FsstSharp v1.0.0 - A high-performance C# port of the FSST compression algorithm for .NET 10. See CHANGELOG.md for details.