We currently have this comment and code in System.IO.Compression:
// Note that ZLib currently exactly correspond to the optimal values.
// However, we have determined the optimal values by intependent measurements across
// a range of all possible ZLib parameters and over a set of different data.
// We stress that by using explicitly the values obtained by the measurements rather than
// ZLib defaults even if they happened to be the same.
// For ZLib 1.2.3 we have (copied from ZLibNative.cs):
// ZLibNative.CompressionLevel.DefaultCompression = 6;
// ZLibNative.Deflate_DefaultWindowBits = -15;
// ZLibNative.Deflate_DefaultMemLevel = 8;
case CompressionLevel.Optimal:
zlibCompressionLevel = (ZLibNative.CompressionLevel)6;
windowBits = -15;
memLevel = 8;
strategy = ZLibNative.CompressionStrategy.DefaultStrategy;
break;
Since we are now using the “current” ZLib version on Unix, and because we are planning on changing which version we use on Windows, I don’t think this is the best approach anymore. It was probably correct when we were hard-coding a version, but since we don’t know which version will actually be used, I think we should be letting the zlib library figure out which is the best compression level to use.
I have 2 separate options on how to address this:
- On Unix, create a new shim method DeflateInit that only takes in the ZStream. The shim code will use the default values from the ZLib headers. Windows remains unchanged.
eerhardt/corefx@c1be54d
- Change both Windows and Unix code to always use the default compression level (-1) and let the zlib version pick.
eerhardt/corefx@38883e3
@ianhays @stephentoub - Do you guys agree this should be fixed? If so, do you have a preferred option - or an even better option than the 2 I've listed?
We currently have this comment and code in System.IO.Compression:
Since we are now using the “current” ZLib version on Unix, and because we are planning on changing which version we use on Windows, I don’t think this is the best approach anymore. It was probably correct when we were hard-coding a version, but since we don’t know which version will actually be used, I think we should be letting the zlib library figure out which is the best compression level to use.
I have 2 separate options on how to address this:
eerhardt/corefx@c1be54d
eerhardt/corefx@38883e3
@ianhays @stephentoub - Do you guys agree this should be fixed? If so, do you have a preferred option - or an even better option than the 2 I've listed?