From eaafda06e223fa611b9799a4c148f478bde60c03 Mon Sep 17 00:00:00 2001 From: Ian Hays Date: Fri, 15 Jan 2016 11:34:30 -0800 Subject: [PATCH] System.IO.Compression: Make CompressionLevel.Optimal = -1 CompressionLevel 6 is what we used to use and we changed it in #4589 because we didn't see any perf regressions in doing so. With more testing, it has become clear that moving from 6 to 9 severely hurt perf in some scenarios so it's being reverted to -1 which maps to 6. --- src/Native/System.IO.Compression.Native/pal_zlib.cpp | 2 +- src/Native/System.IO.Compression.Native/pal_zlib.h | 2 +- .../src/System/IO/Compression/Deflater.cs | 2 +- .../src/System/IO/Compression/ZLibNative.cs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Native/System.IO.Compression.Native/pal_zlib.cpp b/src/Native/System.IO.Compression.Native/pal_zlib.cpp index 999b38c2e0dd..d049903311a5 100644 --- a/src/Native/System.IO.Compression.Native/pal_zlib.cpp +++ b/src/Native/System.IO.Compression.Native/pal_zlib.cpp @@ -20,7 +20,7 @@ static_assert(PAL_Z_VERSIONERROR == Z_VERSION_ERROR, ""); static_assert(PAL_Z_NOCOMPRESSION == Z_NO_COMPRESSION, ""); static_assert(PAL_Z_BESTSPEED == Z_BEST_SPEED, ""); -static_assert(PAL_Z_BESTCOMPRESSION == Z_BEST_COMPRESSION, ""); +static_assert(PAL_Z_DEFAULTCOMPRESSION == Z_DEFAULT_COMPRESSION, ""); static_assert(PAL_Z_DEFAULTSTRATEGY == Z_DEFAULT_STRATEGY, ""); diff --git a/src/Native/System.IO.Compression.Native/pal_zlib.h b/src/Native/System.IO.Compression.Native/pal_zlib.h index 9b61824abb8a..3fd48d29c371 100644 --- a/src/Native/System.IO.Compression.Native/pal_zlib.h +++ b/src/Native/System.IO.Compression.Native/pal_zlib.h @@ -50,7 +50,7 @@ enum PAL_CompressionLevel : int32_t { PAL_Z_NOCOMPRESSION = 0, PAL_Z_BESTSPEED = 1, - PAL_Z_BESTCOMPRESSION = 9, + PAL_Z_DEFAULTCOMPRESSION = -1, }; /* diff --git a/src/System.IO.Compression/src/System/IO/Compression/Deflater.cs b/src/System.IO.Compression/src/System/IO/Compression/Deflater.cs index 109965e7bd44..49dee00bd024 100644 --- a/src/System.IO.Compression/src/System/IO/Compression/Deflater.cs +++ b/src/System.IO.Compression/src/System/IO/Compression/Deflater.cs @@ -42,7 +42,7 @@ internal Deflater(CompressionLevel compressionLevel, int windowBits) // See the note in ZLibNative.CompressionLevel for the recommended combinations. case CompressionLevel.Optimal: - zlibCompressionLevel = ZLibNative.CompressionLevel.BestCompression; + zlibCompressionLevel = ZLibNative.CompressionLevel.DefaultCompression; memLevel = ZLibNative.Deflate_DefaultMemLevel; break; diff --git a/src/System.IO.Compression/src/System/IO/Compression/ZLibNative.cs b/src/System.IO.Compression/src/System/IO/Compression/ZLibNative.cs index 125bf4b83a60..6982a014a150 100644 --- a/src/System.IO.Compression/src/System/IO/Compression/ZLibNative.cs +++ b/src/System.IO.Compression/src/System/IO/Compression/ZLibNative.cs @@ -48,10 +48,10 @@ public enum ErrorCode : int /// ///

How to choose a compression level:

/// - ///

The names NoCompression, BestSpeed, BestCompression are taken over from the corresponding + ///

The names NoCompression, BestSpeed, DefaultCompression are taken over from the corresponding /// ZLib definitions, which map to our public NoCompression, Fastest, and Optimal respectively. ///

Optimal Compression:

- ///

ZLibNative.CompressionLevel compressionLevel = ZLibNative.CompressionLevel.BestCompression;
+ ///

ZLibNative.CompressionLevel compressionLevel = ZLibNative.CompressionLevel.DefaultCompression;
/// Int32 windowBits = 15; // or -15 if no headers required
/// Int32 memLevel = 8;
/// ZLibNative.CompressionStrategy strategy = ZLibNative.CompressionStrategy.DefaultStrategy;

@@ -72,7 +72,7 @@ public enum CompressionLevel : int { NoCompression = 0, BestSpeed = 1, - BestCompression = 9, // Refer to "How to choose a compression level" above. + DefaultCompression = -1 } ///