A high-performance LZ4 and LZ4HC compression library for .NET, offering fast block and stream compression.
K4os.Compression.LZ4 is a .NET library that implements the LZ4 and LZ4HC compression algorithms, designed for extremely fast compression and decompression speeds. It solves the problem of reducing data size with minimal latency, making it suitable for real-time applications where traditional compression algorithms are too slow. The library provides both block-level and stream-level compression APIs, supporting a wide range of .NET platforms.
.NET developers working on performance-sensitive applications, such as real-time data processing, network communication, game development, or any scenario where fast compression and decompression are required.
Developers choose K4os.Compression.LZ4 for its exceptional speed, comprehensive API covering both blocks and streams, and its compatibility with the standard LZ4 frame format. It offers a balance of performance and flexibility, with optimizations like memory pooling and support for various compression levels.
LZ4/LH4HC compression for .NET Standard 1.6/2.0 (formerly known as lz4net)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show compression up to ~400 MB/s and decompression up to ~2 GB/s per core, approaching RAM speed limits, making it ideal for real-time data processing.
Offers both low-level block compression with LZ4Codec for fine control and high-level stream compression with LZ4Stream, plus newer LZ4Frame abstractions for various data structures.
Targets .NET Standard 2.0+, .NET Framework 4.6.2+, and .NET 5.0+, supporting .NET Core, Mono, Xamarin, and UWP, though not all platforms are tested.
Includes built-in memory pooling to reduce allocations and garbage collection overhead, especially beneficial for small, frequent compression operations.
The README admits that stream compression lacks support for ContentLength and Dictionary in the LZ4 frame format, limiting full compatibility with some LZ4 tools.
The build process relies on Windows tools like 7z.exe and lz4.exe and isn't adapted for Linux, requiring manual changes or PRs for cross-platform development.
Despite targeting multiple .NET platforms, the author notes it's not tested on all, potentially leading to untested edge cases and reliance on community feedback.
Block compression APIs require manual buffer allocation and knowledge of maximum output sizes, which can be error-prone and less intuitive for beginners.