This is an experimental managed version of ZLib which follows the same cross-platform vision as .NET while having more consistent performance and compression characteristics. The project includes Deflate algorithm's implementation for raw inflate, based on Deflate64, and raw deflate, based on Zlib, with a test harness for performance and functionality.
Consuming an external dependency like Zlib or Zlib-intel in .NET is a high maintenance task, since it involves shipping different versions for Windows and Unix systems, as well as having to either wait for vulnerabilities to get fixed upstream when they become public, or having to fix them ourselves, causing our code to potentially diverge from the original sources.
This library is being consumed by compression solutions like DeflateStream, GZipStream , ZLibStream and ZipArchive, among others.
The ManagedZLib project's structure goes as following:
- Source - Implementations of raw inflate and deflate following the (RFC151) standard and ZLib's manual.
- Tests - Unit tests for functionality coverage of DeflateStream's deflater and inflater on scenarios like: Text files, pdf (text heavy) and the binary files.
- Benchmarks - Uses BenchmarkDotNet for comparing the performance of this project, using Zlib or Zlib-intel as baseline.
- Profiling - Profiling console app for exploring areas of performance improvement, using VS Profiler.
Note:
- The optimizations done to this port of inflate were tested in a Windows11,x64 machine.
-
For improving performance, an optimization would be adding the same type of memoization during the construction of the lookup table, like done in Zlib's
inftrees.c. -
Since this port is based on the original ZLib, porting zlib-intel's optimizations into this new version should improve performance. This can extend to more 3rd parties' optimizations, like ZLib-NG for ARM64 processors.
.NET Runtime is a .NET Foundation project.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.
.NET (including the runtime repo) is licensed under the MIT license.