Incorporate fast-zlib changes.

This is a PR that seeks to incorporate the fast zlib changes mentioned in #97. Fast-zlib changes require rolling hash to be used. It also performs best when hash mask is 32k-1 instead of 64k-1 which is used for integer hashing method we currently use.
I don't expect these changes to be incorporated into the first release. We might also decide to not incorporate them at all due to the added complexity. But this is the first step toward determining that. And in the future should anybody want to investigate this again they can use this PR as a starting base.
Benchmarks
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.421/2.433/2.442/0.006        0.907/0.919/0.925/0.004       77,255,275
 2     35.381%      2.675/2.689/2.696/0.006        0.897/0.907/0.916/0.006       74,991,864
 3     34.426%      3.306/3.321/3.332/0.007        0.880/0.900/0.908/0.008       72,967,657
 4     33.498%      3.540/3.556/3.566/0.008        0.876/0.891/0.896/0.006       71,002,237
 5     32.627%      4.840/4.858/4.872/0.007        0.876/0.888/0.892/0.004       69,156,120
 6     32.188%      6.789/6.822/6.842/0.015        0.870/0.880/0.886/0.004       68,224,174
 7     32.051%      8.181/8.214/8.234/0.013        0.865/0.877/0.882/0.005       67,934,314
 8     31.935%   12.677/12.719/12.745/0.019        0.863/0.872/0.877/0.003       67,688,380
 9     31.916%   16.200/16.248/16.282/0.022        0.861/0.872/0.877/0.004       67,647,801

 avg1  33.385%                        6.762                          0.889
 tot                               1825.836                        240.135      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.840/1.859/1.865/0.006        0.681/0.688/0.693/0.003      100,930,315
2     35.519%      2.050/2.065/2.074/0.007        0.703/0.715/0.719/0.005       75,286,316
3     34.198%      2.424/2.435/2.442/0.005        0.686/0.699/0.704/0.004       72,485,932
4     32.928%      2.849/2.866/2.874/0.006        0.674/0.681/0.687/0.004       69,794,199
5     32.661%      3.049/3.059/3.064/0.004        0.667/0.678/0.683/0.004       69,226,720
6     32.507%      3.475/3.493/3.502/0.007        0.670/0.678/0.682/0.003       68,902,076
7     32.255%      4.448/4.468/4.480/0.008        0.666/0.676/0.681/0.004       68,366,763
8     32.167%      6.652/6.671/6.683/0.009        0.666/0.675/0.679/0.003       68,180,782
9     32.156%      9.090/9.109/9.124/0.010        0.667/0.674/0.678/0.003       68,156,152

avg1  34.668%                        4.003                          0.685
tot                               1080.764                        184.972      661,329,255

FAST-ZLIB
 Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.325/2.350/2.359/0.008        0.908/0.918/0.926/0.005       77,255,275
2     35.381%      2.517/2.535/2.543/0.006        0.889/0.909/0.917/0.008       74,991,864
3     34.426%      3.072/3.087/3.097/0.008        0.893/0.901/0.908/0.005       72,967,657
4     33.481%      3.359/3.377/3.386/0.007        0.874/0.891/0.896/0.005       70,966,161
5     32.489%      4.366/4.377/4.387/0.006        0.870/0.882/0.887/0.005       68,863,411
6     32.061%      5.148/5.173/5.188/0.011        0.865/0.878/0.882/0.004       67,955,060
7     31.979%      5.433/5.459/5.474/0.011        0.868/0.875/0.879/0.003       67,782,174
8     31.913%      5.889/5.909/5.921/0.010        0.863/0.872/0.878/0.004       67,641,467
9     31.909%      6.116/6.155/6.174/0.014        0.865/0.872/0.876/0.003       67,634,262

avg1  33.343%                        4.269                          0.889
tot                               1152.638                        239.939      636,057,331

ZLIB-NG-FAST
 Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.853/1.864/1.870/0.005        0.681/0.690/0.694/0.004      100,930,315
2     35.519%      2.062/2.078/2.086/0.008        0.705/0.715/0.721/0.004       75,286,316
3     34.198%      2.435/2.451/2.462/0.008        0.693/0.700/0.705/0.003       72,485,932
4     32.928%      2.870/2.889/2.899/0.007        0.675/0.682/0.688/0.004       69,794,199
5     32.661%      3.062/3.075/3.086/0.007        0.673/0.680/0.685/0.003       69,226,720
6     32.507%      3.490/3.513/3.522/0.008        0.668/0.678/0.683/0.004       68,902,076
7     32.255%      4.488/4.516/4.525/0.008        0.669/0.677/0.682/0.003       68,366,763
8     32.167%      6.708/6.723/6.735/0.008        0.661/0.676/0.680/0.005       68,180,782
9     32.003%      8.272/8.302/8.321/0.015        0.677/0.686/0.689/0.003       67,831,961

avg1  34.651%                        3.935                          0.687
tot                               1062.329                        185.535      661,005,064

Highly interesting.
Not sure why the change of update_hash/insert_string cannot happen in a functable.c function, and the function pointers could then still live in functable instead of inflating deflate internal_state.

Highly interesting.
Not sure why the change of update_hash/insert_string cannot happen in a functable.c function, and the function pointers could then still live in functable instead of inflating deflate internal_state.

I initially thought about putting it in functable too. But then I realized that the rolling hashing method can only be utilized for when we want to use the fast-zlib method. This means on level 9 (at least for now) where we see the most improvement. If we put it in functable then when the user uses our library and switched between using different deflate levels they will not see the change in performance because the hash methods will still be configured one way or another. In other words, there is no functable_reset in deflateInit when the level is set, so we need to have pointers to the correct hash functions else where.

I initially thought about putting it in functable too. But then I realized that the rolling hashing method can only be utilized for when we want to use the fast-zlib method. This means on level 9 (at least for now) where we see the most improvement. If we put it in functable then when the user uses our library and switched between using different deflate levels they will not see the change in performance because the hash methods will still be configured one way or another. In other words, there is no functable_reset in deflateInit when the level is set, so we need to have pointers to the correct hash functions else where.

More benchmarks after recent commits, level 9 (only place this is being used) is more inline with what we are seeing with fast-zlib.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.398/2.415/2.427/0.008        0.894/0.910/0.920/0.006       77,255,275
 2     35.381%      2.648/2.673/2.684/0.009        0.891/0.907/0.916/0.007       74,991,864
 3     34.426%      3.296/3.306/3.313/0.005        0.872/0.894/0.902/0.009       72,967,657
 4     33.498%      3.514/3.535/3.546/0.009        0.864/0.883/0.893/0.008       71,002,237
 5     32.627%      4.803/4.828/4.840/0.010        0.878/0.888/0.893/0.004       69,156,120
 6     32.188%      6.764/6.789/6.804/0.013        0.870/0.881/0.886/0.004       68,224,174
 7     32.051%      8.125/8.172/8.188/0.017        0.870/0.876/0.880/0.004       67,934,314
 8     31.935%   12.562/12.646/12.673/0.024        0.861/0.874/0.879/0.005       67,688,380
 9     31.916%   16.100/16.157/16.191/0.025        0.865/0.873/0.877/0.003       67,647,801

 avg1  33.385%                        6.725                          0.887
 tot                               1815.640                        239.555      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.820/1.834/1.842/0.006        0.671/0.685/0.690/0.005      100,930,315
2     35.519%      2.029/2.039/2.047/0.005        0.702/0.709/0.714/0.003       75,286,316
3     34.198%      2.392/2.414/2.424/0.009        0.687/0.697/0.701/0.003       72,485,932
4     32.928%      2.820/2.837/2.844/0.006        0.669/0.676/0.681/0.003       69,794,199
5     32.661%      3.013/3.030/3.037/0.007        0.667/0.677/0.681/0.003       69,226,720
6     32.507%      3.440/3.458/3.466/0.006        0.669/0.675/0.680/0.003       68,902,076
7     32.255%      4.409/4.430/4.440/0.008        0.668/0.675/0.678/0.003       68,366,763
8     32.167%      6.609/6.626/6.637/0.009        0.663/0.671/0.676/0.004       68,180,782
9     32.156%      9.020/9.056/9.069/0.011        0.659/0.670/0.675/0.005       68,156,152

avg1  34.668%                        3.969                          0.682
tot                               1071.678                        184.055      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.318/2.333/2.342/0.006        0.900/0.913/0.920/0.006       77,255,275
2     35.381%      2.497/2.511/2.518/0.005        0.880/0.903/0.912/0.007       74,991,864
3     34.426%      3.043/3.066/3.075/0.008        0.874/0.886/0.896/0.006       72,967,657
4     33.481%      3.338/3.356/3.365/0.007        0.866/0.881/0.887/0.006       70,966,161
5     32.489%      4.327/4.348/4.359/0.008        0.867/0.879/0.882/0.004       68,863,411
6     32.061%      5.115/5.142/5.154/0.010        0.859/0.869/0.873/0.003       67,955,060
7     31.979%      5.384/5.421/5.441/0.016        0.855/0.868/0.873/0.005       67,782,174
8     31.913%      5.848/5.874/5.887/0.011        0.853/0.866/0.872/0.005       67,641,467
9     31.909%      6.086/6.117/6.131/0.012        0.857/0.867/0.870/0.003       67,634,262

avg1  33.343%                        4.241                          0.881
tot                               1145.032                        237.917      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.813/1.829/1.837/0.007        0.677/0.688/0.693/0.004      100,930,315
2     35.519%      2.024/2.050/2.062/0.008        0.704/0.711/0.716/0.004       75,286,316
3     34.198%      2.413/2.427/2.437/0.007        0.689/0.698/0.703/0.004       72,485,932
4     32.928%      2.835/2.852/2.863/0.007        0.678/0.683/0.688/0.003       69,794,199
5     32.661%      3.023/3.046/3.056/0.010        0.668/0.678/0.682/0.004       69,226,720
6     32.507%      3.468/3.478/3.486/0.006        0.669/0.676/0.682/0.004       68,902,076
7     32.255%      4.443/4.464/4.476/0.008        0.668/0.676/0.679/0.003       68,366,763
8     32.167%      6.625/6.656/6.671/0.011        0.666/0.675/0.679/0.003       68,180,782
9     31.887%      6.795/6.822/6.832/0.009        0.671/0.679/0.684/0.004       67,586,412

avg1  34.638%                        3.736                          0.685
tot                               1008.679                        184.924      660,759,515

More benchmarks after recent commits, level 9 (only place this is being used) is more inline with what we are seeing with fast-zlib.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.398/2.415/2.427/0.008        0.894/0.910/0.920/0.006       77,255,275
 2     35.381%      2.648/2.673/2.684/0.009        0.891/0.907/0.916/0.007       74,991,864
 3     34.426%      3.296/3.306/3.313/0.005        0.872/0.894/0.902/0.009       72,967,657
 4     33.498%      3.514/3.535/3.546/0.009        0.864/0.883/0.893/0.008       71,002,237
 5     32.627%      4.803/4.828/4.840/0.010        0.878/0.888/0.893/0.004       69,156,120
 6     32.188%      6.764/6.789/6.804/0.013        0.870/0.881/0.886/0.004       68,224,174
 7     32.051%      8.125/8.172/8.188/0.017        0.870/0.876/0.880/0.004       67,934,314
 8     31.935%   12.562/12.646/12.673/0.024        0.861/0.874/0.879/0.005       67,688,380
 9     31.916%   16.100/16.157/16.191/0.025        0.865/0.873/0.877/0.003       67,647,801

 avg1  33.385%                        6.725                          0.887
 tot                               1815.640                        239.555      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.820/1.834/1.842/0.006        0.671/0.685/0.690/0.005      100,930,315
2     35.519%      2.029/2.039/2.047/0.005        0.702/0.709/0.714/0.003       75,286,316
3     34.198%      2.392/2.414/2.424/0.009        0.687/0.697/0.701/0.003       72,485,932
4     32.928%      2.820/2.837/2.844/0.006        0.669/0.676/0.681/0.003       69,794,199
5     32.661%      3.013/3.030/3.037/0.007        0.667/0.677/0.681/0.003       69,226,720
6     32.507%      3.440/3.458/3.466/0.006        0.669/0.675/0.680/0.003       68,902,076
7     32.255%      4.409/4.430/4.440/0.008        0.668/0.675/0.678/0.003       68,366,763
8     32.167%      6.609/6.626/6.637/0.009        0.663/0.671/0.676/0.004       68,180,782
9     32.156%      9.020/9.056/9.069/0.011        0.659/0.670/0.675/0.005       68,156,152

avg1  34.668%                        3.969                          0.682
tot                               1071.678                        184.055      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.318/2.333/2.342/0.006        0.900/0.913/0.920/0.006       77,255,275
2     35.381%      2.497/2.511/2.518/0.005        0.880/0.903/0.912/0.007       74,991,864
3     34.426%      3.043/3.066/3.075/0.008        0.874/0.886/0.896/0.006       72,967,657
4     33.481%      3.338/3.356/3.365/0.007        0.866/0.881/0.887/0.006       70,966,161
5     32.489%      4.327/4.348/4.359/0.008        0.867/0.879/0.882/0.004       68,863,411
6     32.061%      5.115/5.142/5.154/0.010        0.859/0.869/0.873/0.003       67,955,060
7     31.979%      5.384/5.421/5.441/0.016        0.855/0.868/0.873/0.005       67,782,174
8     31.913%      5.848/5.874/5.887/0.011        0.853/0.866/0.872/0.005       67,641,467
9     31.909%      6.086/6.117/6.131/0.012        0.857/0.867/0.870/0.003       67,634,262

avg1  33.343%                        4.241                          0.881
tot                               1145.032                        237.917      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.813/1.829/1.837/0.007        0.677/0.688/0.693/0.004      100,930,315
2     35.519%      2.024/2.050/2.062/0.008        0.704/0.711/0.716/0.004       75,286,316
3     34.198%      2.413/2.427/2.437/0.007        0.689/0.698/0.703/0.004       72,485,932
4     32.928%      2.835/2.852/2.863/0.007        0.678/0.683/0.688/0.003       69,794,199
5     32.661%      3.023/3.046/3.056/0.010        0.668/0.678/0.682/0.004       69,226,720
6     32.507%      3.468/3.478/3.486/0.006        0.669/0.676/0.682/0.004       68,902,076
7     32.255%      4.443/4.464/4.476/0.008        0.668/0.676/0.679/0.003       68,366,763
8     32.167%      6.625/6.656/6.671/0.011        0.666/0.675/0.679/0.003       68,180,782
9     31.887%      6.795/6.822/6.832/0.009        0.671/0.679/0.684/0.004       67,586,412

avg1  34.638%                        3.736                          0.685
tot                               1008.679                        184.924      660,759,515

Next I will extend fast-lib method to level 8 and produce benchmarks. I also want to try using fast-zlib method for all hashing/matching and produce benchmarks for that to compare.

Next I will extend fast-lib method to level 8 and produce benchmarks. I also want to try using fast-zlib method for all hashing/matching and produce benchmarks for that to compare.

Here are the results of level 8 and level 9 using fast-zlib hashing & longest match algorithm. It appears to show an increase in speed and decrease compression size for level 8.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.394/2.412/2.419/0.006        0.875/0.890/0.898/0.006       77,255,275
 2     35.381%      2.633/2.646/2.656/0.006        0.859/0.890/0.901/0.010       74,991,864
 3     34.426%      3.264/3.282/3.293/0.008        0.857/0.875/0.886/0.008       72,967,657
 4     33.498%      3.484/3.506/3.519/0.009        0.848/0.870/0.880/0.007       71,002,237
 5     32.627%      4.764/4.786/4.799/0.009        0.854/0.868/0.874/0.006       69,156,120
 6     32.188%      6.677/6.718/6.734/0.012        0.848/0.858/0.865/0.005       68,224,174
 7     32.051%      8.057/8.086/8.106/0.015        0.846/0.857/0.862/0.004       67,934,314
 8     31.935%   12.456/12.499/12.525/0.018        0.841/0.856/0.863/0.005       67,688,380
 9     31.916%   15.937/15.980/16.001/0.018        0.840/0.855/0.862/0.006       67,647,801

 avg1  33.385%                        6.657                          0.869
 tot                               1797.465                        234.571      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.828/1.837/1.844/0.005        0.663/0.672/0.678/0.005      100,930,315
2     35.519%      2.018/2.030/2.038/0.006        0.688/0.698/0.707/0.005       75,286,316
3     34.198%      2.385/2.401/2.410/0.007        0.673/0.682/0.686/0.004       72,485,932
4     32.928%      2.799/2.814/2.824/0.007        0.653/0.667/0.674/0.005       69,794,199
5     32.661%      2.985/3.006/3.014/0.006        0.648/0.661/0.668/0.005       69,226,720
6     32.507%      3.396/3.431/3.440/0.010        0.646/0.661/0.667/0.005       68,902,076
7     32.255%      4.381/4.397/4.408/0.007        0.649/0.659/0.665/0.005       68,366,763
8     32.167%      6.529/6.565/6.582/0.016        0.652/0.658/0.663/0.003       68,180,782
9     32.156%      8.916/8.965/8.983/0.018        0.645/0.659/0.664/0.005       68,156,152

avg1  34.668%                        3.938                          0.669
tot                               1063.333                        180.535      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.299/2.318/2.328/0.007        0.879/0.900/0.914/0.011       77,255,275
2     35.381%      2.486/2.497/2.504/0.005        0.870/0.887/0.899/0.008       74,991,864
3     34.426%      3.022/3.042/3.052/0.008        0.857/0.877/0.886/0.008       72,967,657
4     33.481%      3.307/3.324/3.334/0.007        0.860/0.871/0.879/0.006       70,966,161
5     32.489%      4.278/4.304/4.316/0.010        0.856/0.868/0.874/0.005       68,863,411
6     32.061%      5.071/5.096/5.107/0.009        0.849/0.860/0.866/0.004       67,955,060
7     31.979%      5.346/5.368/5.378/0.008        0.840/0.856/0.863/0.005       67,782,174
8     31.913%      5.778/5.811/5.825/0.012        0.846/0.854/0.859/0.004       67,641,467
9     31.909%      6.041/6.061/6.072/0.009        0.840/0.856/0.862/0.005       67,634,262

avg1  33.343%                        4.202                          0.870
tot                               1134.618                        234.802      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.821/1.831/1.840/0.005        0.662/0.673/0.677/0.004      100,930,315
2     35.519%      2.038/2.049/2.055/0.005        0.686/0.698/0.705/0.005       75,286,316
3     34.198%      2.399/2.421/2.428/0.007        0.669/0.683/0.688/0.005       72,485,932
4     32.928%      2.817/2.842/2.849/0.007        0.651/0.665/0.671/0.005       69,794,199
5     32.661%      3.015/3.028/3.035/0.006        0.654/0.664/0.669/0.004       69,226,720
6     32.507%      3.443/3.455/3.460/0.004        0.651/0.662/0.667/0.004       68,902,076
7     32.255%      4.410/4.431/4.442/0.008        0.655/0.663/0.667/0.003       68,366,763
8     31.888%      6.283/6.301/6.311/0.007        0.656/0.665/0.672/0.004       67,588,330
9     31.887%      6.739/6.758/6.769/0.009        0.654/0.665/0.670/0.004       67,586,412

avg1  34.607%                        3.680                          0.671
tot                                993.475                        181.146      660,167,063

Here are the results of level 8 and level 9 using fast-zlib hashing & longest match algorithm. It appears to show an increase in speed and decrease compression size for level 8.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.394/2.412/2.419/0.006        0.875/0.890/0.898/0.006       77,255,275
 2     35.381%      2.633/2.646/2.656/0.006        0.859/0.890/0.901/0.010       74,991,864
 3     34.426%      3.264/3.282/3.293/0.008        0.857/0.875/0.886/0.008       72,967,657
 4     33.498%      3.484/3.506/3.519/0.009        0.848/0.870/0.880/0.007       71,002,237
 5     32.627%      4.764/4.786/4.799/0.009        0.854/0.868/0.874/0.006       69,156,120
 6     32.188%      6.677/6.718/6.734/0.012        0.848/0.858/0.865/0.005       68,224,174
 7     32.051%      8.057/8.086/8.106/0.015        0.846/0.857/0.862/0.004       67,934,314
 8     31.935%   12.456/12.499/12.525/0.018        0.841/0.856/0.863/0.005       67,688,380
 9     31.916%   15.937/15.980/16.001/0.018        0.840/0.855/0.862/0.006       67,647,801

 avg1  33.385%                        6.657                          0.869
 tot                               1797.465                        234.571      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.828/1.837/1.844/0.005        0.663/0.672/0.678/0.005      100,930,315
2     35.519%      2.018/2.030/2.038/0.006        0.688/0.698/0.707/0.005       75,286,316
3     34.198%      2.385/2.401/2.410/0.007        0.673/0.682/0.686/0.004       72,485,932
4     32.928%      2.799/2.814/2.824/0.007        0.653/0.667/0.674/0.005       69,794,199
5     32.661%      2.985/3.006/3.014/0.006        0.648/0.661/0.668/0.005       69,226,720
6     32.507%      3.396/3.431/3.440/0.010        0.646/0.661/0.667/0.005       68,902,076
7     32.255%      4.381/4.397/4.408/0.007        0.649/0.659/0.665/0.005       68,366,763
8     32.167%      6.529/6.565/6.582/0.016        0.652/0.658/0.663/0.003       68,180,782
9     32.156%      8.916/8.965/8.983/0.018        0.645/0.659/0.664/0.005       68,156,152

avg1  34.668%                        3.938                          0.669
tot                               1063.333                        180.535      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.299/2.318/2.328/0.007        0.879/0.900/0.914/0.011       77,255,275
2     35.381%      2.486/2.497/2.504/0.005        0.870/0.887/0.899/0.008       74,991,864
3     34.426%      3.022/3.042/3.052/0.008        0.857/0.877/0.886/0.008       72,967,657
4     33.481%      3.307/3.324/3.334/0.007        0.860/0.871/0.879/0.006       70,966,161
5     32.489%      4.278/4.304/4.316/0.010        0.856/0.868/0.874/0.005       68,863,411
6     32.061%      5.071/5.096/5.107/0.009        0.849/0.860/0.866/0.004       67,955,060
7     31.979%      5.346/5.368/5.378/0.008        0.840/0.856/0.863/0.005       67,782,174
8     31.913%      5.778/5.811/5.825/0.012        0.846/0.854/0.859/0.004       67,641,467
9     31.909%      6.041/6.061/6.072/0.009        0.840/0.856/0.862/0.005       67,634,262

avg1  33.343%                        4.202                          0.870
tot                               1134.618                        234.802      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.821/1.831/1.840/0.005        0.662/0.673/0.677/0.004      100,930,315
2     35.519%      2.038/2.049/2.055/0.005        0.686/0.698/0.705/0.005       75,286,316
3     34.198%      2.399/2.421/2.428/0.007        0.669/0.683/0.688/0.005       72,485,932
4     32.928%      2.817/2.842/2.849/0.007        0.651/0.665/0.671/0.005       69,794,199
5     32.661%      3.015/3.028/3.035/0.006        0.654/0.664/0.669/0.004       69,226,720
6     32.507%      3.443/3.455/3.460/0.004        0.651/0.662/0.667/0.004       68,902,076
7     32.255%      4.410/4.431/4.442/0.008        0.655/0.663/0.667/0.003       68,366,763
8     31.888%      6.283/6.301/6.311/0.007        0.656/0.665/0.672/0.004       67,588,330
9     31.887%      6.739/6.758/6.769/0.009        0.654/0.665/0.670/0.004       67,586,412

avg1  34.607%                        3.680                          0.671
tot                                993.475                        181.146      660,167,063

FYI my zlib-ng and zlib-ng-fast benchmarks use -DWITH_OPTIM=OFF, which for levels not using fast-zlib (1-7), still use integer hashing but non-intrinsic version.

FYI my zlib-ng and zlib-ng-fast benchmarks use -DWITH_OPTIM=OFF, which for levels not using fast-zlib (1-7), still use integer hashing but non-intrinsic version.

Another set of tests from last night using rolling hash for all algorithms and another using high max chain length.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.335/2.361/2.369/0.007        0.862/0.873/0.881/0.005       77,255,275
 2     35.381%      2.589/2.611/2.618/0.007        0.847/0.864/0.871/0.006       74,991,864
 3     34.426%      3.206/3.232/3.243/0.009        0.832/0.852/0.860/0.007       72,967,657
 4     33.498%      3.430/3.453/3.467/0.009        0.819/0.843/0.849/0.007       71,002,237
 5     32.627%      4.703/4.730/4.740/0.008        0.821/0.835/0.842/0.006       69,156,120
 6     32.188%      6.649/6.670/6.686/0.012        0.819/0.830/0.836/0.005       68,224,174
 7     32.051%      8.008/8.044/8.062/0.014        0.813/0.831/0.837/0.006       67,934,314
 8     31.935%   12.400/12.465/12.483/0.019        0.821/0.829/0.834/0.004       67,688,380
 9     31.916%   15.860/15.926/15.949/0.024        0.817/0.826/0.832/0.004       67,647,801

 avg1  33.385%                        6.610                          0.843
 tot                               1784.743                        227.495      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.762/1.783/1.789/0.006        0.662/0.672/0.678/0.005      100,930,315
2     35.519%      1.971/1.987/1.995/0.007        0.681/0.694/0.700/0.005       75,286,316
3     34.198%      2.334/2.356/2.367/0.007        0.675/0.682/0.688/0.004       72,485,932
4     32.928%      2.758/2.772/2.785/0.009        0.647/0.659/0.667/0.006       69,794,199
5     32.661%      2.949/2.962/2.974/0.007        0.648/0.662/0.668/0.005       69,226,720
6     32.507%      3.374/3.392/3.401/0.007        0.646/0.662/0.668/0.005       68,902,076
7     32.255%      4.321/4.354/4.369/0.013        0.653/0.663/0.668/0.004       68,366,763
8     32.167%      6.506/6.527/6.542/0.009        0.652/0.664/0.668/0.003       68,180,782
9     32.156%      8.891/8.933/8.947/0.012        0.648/0.661/0.666/0.004       68,156,152

avg1  34.668%                        3.896                          0.669
tot                               1051.940                        180.557      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.265/2.278/2.286/0.006        0.861/0.877/0.889/0.007       77,255,275
2     35.381%      2.440/2.465/2.475/0.009        0.847/0.867/0.879/0.008       74,991,864
3     34.426%      2.981/2.999/3.010/0.008        0.840/0.864/0.871/0.008       72,967,657
4     33.481%      3.248/3.276/3.288/0.010        0.838/0.855/0.864/0.007       70,966,161
5     32.489%      4.249/4.268/4.281/0.009        0.833/0.849/0.855/0.005       68,863,411
6     32.061%      5.009/5.045/5.059/0.013        0.831/0.847/0.853/0.005       67,955,060
7     31.979%      5.307/5.333/5.343/0.009        0.828/0.843/0.851/0.005       67,782,174
8     31.913%      5.736/5.769/5.783/0.012        0.832/0.844/0.849/0.005       67,641,467
9     31.909%      5.992/6.018/6.030/0.010        0.830/0.840/0.846/0.004       67,634,262

avg1  33.343%                        4.161                          0.854
tot                               1123.509                        230.577      636,057,331

ZLIB-NG-FAST
Both level 8 and level 9 using fast-zlib method.
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.770/1.785/1.795/0.006        0.664/0.674/0.679/0.004      100,930,315
2     35.519%      1.996/2.010/2.018/0.006        0.681/0.695/0.703/0.005       75,286,316
3     34.198%      2.360/2.378/2.387/0.007        0.665/0.681/0.688/0.006       72,485,932
4     32.928%      2.780/2.799/2.806/0.006        0.662/0.667/0.672/0.003       69,794,199
5     32.661%      2.969/2.986/2.996/0.007        0.653/0.663/0.668/0.004       69,226,720
6     32.507%      3.392/3.410/3.421/0.008        0.649/0.663/0.670/0.004       68,902,076
7     32.255%      4.367/4.394/4.408/0.010        0.648/0.662/0.667/0.005       68,366,763
8     31.888%      6.236/6.261/6.271/0.009        0.665/0.670/0.673/0.003       67,588,330
9     31.887%      6.702/6.719/6.730/0.008        0.662/0.668/0.673/0.004       67,586,412

avg1  34.607%                        3.638                          0.672
tot                                982.192                        181.323      660,167,063

ZLIB-NG-FAST (ALL ALGOS)
All algorithms using rolling hash.
 Tool: minigzip-fast-ng-all-algos.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     56.395%      2.093/2.111/2.124/0.008        0.746/0.759/0.766/0.005      119,532,640
 2     38.739%      2.375/2.394/2.405/0.008        0.749/0.765/0.771/0.006       82,110,686
 3     36.143%      3.152/3.166/3.176/0.007        0.706/0.721/0.728/0.006       76,606,874
 4     32.981%      3.227/3.245/3.253/0.007        0.660/0.672/0.677/0.005       69,906,079
 5     32.548%      3.624/3.652/3.664/0.010        0.659/0.671/0.676/0.005       68,987,379
 6     32.224%      4.533/4.566/4.577/0.011        0.663/0.670/0.675/0.003       68,301,003
 7     31.961%      5.584/5.616/5.629/0.010        0.662/0.670/0.677/0.004       67,743,275
 8     31.888%      6.216/6.253/6.268/0.013        0.660/0.671/0.676/0.004       67,588,330
 9     31.887%      6.684/6.718/6.731/0.012        0.664/0.673/0.677/0.004       67,586,412

 avg1  36.085%                        4.191                          0.697
 tot                               1131.622                        188.139      688,362,678

ZLIB-NG-FAST (MAX CHAIN)
Level 9 using 32k max chain length.
Tool: minigzip-fast-ng-max-chain.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.779/1.795/1.803/0.008        0.664/0.674/0.680/0.004      100,930,315
2     35.519%      1.999/2.016/2.026/0.007        0.686/0.698/0.704/0.005       75,286,316
3     34.198%      2.357/2.380/2.394/0.009        0.674/0.685/0.691/0.005       72,485,932
4     32.928%      2.789/2.801/2.811/0.007        0.660/0.669/0.673/0.004       69,794,199
5     32.661%      2.971/2.983/2.992/0.006        0.652/0.664/0.670/0.005       69,226,720
6     32.507%      3.391/3.418/3.428/0.008        0.648/0.664/0.669/0.005       68,902,076
7     32.797%      3.705/3.740/3.753/0.010        0.654/0.668/0.674/0.005       69,515,526
8     31.888%      6.227/6.258/6.273/0.013        0.656/0.670/0.678/0.005       67,588,330
9     31.883%      7.214/7.256/7.270/0.014        0.661/0.671/0.677/0.005       67,579,206

avg1  34.667%                        3.627                          0.674
tot                                979.413                        181.848      661,308,620

Another set of tests from last night using rolling hash for all algorithms and another using high max chain length.
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.335/2.361/2.369/0.007        0.862/0.873/0.881/0.005       77,255,275
 2     35.381%      2.589/2.611/2.618/0.007        0.847/0.864/0.871/0.006       74,991,864
 3     34.426%      3.206/3.232/3.243/0.009        0.832/0.852/0.860/0.007       72,967,657
 4     33.498%      3.430/3.453/3.467/0.009        0.819/0.843/0.849/0.007       71,002,237
 5     32.627%      4.703/4.730/4.740/0.008        0.821/0.835/0.842/0.006       69,156,120
 6     32.188%      6.649/6.670/6.686/0.012        0.819/0.830/0.836/0.005       68,224,174
 7     32.051%      8.008/8.044/8.062/0.014        0.813/0.831/0.837/0.006       67,934,314
 8     31.935%   12.400/12.465/12.483/0.019        0.821/0.829/0.834/0.004       67,688,380
 9     31.916%   15.860/15.926/15.949/0.024        0.817/0.826/0.832/0.004       67,647,801

 avg1  33.385%                        6.610                          0.843
 tot                               1784.743                        227.495      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.762/1.783/1.789/0.006        0.662/0.672/0.678/0.005      100,930,315
2     35.519%      1.971/1.987/1.995/0.007        0.681/0.694/0.700/0.005       75,286,316
3     34.198%      2.334/2.356/2.367/0.007        0.675/0.682/0.688/0.004       72,485,932
4     32.928%      2.758/2.772/2.785/0.009        0.647/0.659/0.667/0.006       69,794,199
5     32.661%      2.949/2.962/2.974/0.007        0.648/0.662/0.668/0.005       69,226,720
6     32.507%      3.374/3.392/3.401/0.007        0.646/0.662/0.668/0.005       68,902,076
7     32.255%      4.321/4.354/4.369/0.013        0.653/0.663/0.668/0.004       68,366,763
8     32.167%      6.506/6.527/6.542/0.009        0.652/0.664/0.668/0.003       68,180,782
9     32.156%      8.891/8.933/8.947/0.012        0.648/0.661/0.666/0.004       68,156,152

avg1  34.668%                        3.896                          0.669
tot                               1051.940                        180.557      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.265/2.278/2.286/0.006        0.861/0.877/0.889/0.007       77,255,275
2     35.381%      2.440/2.465/2.475/0.009        0.847/0.867/0.879/0.008       74,991,864
3     34.426%      2.981/2.999/3.010/0.008        0.840/0.864/0.871/0.008       72,967,657
4     33.481%      3.248/3.276/3.288/0.010        0.838/0.855/0.864/0.007       70,966,161
5     32.489%      4.249/4.268/4.281/0.009        0.833/0.849/0.855/0.005       68,863,411
6     32.061%      5.009/5.045/5.059/0.013        0.831/0.847/0.853/0.005       67,955,060
7     31.979%      5.307/5.333/5.343/0.009        0.828/0.843/0.851/0.005       67,782,174
8     31.913%      5.736/5.769/5.783/0.012        0.832/0.844/0.849/0.005       67,641,467
9     31.909%      5.992/6.018/6.030/0.010        0.830/0.840/0.846/0.004       67,634,262

avg1  33.343%                        4.161                          0.854
tot                               1123.509                        230.577      636,057,331

ZLIB-NG-FAST
Both level 8 and level 9 using fast-zlib method.
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.770/1.785/1.795/0.006        0.664/0.674/0.679/0.004      100,930,315
2     35.519%      1.996/2.010/2.018/0.006        0.681/0.695/0.703/0.005       75,286,316
3     34.198%      2.360/2.378/2.387/0.007        0.665/0.681/0.688/0.006       72,485,932
4     32.928%      2.780/2.799/2.806/0.006        0.662/0.667/0.672/0.003       69,794,199
5     32.661%      2.969/2.986/2.996/0.007        0.653/0.663/0.668/0.004       69,226,720
6     32.507%      3.392/3.410/3.421/0.008        0.649/0.663/0.670/0.004       68,902,076
7     32.255%      4.367/4.394/4.408/0.010        0.648/0.662/0.667/0.005       68,366,763
8     31.888%      6.236/6.261/6.271/0.009        0.665/0.670/0.673/0.003       67,588,330
9     31.887%      6.702/6.719/6.730/0.008        0.662/0.668/0.673/0.004       67,586,412

avg1  34.607%                        3.638                          0.672
tot                                982.192                        181.323      660,167,063

ZLIB-NG-FAST (ALL ALGOS)
All algorithms using rolling hash.
 Tool: minigzip-fast-ng-all-algos.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     56.395%      2.093/2.111/2.124/0.008        0.746/0.759/0.766/0.005      119,532,640
 2     38.739%      2.375/2.394/2.405/0.008        0.749/0.765/0.771/0.006       82,110,686
 3     36.143%      3.152/3.166/3.176/0.007        0.706/0.721/0.728/0.006       76,606,874
 4     32.981%      3.227/3.245/3.253/0.007        0.660/0.672/0.677/0.005       69,906,079
 5     32.548%      3.624/3.652/3.664/0.010        0.659/0.671/0.676/0.005       68,987,379
 6     32.224%      4.533/4.566/4.577/0.011        0.663/0.670/0.675/0.003       68,301,003
 7     31.961%      5.584/5.616/5.629/0.010        0.662/0.670/0.677/0.004       67,743,275
 8     31.888%      6.216/6.253/6.268/0.013        0.660/0.671/0.676/0.004       67,588,330
 9     31.887%      6.684/6.718/6.731/0.012        0.664/0.673/0.677/0.004       67,586,412

 avg1  36.085%                        4.191                          0.697
 tot                               1131.622                        188.139      688,362,678

ZLIB-NG-FAST (MAX CHAIN)
Level 9 using 32k max chain length.
Tool: minigzip-fast-ng-max-chain.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.779/1.795/1.803/0.008        0.664/0.674/0.680/0.004      100,930,315
2     35.519%      1.999/2.016/2.026/0.007        0.686/0.698/0.704/0.005       75,286,316
3     34.198%      2.357/2.380/2.394/0.009        0.674/0.685/0.691/0.005       72,485,932
4     32.928%      2.789/2.801/2.811/0.007        0.660/0.669/0.673/0.004       69,794,199
5     32.661%      2.971/2.983/2.992/0.006        0.652/0.664/0.670/0.005       69,226,720
6     32.507%      3.391/3.418/3.428/0.008        0.648/0.664/0.669/0.005       68,902,076
7     32.797%      3.705/3.740/3.753/0.010        0.654/0.668/0.674/0.005       69,515,526
8     31.888%      6.227/6.258/6.273/0.013        0.656/0.670/0.678/0.005       67,588,330
9     31.883%      7.214/7.256/7.270/0.014        0.661/0.671/0.677/0.005       67,579,206

avg1  34.667%                        3.627                          0.674
tot                                979.413                        181.848      661,308,620

My latest benchmarks - adding a new spread test which tests new config values with level 8 (levels 8 & 9 use fast-zlib).
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.387/2.408/2.418/0.009        0.888/0.901/0.908/0.004       77,255,275
 2     35.381%      2.638/2.655/2.665/0.008        0.876/0.895/0.905/0.008       74,991,864
 3     34.426%      3.271/3.289/3.303/0.009        0.867/0.886/0.894/0.007       72,967,657
 4     33.498%      3.502/3.517/3.526/0.007        0.856/0.874/0.884/0.009       71,002,237
 5     32.627%      4.765/4.801/4.817/0.015        0.869/0.878/0.882/0.003       69,156,120
 6     32.188%      6.713/6.749/6.770/0.015        0.854/0.867/0.873/0.005       68,224,174
 7     32.051%      8.087/8.130/8.151/0.017        0.852/0.865/0.869/0.004       67,934,314
 8     31.935%   12.520/12.581/12.607/0.020        0.854/0.865/0.870/0.004       67,688,380
 9     31.916%   15.983/16.092/16.125/0.033        0.853/0.861/0.868/0.004       67,647,801

 avg1  33.385%                        6.691                          0.877
 tot                               1806.641                        236.755      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.790/1.838/1.848/0.011        0.665/0.673/0.680/0.005      100,930,315
2     35.519%      2.014/2.032/2.039/0.006        0.688/0.698/0.703/0.004       75,286,316
3     34.198%      2.382/2.404/2.412/0.007        0.669/0.680/0.685/0.003       72,485,932
4     32.928%      2.818/2.829/2.836/0.005        0.659/0.665/0.668/0.003       69,794,199
5     32.661%      2.997/3.011/3.021/0.007        0.651/0.662/0.667/0.004       69,226,720
6     32.507%      3.427/3.442/3.453/0.008        0.654/0.661/0.665/0.003       68,902,076
7     32.255%      4.390/4.411/4.421/0.008        0.655/0.662/0.665/0.002       68,366,763
8     32.167%      6.552/6.594/6.615/0.017        0.658/0.663/0.667/0.003       68,180,782
9     32.156%      8.985/9.016/9.030/0.011        0.654/0.663/0.669/0.004       68,156,152

avg1  34.668%                        3.953                          0.670
tot                               1067.300                        180.812      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.308/2.326/2.338/0.008        0.883/0.905/0.918/0.010       77,255,275
2     35.381%      2.490/2.498/2.507/0.005        0.878/0.898/0.908/0.009       74,991,864
3     34.426%      3.033/3.052/3.061/0.008        0.864/0.879/0.892/0.008       72,967,657
4     33.481%      3.322/3.335/3.344/0.007        0.860/0.873/0.881/0.007       70,966,161
5     32.489%      4.296/4.324/4.335/0.010        0.859/0.872/0.878/0.004       68,863,411
6     32.061%      5.091/5.117/5.129/0.011        0.853/0.863/0.869/0.004       67,955,060
7     31.979%      5.382/5.399/5.410/0.007        0.854/0.864/0.869/0.004       67,782,174
8     31.913%      5.819/5.840/5.856/0.011        0.857/0.863/0.866/0.003       67,641,467
9     31.909%      6.058/6.081/6.097/0.012        0.854/0.861/0.865/0.003       67,634,262

avg1  33.343%                        4.219                          0.875
tot                               1139.122                        236.349      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.818/1.834/1.845/0.008        0.664/0.675/0.680/0.004      100,930,315
2     35.519%      2.032/2.054/2.064/0.008        0.686/0.701/0.706/0.005       75,286,316
3     34.198%      2.412/2.430/2.439/0.008        0.676/0.684/0.689/0.004       72,485,932
4     32.928%      2.841/2.852/2.863/0.007        0.657/0.668/0.674/0.005       69,794,199
5     32.661%      3.020/3.039/3.047/0.006        0.656/0.664/0.668/0.004       69,226,720
6     32.507%      3.448/3.467/3.478/0.009        0.657/0.663/0.668/0.003       68,902,076
7     32.255%      4.423/4.453/4.465/0.010        0.654/0.662/0.666/0.004       68,366,763
8     31.888%      6.308/6.336/6.346/0.011        0.661/0.670/0.676/0.004       67,588,330
9     31.887%      6.776/6.799/6.813/0.010        0.659/0.668/0.672/0.004       67,586,412

avg1  34.607%                        3.696                          0.673
tot                                997.906                        181.626      660,167,063

ZLIB-NG-FAST (SPREAD)
Level 8 and 9 using fast-zlib algorithm. I have modified deflate config values to have a better spread of time vs size for level 8.
 Tool: minigzip-fast-ng-spread.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     47.618%      0.957/0.974/0.980/0.006        0.651/0.656/0.661/0.003      100,930,174
 2     35.518%      1.625/1.640/1.651/0.007        0.661/0.673/0.682/0.005       75,282,951
 3     34.198%      1.976/2.002/2.014/0.011        0.649/0.661/0.666/0.005       72,485,720
 4     32.928%      2.403/2.427/2.436/0.008        0.638/0.644/0.648/0.003       69,793,995
 5     32.662%      2.580/2.611/2.623/0.009        0.630/0.639/0.643/0.004       69,228,861
 6     32.507%      3.026/3.039/3.049/0.006        0.632/0.639/0.643/0.003       68,901,208
 7     32.296%      3.564/3.589/3.601/0.009        0.623/0.637/0.642/0.004       68,454,759
 8     31.909%      5.537/5.561/5.576/0.011        0.636/0.642/0.646/0.003       67,633,105
 9     31.887%      6.435/6.460/6.474/0.011        0.633/0.642/0.647/0.003       67,586,412

 avg1  34.614%                        3.145                          0.648
 tot                                849.073                        174.986      660,297,185

My latest benchmarks - adding a new spread test which tests new config values with level 8 (levels 8 & 9 use fast-zlib).
MADLER
 Tool: minigzip-madler.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     36.448%      2.387/2.408/2.418/0.009        0.888/0.901/0.908/0.004       77,255,275
 2     35.381%      2.638/2.655/2.665/0.008        0.876/0.895/0.905/0.008       74,991,864
 3     34.426%      3.271/3.289/3.303/0.009        0.867/0.886/0.894/0.007       72,967,657
 4     33.498%      3.502/3.517/3.526/0.007        0.856/0.874/0.884/0.009       71,002,237
 5     32.627%      4.765/4.801/4.817/0.015        0.869/0.878/0.882/0.003       69,156,120
 6     32.188%      6.713/6.749/6.770/0.015        0.854/0.867/0.873/0.005       68,224,174
 7     32.051%      8.087/8.130/8.151/0.017        0.852/0.865/0.869/0.004       67,934,314
 8     31.935%   12.520/12.581/12.607/0.020        0.854/0.865/0.870/0.004       67,688,380
 9     31.916%   15.983/16.092/16.125/0.033        0.853/0.861/0.868/0.004       67,647,801

 avg1  33.385%                        6.691                          0.877
 tot                               1806.641                        236.755      636,867,822

ZLIB-NG
Tool: minigzip-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.790/1.838/1.848/0.011        0.665/0.673/0.680/0.005      100,930,315
2     35.519%      2.014/2.032/2.039/0.006        0.688/0.698/0.703/0.004       75,286,316
3     34.198%      2.382/2.404/2.412/0.007        0.669/0.680/0.685/0.003       72,485,932
4     32.928%      2.818/2.829/2.836/0.005        0.659/0.665/0.668/0.003       69,794,199
5     32.661%      2.997/3.011/3.021/0.007        0.651/0.662/0.667/0.004       69,226,720
6     32.507%      3.427/3.442/3.453/0.008        0.654/0.661/0.665/0.003       68,902,076
7     32.255%      4.390/4.411/4.421/0.008        0.655/0.662/0.665/0.002       68,366,763
8     32.167%      6.552/6.594/6.615/0.017        0.658/0.663/0.667/0.003       68,180,782
9     32.156%      8.985/9.016/9.030/0.011        0.654/0.663/0.669/0.004       68,156,152

avg1  34.668%                        3.953                          0.670
tot                               1067.300                        180.812      661,329,255

FAST-ZLIB
Tool: minigzip-fast-zlib.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     36.448%      2.308/2.326/2.338/0.008        0.883/0.905/0.918/0.010       77,255,275
2     35.381%      2.490/2.498/2.507/0.005        0.878/0.898/0.908/0.009       74,991,864
3     34.426%      3.033/3.052/3.061/0.008        0.864/0.879/0.892/0.008       72,967,657
4     33.481%      3.322/3.335/3.344/0.007        0.860/0.873/0.881/0.007       70,966,161
5     32.489%      4.296/4.324/4.335/0.010        0.859/0.872/0.878/0.004       68,863,411
6     32.061%      5.091/5.117/5.129/0.011        0.853/0.863/0.869/0.004       67,955,060
7     31.979%      5.382/5.399/5.410/0.007        0.854/0.864/0.869/0.004       67,782,174
8     31.913%      5.819/5.840/5.856/0.011        0.857/0.863/0.866/0.003       67,641,467
9     31.909%      6.058/6.081/6.097/0.012        0.854/0.861/0.865/0.003       67,634,262

avg1  33.343%                        4.219                          0.875
tot                               1139.122                        236.349      636,057,331

ZLIB-NG-FAST
Tool: minigzip-fast-ng.exe Levels: 1-9
Runs: 70         Trim worst: 40

Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
1     47.618%      1.818/1.834/1.845/0.008        0.664/0.675/0.680/0.004      100,930,315
2     35.519%      2.032/2.054/2.064/0.008        0.686/0.701/0.706/0.005       75,286,316
3     34.198%      2.412/2.430/2.439/0.008        0.676/0.684/0.689/0.004       72,485,932
4     32.928%      2.841/2.852/2.863/0.007        0.657/0.668/0.674/0.005       69,794,199
5     32.661%      3.020/3.039/3.047/0.006        0.656/0.664/0.668/0.004       69,226,720
6     32.507%      3.448/3.467/3.478/0.009        0.657/0.663/0.668/0.003       68,902,076
7     32.255%      4.423/4.453/4.465/0.010        0.654/0.662/0.666/0.004       68,366,763
8     31.888%      6.308/6.336/6.346/0.011        0.661/0.670/0.676/0.004       67,588,330
9     31.887%      6.776/6.799/6.813/0.010        0.659/0.668/0.672/0.004       67,586,412

avg1  34.607%                        3.696                          0.673
tot                                997.906                        181.626      660,167,063

ZLIB-NG-FAST (SPREAD)
Level 8 and 9 using fast-zlib algorithm. I have modified deflate config values to have a better spread of time vs size for level 8.
 Tool: minigzip-fast-ng-spread.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     47.618%      0.957/0.974/0.980/0.006        0.651/0.656/0.661/0.003      100,930,174
 2     35.518%      1.625/1.640/1.651/0.007        0.661/0.673/0.682/0.005       75,282,951
 3     34.198%      1.976/2.002/2.014/0.011        0.649/0.661/0.666/0.005       72,485,720
 4     32.928%      2.403/2.427/2.436/0.008        0.638/0.644/0.648/0.003       69,793,995
 5     32.662%      2.580/2.611/2.623/0.009        0.630/0.639/0.643/0.004       69,228,861
 6     32.507%      3.026/3.039/3.049/0.006        0.632/0.639/0.643/0.003       68,901,208
 7     32.296%      3.564/3.589/3.601/0.009        0.623/0.637/0.642/0.004       68,454,759
 8     31.909%      5.537/5.561/5.576/0.011        0.636/0.642/0.646/0.003       67,633,105
 9     31.887%      6.435/6.460/6.474/0.011        0.633/0.642/0.647/0.003       67,586,412

 avg1  34.614%                        3.145                          0.648
 tot                                849.073                        174.986      660,297,185

Looking for feedback.

Looking for feedback.

Rebased.

More benchmarks..
ZLIB-NG (FAST-ZLIB)
PR #828. Fast-zlib uses rolling hash same as zlib.
 Tool: minigzip-fast-zlib.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 1     47.618%      0.966/0.986/1.009/0.012       100,930,174
 2     35.518%      1.639/1.678/1.719/0.021        75,282,951
 3     34.198%      2.024/2.064/2.115/0.024        72,485,720
 4     32.928%      2.454/2.493/2.547/0.025        69,793,995
 5     32.662%      2.674/2.707/2.766/0.027        69,228,861
 6     32.507%      3.124/3.182/3.256/0.035        68,901,208
 7     32.296%      3.715/3.759/3.840/0.039        68,454,759
 8     31.909%      5.689/5.779/5.927/0.066        67,633,105
 9     31.887%      6.656/6.741/6.924/0.074        67,586,412

 avg1  34.614%                        3.265
 tot                                881.633       660,297,185

ZLIB-NG (MIN-MATCH=3: NO MASKING)
This is equivalent to develop branch with no changes. This uses 32-bit integer hashing.
 Tool: minigzip-min-match-3-no-masking.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 1     47.618%      0.978/0.995/1.004/0.007       100,930,174
 2     35.518%      1.624/1.640/1.658/0.009        75,282,951
 3     34.198%      1.990/2.005/2.019/0.008        72,485,720
 4     32.928%      2.391/2.420/2.442/0.012        69,793,995
 5     32.662%      2.588/2.621/2.636/0.012        69,228,861
 6     32.507%      3.071/3.096/3.117/0.011        68,901,208
 7     32.255%      4.100/4.144/4.168/0.017        68,366,778
 8     32.167%      6.510/6.547/6.576/0.020        68,180,776
 9     32.156%      9.117/9.168/9.204/0.022        68,156,160

 avg1  34.668%                        3.626
 tot                                979.089       661,326,623

ZLIB-NG (MIN-MATCH=3: 3 BYTE-MASKING)
In quick_insert_string and insert_string after loading the bytes into 32-bit integer it was hashed with val &= 0xFFFFFF regardless of level, so there was no branch based on trigger level.
 Tool: minigzip-min-match-3-3-byte-masking.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 1     49.397%      1.051/1.068/1.100/0.013       104,701,133
 2     36.070%      1.687/1.719/1.770/0.023        76,453,977
 3     34.235%      2.300/2.337/2.387/0.024        72,563,545
 4     32.879%      2.554/2.579/2.650/0.024        69,689,150
 5     32.513%      2.882/2.921/3.003/0.030        68,913,072
 6     32.255%      3.757/3.814/3.911/0.041        68,366,970
 7     32.027%      6.195/6.246/6.420/0.069        67,883,431
 8     31.910%   10.290/10.393/10.725/0.113        67,636,447
 9     31.893%   13.645/13.800/14.229/0.163        67,600,429

 avg1  34.798%                        4.986
 tot                               1346.263       663,808,154

ZLIB-NG (MIN-MATCH=4)
Minimal changes needed for MIN-MATCH=4. Uses 32-bit integer hashing while comparing a minimum of 4 bytes for each match.
 Tool: minigzip-min-match-4.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 1     47.596%      0.982/0.993/1.007/0.007       100,883,482
 2     35.292%      1.651/1.672/1.695/0.012        74,804,153
 3     34.075%      2.007/2.034/2.058/0.012        72,224,579
 4     32.924%      2.382/2.409/2.432/0.013        69,784,931
 5     32.656%      2.579/2.619/2.654/0.016        69,217,008
 6     32.505%      3.063/3.087/3.112/0.014        68,895,989
 7     32.249%      4.114/4.142/4.167/0.014        68,354,948
 8     32.162%      6.503/6.547/6.582/0.020        68,169,922
 9     32.150%      9.100/9.154/9.214/0.031        68,145,189

 avg1  34.623%                        3.628
 tot                                979.690       660,480,201

rebase needed

Rebased. Squashed an extra clean up commit at the end. Fixed indenting.

I am getting a lot of these warnings, at least when based on top of c475ec95525ac4bbf4838a6943ebd2c88c1fb5a1:
/home/hansr/github/zlib/zlib-ng/deflate.h:284:15: warning: redefinition of typedef ‘deflate_state’ [-Wpedantic]
  284 | } ALIGNED_(8) deflate_state;
      |               ^~~~~~~~~~~~~
/home/hansr/github/zlib/zlib-ng/deflate.h:103:31: note: previous declaration of ‘deflate_state’ was here
  103 | typedef struct internal_state deflate_state;
      |                               ^~~~~~~~~~~~~

Baseline e56238cbc4433b71b75f08deac35addb8426fef6 x86-64
   text    data     bss     dec     hex filename
 112360    1296      32  113688   1bc18 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.164%      1.895/1.911/1.924/0.009        1.005/1.017/1.024/0.005       85,234,591
 2     43.876%      2.032/2.046/2.056/0.007        0.621/0.631/0.636/0.004       41,427,218
 3     42.383%      2.094/2.114/2.128/0.011        0.506/0.512/0.517/0.004       33,347,341
 4     41.669%      1.902/1.931/1.946/0.011        0.391/0.400/0.405/0.004       26,228,657
 5     41.211%      2.145/2.168/2.177/0.008        0.389/0.397/0.401/0.003       25,940,617
 6     41.038%      1.887/1.904/1.913/0.008        0.289/0.295/0.297/0.002       19,373,674
 7     40.781%      1.645/1.655/1.661/0.004        0.193/0.197/0.199/0.002       12,834,980
 8     40.706%      2.061/2.071/2.078/0.006        0.190/0.196/0.200/0.003       12,811,166
 9     40.695%      2.258/2.270/2.276/0.004        0.189/0.198/0.200/0.003       12,807,941

 avg1  42.947%                        2.008                          0.427
 tot                                361.422                         76.862      270,006,185

PR #828 4cb769a130237e413cf75b1519b5afa2a44a1836 x86-64
   text    data     bss     dec     hex filename
 117000    1304      32  118336   1ce40 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.164%      1.919/1.934/1.945/0.008        0.994/1.012/1.021/0.008       85,234,591
 2     43.876%      2.153/2.167/2.174/0.007        0.620/0.632/0.636/0.004       41,427,218
 3     42.383%      2.229/2.246/2.259/0.009        0.501/0.510/0.515/0.004       33,347,341
 4     41.669%      2.020/2.034/2.044/0.008        0.398/0.401/0.405/0.003       26,228,657
 5     41.211%      2.240/2.277/2.297/0.017        0.382/0.396/0.402/0.005       25,940,617
 6     41.038%      1.961/1.990/2.007/0.013        0.289/0.295/0.298/0.002       19,373,674
 7     40.822%      1.595/1.601/1.606/0.003        0.191/0.196/0.201/0.003       12,847,853
 8     40.443%      2.447/2.461/2.468/0.006        0.194/0.199/0.202/0.002       12,728,578
 9     40.423%      2.549/2.565/2.574/0.006        0.192/0.197/0.201/0.002       12,722,161

 avg1  42.892%                        2.142                          0.427
 tot                                385.493                         76.787      269,850,690

Big increase in compiled size.
6.7% slower compression on average.
lvl 6: ~4.5% slower
lvl 7: ~3.4% slower.  ~0.1% smaller compressed size.
lvl 8: ~18.8% slower. ~0.64% smaller compressed size.
lvl 9:  ~13.0% slower. ~0.67% smaller compressed size.

Baseline e56238cbc4433b71b75f08deac35addb8426fef6 aarch64
   text    data     bss     dec     hex filename
 103138    1504      16  104658   198d2 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.768/2.818/2.842/0.020        0.990/1.012/1.026/0.012       42,618,858
 2     43.879%      2.809/2.855/2.880/0.019        0.593/0.607/0.618/0.008       20,714,938
 3     42.383%      3.717/3.754/3.772/0.016        0.557/0.585/0.613/0.016       20,008,755
 4     41.660%      2.779/2.794/2.807/0.010        0.352/0.374/0.390/0.011       13,111,391
 5     41.216%      2.988/3.027/3.044/0.015        0.356/0.374/0.381/0.008       12,971,746
 6     41.039%      3.503/3.538/3.556/0.016        0.355/0.375/0.383/0.007       12,916,025
 7     40.778%      2.259/2.270/2.285/0.008        0.169/0.180/0.189/0.006        6,416,924
 8     40.704%      2.789/2.808/2.817/0.008        0.156/0.174/0.188/0.010        6,405,244
 9     40.696%      2.993/3.018/3.033/0.014        0.160/0.177/0.188/0.008        6,404,084

 avg1  42.947%                        2.987                          0.429
 tot                                403.221                         57.867      141,567,965

PR #828 4cb769a130237e413cf75b1519b5afa2a44a1836 aarch64
   text    data     bss     dec     hex filename
 107506    1552      16  109074   1aa12 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.759/2.824/2.853/0.027        0.972/1.007/1.021/0.014       42,618,858
 2     43.879%      3.028/3.045/3.064/0.013        0.562/0.604/0.624/0.017       20,714,938
 3     42.383%      3.922/3.950/3.985/0.021        0.559/0.597/0.615/0.017       20,008,755
 4     41.660%      2.938/2.962/2.979/0.015        0.348/0.377/0.395/0.014       13,111,391
 5     41.216%      3.184/3.213/3.230/0.014        0.347/0.365/0.379/0.009       12,971,746
 6     41.039%      3.768/3.801/3.815/0.015        0.364/0.374/0.384/0.006       12,916,025
 7     40.822%      2.368/2.385/2.397/0.009        0.168/0.180/0.189/0.007        6,423,802
 8     40.433%      3.208/3.224/3.235/0.010        0.165/0.185/0.193/0.008        6,362,598
 9     40.409%      3.362/3.389/3.407/0.013        0.169/0.182/0.197/0.009        6,358,951

 avg1  42.890%                        3.199                          0.430
 tot                                431.897                         58.056      141,487,064

Big increase in compiled size.
7.1% slower compression on average.
lvl 6: ~7.4% slower
lvl 7: ~5.1% slower. ~0.1% smaller compressed size.
lvl 8: ~14.8% slower. ~0.66% smaller compressed size.
lvl 9: ~12.3% slower. ~0.70% smaller compressed size.

Something must not be working right.

I have removed one of the commits I added that would spread out the compression levels which may not be good for all data types.

silesia.tar
DEVELOP
Tool: C:\Users\Nathan\Source\zlib-ng\build-develop\Release\minigzip.exe
Activated single file mode
Level 7-9: C:\Users\Nathan\Source\deflatebench\silesia.tar  202.1 MiB   211,957,760 B
Starting run 1 of 70
Testing level 7: c   4.423   0.000      68,366,800  32.255%
Testing level 8: c   6.545   0.000      68,180,776  32.167%
Testing level 9: c   9.093   0.000      68,156,160  32.156%
Starting run 2 of 70
Testing level 7: c   4.195   0.000      68,366,800  32.255%
Testing level 8: c   6.550   0.000      68,180,776  32.167%
Testing level 9: c   9.117   0.000      68,156,160  32.156%

FAST PR (https://github.com/zlib-ng/zlib-ng/pull/828/commits/57090fbc8cd763585ce3db797aea74b2a0c91e9e)
Starting run 1 of 70
Testing level 7: c   4.372   0.000      68,366,800  32.255%
Testing level 8: c   6.672   0.000      68,180,776  32.167%
Testing level 9: c   6.935   0.000      67,586,442  31.887%
Starting run 2 of 70
Testing level 7: c   4.341   0.000      68,366,800  32.255%
Testing level 8: c   7.324   0.000      68,180,776  32.167%
Testing level 9: c   7.002   0.000      67,586,442  31.887%
Starting run 3 of 70
Testing level 7: c   4.394   0.000      68,366,800  32.255%
Testing level 8: c   6.957   0.000      68,180,776  32.167%
Testing level 9: c   7.156   0.000      67,586,442  31.887%

silesia-small.tar
DEVELOP
Starting run 1 of 70
Testing level 7: c   0.377   0.000       6,416,919  40.778%
Testing level 8: c   0.468   0.000       6,405,244  40.704%
Testing level 9: c   0.494   0.000       6,404,084  40.696%
Starting run 2 of 70
Testing level 7: c   0.360   0.000       6,416,919  40.778%
Testing level 8: c   0.457   0.000       6,405,244  40.704%
Testing level 9: c   0.516   0.000       6,404,084  40.696%
Starting run 3 of 70
Testing level 7: c   0.364   0.000       6,416,919  40.778%
Testing level 8: c   0.456   0.000       6,405,244  40.704%
Testing level 9: c   0.504   0.000       6,404,084  40.696%

FAST PR (https://github.com/zlib-ng/zlib-ng/pull/828/commits/57090fbc8cd763585ce3db797aea74b2a0c91e9e)
Tool: C:\Users\Nathan\Source\zlib-ng\build\Release\minigzip.exe
Activated single file mode
Level 7-9: C:\Users\Nathan\Source\deflatebench\silesia-small.tar   15.0 MiB    15,736,320 B
Starting run 1 of 70
Testing level 7: c   0.365   0.000       6,416,919  40.778%
Testing level 8: c   0.469   0.000       6,405,244  40.704%
Testing level 9: c   0.523   0.000       6,358,951  40.409%
Starting run 2 of 70
Testing level 7: c   0.371   0.000       6,416,919  40.778%
Testing level 8: c   0.478   0.000       6,405,244  40.704%
Testing level 9: c   0.517   0.000       6,358,951  40.409%
Starting run 3 of 70
Testing level 7: c   0.374   0.000       6,416,919  40.778%
Testing level 8: c   0.462   0.000       6,405,244  40.704%
Testing level 9: c   0.533   0.000       6,358,951  40.409%
Starting run 4 of 70
Testing level 7: c   0.364   0.000       6,416,919  40.778%
Testing level 8: c   0.467   0.000       6,405,244  40.704%
Testing level 9: c   0.528   0.000       6,358,951  40.409%

corpora.tar
DEVELOP
Tool: C:\Users\Nathan\Source\zlib-ng\build-develop\Release\minigzip.exe
Activated single file mode
Level 7-9: C:\Users\Nathan\Source\deflatebench\corpora.tar  221.5 MiB   232,249,344 B
Starting run 1 of 70
Testing level 7: c   5.255   0.000      74,461,300  32.061%
Testing level 8: c   7.965   0.000      74,269,032  31.978%
Testing level 9: c  10.993   0.000      74,230,342  31.961%
Starting run 2 of 70
Testing level 7: c   5.257   0.000      74,461,300  32.061%
Testing level 8: c   8.056   0.000      74,269,032  31.978%
Testing level 9: c  10.642   0.000      74,230,342  31.961%
Starting run 3 of 70
Testing level 7: c   5.000   0.000      74,461,300  32.061%
Testing level 8: c   7.699   0.000      74,269,032  31.978%
Testing level 9: c  10.743   0.000      74,230,342  31.961%

FAST PR (https://github.com/zlib-ng/zlib-ng/pull/828/commits/57090fbc8cd763585ce3db797aea74b2a0c91e9e)
Tool: C:\Users\Nathan\Source\zlib-ng\build\Release\minigzip.exe
Activated single file mode
Level 7-9: C:\Users\Nathan\Source\deflatebench\corpora.tar  221.5 MiB   232,249,344 B
Starting run 1 of 70
Testing level 7: c   5.271   0.000      74,461,300  32.061%
Testing level 8: c   8.111   0.000      74,269,032  31.978%
Testing level 9: c   9.944   0.000      73,685,100  31.727%
Starting run 2 of 70
Testing level 7: c   5.218   0.000      74,461,300  32.061%
Testing level 8: c   8.022   0.000      74,269,032  31.978%
Testing level 9: c  10.248   0.000      73,685,100  31.727%
Starting run 3 of 70
Testing level 7: c   5.289   0.000      74,461,300  32.061%
Testing level 8: c   7.921   0.000      74,269,032  31.978%
Testing level 9: c  10.029   0.000      73,685,100  31.727%

Remember, fast-zlib doesn't promise faster compression always, only that it should take equal or less time and achieve better compression results.

I think the problem was use of WANT_MIN_MATCH instead of STD_MIN_MATCH...

😀

Retested with current develop HEAD and updated PR.
Baseline e56238cbc4433b71b75f08deac35addb8426fef6 x86-64
   text    data     bss     dec     hex filename
 112360    1296      32  113688   1bc18 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.164%      1.886/1.914/1.922/0.008        1.003/1.015/1.024/0.006       85,234,591
 2     43.876%      2.026/2.037/2.045/0.006        0.623/0.633/0.639/0.004       41,427,218
 3     42.383%      2.079/2.092/2.104/0.008        0.502/0.513/0.516/0.004       33,347,341
 4     41.669%      1.898/1.913/1.924/0.008        0.390/0.398/0.403/0.004       26,228,657
 5     41.211%      2.145/2.162/2.174/0.009        0.387/0.396/0.400/0.004       25,940,617
 6     41.038%      1.880/1.901/1.912/0.008        0.286/0.295/0.299/0.004       19,373,674
 7     40.781%      1.645/1.653/1.659/0.004        0.184/0.194/0.199/0.004       12,834,980
 8     40.706%      2.059/2.069/2.078/0.005        0.156/0.193/0.198/0.009       12,811,166
 9     40.695%      2.261/2.269/2.274/0.004        0.190/0.196/0.198/0.003       12,807,941

 avg1  42.947%                        2.001                          0.426
 tot                                360.206                         76.677      270,006,185

PR #828 36b41145b52d500540517bebdb517e867da51f8b x86-64
   text    data     bss     dec     hex filename
 117000    1304      32  118336   1ce40 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.164%      1.914/1.930/1.937/0.006        1.000/1.010/1.017/0.005       85,234,591
 2     43.876%      2.152/2.167/2.173/0.007        0.626/0.632/0.636/0.003       41,427,218
 3     42.383%      2.216/2.237/2.247/0.010        0.501/0.510/0.515/0.004       33,347,341
 4     41.669%      2.010/2.033/2.050/0.012        0.394/0.400/0.405/0.003       26,228,657
 5     41.211%      2.254/2.289/2.308/0.016        0.388/0.397/0.401/0.004       25,940,617
 6     41.038%      1.966/1.997/2.013/0.014        0.288/0.295/0.298/0.003       19,373,674
 7     40.781%      1.749/1.757/1.764/0.005        0.190/0.197/0.200/0.003       12,834,980
 8     40.706%      2.169/2.175/2.181/0.004        0.185/0.197/0.201/0.004       12,811,166
 9     40.423%      2.538/2.566/2.574/0.008        0.194/0.199/0.202/0.002       12,722,161

 avg1  42.917%                        2.128                          0.426
 tot                                383.025                         76.752      269,920,405

Baseline e56238cbc4433b71b75f08deac35addb8426fef6 aarch64
   text    data     bss     dec     hex filename
 103754    1504      16  105274   19b3a libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.775/2.807/2.826/0.016        0.978/1.001/1.019/0.013       42,618,858
 2     43.879%      2.816/2.852/2.875/0.018        0.576/0.605/0.619/0.013       20,714,938
 3     42.383%      3.734/3.759/3.779/0.013        0.557/0.582/0.602/0.014       20,008,755
 4     41.660%      2.748/2.796/2.817/0.023        0.362/0.380/0.394/0.008       13,111,391
 5     41.216%      2.998/3.027/3.049/0.018        0.364/0.377/0.385/0.006       12,971,746
 6     41.039%      3.529/3.547/3.559/0.008        0.360/0.375/0.385/0.009       12,916,025
 7     40.778%      2.244/2.272/2.287/0.013        0.161/0.182/0.191/0.009        6,416,924
 8     40.704%      2.776/2.805/2.816/0.010        0.163/0.177/0.185/0.007        6,405,244
 9     40.696%      3.004/3.024/3.042/0.013        0.164/0.179/0.189/0.007        6,404,084

 avg1  42.947%                        2.988                          0.429
 tot                                403.341                         57.879      141,567,965

PR #828 36b41145b52d500540517bebdb517e867da51f8b aarch64
   text    data     bss     dec     hex filename
 107498    1552      16  109066   1aa0a libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.798/2.822/2.848/0.017        0.963/0.997/1.014/0.014       42,618,858
 2     43.879%      3.007/3.044/3.068/0.018        0.586/0.607/0.625/0.013       20,714,938
 3     42.383%      3.902/3.943/3.956/0.014        0.556/0.588/0.607/0.018       20,008,755
 4     41.660%      2.956/2.978/2.993/0.013        0.364/0.378/0.387/0.007       13,111,391
 5     41.216%      3.195/3.226/3.242/0.014        0.355/0.369/0.377/0.006       12,971,746
 6     41.039%      3.771/3.796/3.813/0.013        0.360/0.375/0.384/0.009       12,916,025
 7     40.778%      2.580/2.610/2.622/0.012        0.166/0.178/0.186/0.006        6,416,924
 8     40.704%      3.216/3.238/3.252/0.010        0.165/0.178/0.185/0.007        6,405,244
 9     40.409%      3.382/3.392/3.400/0.006        0.175/0.192/0.201/0.007        6,358,951

 avg1  42.915%                        3.228                          0.429
 tot                                435.747                         57.924      141,522,832

I must confess that I am having a hard time reviewing this.
The first commit is very big and also contains a lot of changes that are not actual code changes and should perhaps instead be in a prep-commit. I also feel like it would have been easier if the changes were split up into two/three parts, one for changing the framework and one for actually making the algorithm changes (and perhaps the algo before functable change so we can see all-level impact without level checks?). That would also let us easily make profiles to compare between before, with framework changes, and with all the changes.
Perhaps also squash the minor fixes commits.
I have read through all the changes probably 5 times by now, but I am unable to get a good enough overview so I can give good consideration and feedback.  😅
My current thoughts are that level 9 looks nice indeed, but that the rest of the levels pay a quite high price, perhaps especially on ARM. We can probably live with that though.

Thanks for do benchmarks agian. I think it may have to do with the whole s->insert_string stuff. If we assigned that function name lookup to a variable in the deflate functions it might go faster. But it could also be a compiler issue somewhere else.
I will split the first commit into a couple of them so we can better get an idea of where the slow down is occuring.

@Dead2 I have split this PR better into more logic commits. Can you please let me know if you think about it now?

ZLIB-NG https://github.com/zlib-ng/zlib-ng/commit/e2705f826e281917c2c0b3ba4abaf594f7b85f37
 Tool: minigzip-ng.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.866/3.891/3.905/0.011        68,366,800
 8     32.167%      6.045/6.078/6.100/0.016        68,180,776
 9     32.156%      8.427/8.464/8.504/0.021        68,156,160

 avg1  32.193%                        6.144
 tot                                552.970       204,703,736

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/31c522f0b383617bcb59b2a6122e3765223ccc33
 Tool: minigzip-ng-fast-commit-1.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.805/3.821/3.828/0.006        68,366,800
 8     32.167%      5.977/5.992/5.999/0.006        68,180,776
 9     32.156%      8.351/8.371/8.381/0.008        68,156,160

 avg1  32.193%                        6.061
 tot                                545.499       204,703,736

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/0ee94deda9aab62a666e287ded1b8553c354222e
 Tool: minigzip-ng-fast-commit-2.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.802/3.826/3.838/0.009        68,366,800
 8     32.167%      5.967/6.000/6.015/0.012        68,180,776
 9     32.156%      8.353/8.382/8.400/0.014        68,156,160

 avg1  32.193%                        6.069
 tot                                546.213       204,703,736

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/484de65ccc1f6001af94f74b0eef46489b08afa8
 Tool: minigzip-ng-fast-commit-3.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.897/3.989/4.099/0.073        68,366,800
 8     32.167%      6.075/6.180/6.359/0.096        68,180,776
 9     32.156%      8.444/8.616/8.855/0.163        68,156,160

 avg1  32.193%                        6.261
 tot                                563.520       204,703,736

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/5460d0aad2ad0e6eafb743bd186f79ab383ccf3a
 Tool: minigzip-ng-fast-commit-4.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.893/3.907/3.916/0.007        68,366,800
 8     32.167%      6.067/6.081/6.088/0.006        68,180,776
 9     32.156%      8.429/8.452/8.463/0.007        68,156,160

 avg1  32.193%                        6.147
 tot                                553.228       204,703,736

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/dcdd9bba3ec468e8c91048925ec2f58753267bba
 Tool: minigzip-ng-fast-commit-5.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.964/3.979/3.989/0.007        68,366,800
 8     32.167%      6.139/6.153/6.165/0.008        68,180,776
 9     35.404%      3.242/3.258/3.264/0.007        75,041,407

 avg1  33.275%                        4.463
 tot                                401.689       211,588,983

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/8dcb0b86775cbcab4983fd8c79ae211ede8cd41b
 Tool: minigzip-ng-fast-commit-6.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.965/3.977/3.987/0.006        68,366,800
 8     32.167%      6.132/6.155/6.163/0.008        68,180,776
 9     31.887%      6.357/6.377/6.389/0.008        67,586,442

 avg1  32.103%                        5.503
 tot                                495.264       204,134,018

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80
 Tool: minigzip-ng-fast-commit-7.exe Levels: 7-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev   Compressed size
 7     32.255%      3.966/3.988/4.000/0.010        68,366,800
 8     32.167%      6.139/6.162/6.173/0.009        68,180,776
 9     31.887%      6.365/6.389/6.402/0.010        67,586,442

 avg1  32.103%                        5.513
 tot                                496.159       204,134,018

I forgot to turn on the other levels but do another run of tests.
~10% compression speed improvement.
~1% compression size improvement. (~560KB)

Corpora.tar
ZLIB-NG https://github.com/zlib-ng/zlib-ng/commit/e2705f826e281917c2c0b3ba4abaf594f7b85f37
 Tool: minigzip-ng.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.025/1.034/1.042/0.004        0.663/0.675/0.680/0.004      104,067,822
 2     35.391%      1.690/1.701/1.709/0.006        0.684/0.691/0.696/0.003       82,195,416
 3     33.698%      2.180/2.189/2.196/0.005        0.653/0.667/0.672/0.005       78,262,436
 4     32.989%      2.490/2.504/2.512/0.006        0.644/0.653/0.660/0.005       76,616,183
 5     32.483%      2.755/2.775/2.787/0.009        0.643/0.649/0.655/0.003       75,441,984
 6     32.318%      3.377/3.394/3.401/0.007        0.641/0.649/0.654/0.004       75,058,801
 7     32.061%      4.647/4.665/4.679/0.010        0.646/0.653/0.661/0.004       74,461,300
 8     31.978%      7.159/7.176/7.190/0.009        0.640/0.651/0.657/0.004       74,269,032
 9     31.961%      9.714/9.748/9.770/0.014        0.645/0.654/0.659/0.004       74,230,342

 avg1  34.188%                        3.910                          0.660
 tot                               1055.584                        178.248      714,603,316

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/31c522f0b383617bcb59b2a6122e3765223ccc33
 Tool: minigzip-ng-fast-commit-1.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.005/1.015/1.021/0.005        0.662/0.673/0.679/0.005      104,067,822
 2     35.391%      1.716/1.726/1.734/0.006        0.676/0.690/0.696/0.004       82,195,416
 3     33.698%      2.217/2.231/2.238/0.006        0.653/0.664/0.670/0.004       78,262,436
 4     32.989%      2.541/2.558/2.567/0.007        0.642/0.652/0.656/0.003       76,616,183
 5     32.483%      2.766/2.784/2.792/0.007        0.639/0.648/0.652/0.004       75,441,984
 6     32.318%      3.376/3.394/3.406/0.007        0.638/0.646/0.652/0.004       75,058,801
 7     32.061%      4.594/4.612/4.620/0.006        0.645/0.652/0.656/0.003       74,461,300
 8     31.978%      7.096/7.114/7.124/0.009        0.642/0.650/0.654/0.003       74,269,032
 9     31.961%      9.662/9.683/9.692/0.008        0.643/0.652/0.656/0.003       74,230,342

 avg1  34.188%                        3.902                          0.658
 tot                               1053.501                        177.748      714,603,316

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/0ee94deda9aab62a666e287ded1b8553c354222e
 Tool: minigzip-ng-fast-commit-2.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.007/1.016/1.022/0.004        0.663/0.673/0.679/0.005      104,067,822
 2     35.391%      1.713/1.731/1.739/0.006        0.680/0.689/0.696/0.004       82,195,416
 3     33.698%      2.204/2.215/2.223/0.005        0.655/0.666/0.671/0.005       78,262,436
 4     32.989%      2.517/2.532/2.538/0.005        0.642/0.653/0.659/0.003       76,616,183
 5     32.483%      2.771/2.788/2.796/0.007        0.643/0.650/0.656/0.004       75,441,984
 6     32.318%      3.385/3.401/3.413/0.008        0.641/0.648/0.654/0.004       75,058,801
 7     32.061%      4.592/4.608/4.620/0.008        0.645/0.654/0.661/0.004       74,461,300
 8     31.978%      7.088/7.112/7.124/0.010        0.644/0.651/0.656/0.003       74,269,032
 9     31.961%      9.669/9.684/9.693/0.007        0.644/0.652/0.658/0.004       74,230,342

 avg1  34.188%                        3.899                          0.660
 tot                               1052.638                        178.099      714,603,316

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/484de65ccc1f6001af94f74b0eef46489b08afa8
 Tool: minigzip-ng-fast-commit-3.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.019/1.026/1.031/0.004        0.656/0.669/0.674/0.004      104,067,822
 2     35.391%      1.682/1.699/1.706/0.005        0.673/0.685/0.691/0.005       82,195,416
 3     33.698%      2.172/2.184/2.192/0.006        0.650/0.659/0.664/0.004       78,262,436
 4     32.989%      2.481/2.505/2.516/0.009        0.641/0.648/0.652/0.003       76,616,183
 5     32.483%      2.750/2.764/2.772/0.006        0.638/0.644/0.649/0.003       75,441,984
 6     32.318%      3.355/3.373/3.385/0.009        0.633/0.641/0.646/0.003       75,058,801
 7     32.061%      4.688/4.719/4.728/0.009        0.638/0.648/0.654/0.004       74,461,300
 8     31.978%      7.204/7.229/7.241/0.010        0.640/0.647/0.652/0.003       74,269,032
 9     31.961%      9.782/9.802/9.816/0.009        0.640/0.648/0.653/0.004       74,230,342

 avg1  34.188%                        3.922                          0.654
 tot                               1059.062                        176.690      714,603,316

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/5460d0aad2ad0e6eafb743bd186f79ab383ccf3a
 Tool: minigzip-ng-fast-commit-4.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.014/1.027/1.034/0.005        0.660/0.669/0.674/0.004      104,067,822
 2     35.391%      1.687/1.700/1.708/0.005        0.674/0.685/0.692/0.005       82,195,416
 3     33.698%      2.168/2.183/2.190/0.006        0.654/0.659/0.663/0.003       78,262,436
 4     32.989%      2.491/2.503/2.512/0.006        0.640/0.648/0.653/0.004       76,616,183
 5     32.483%      2.749/2.763/2.771/0.006        0.637/0.645/0.649/0.003       75,441,984
 6     32.318%      3.353/3.372/3.382/0.009        0.631/0.643/0.647/0.004       75,058,801
 7     32.061%      4.698/4.719/4.729/0.009        0.642/0.648/0.655/0.004       74,461,300
 8     31.978%      7.205/7.231/7.245/0.012        0.640/0.647/0.652/0.004       74,269,032
 9     31.961%      9.777/9.798/9.807/0.008        0.640/0.648/0.655/0.004       74,230,342

 avg1  34.188%                        3.922                          0.655
 tot                               1058.891                        176.739      714,603,316

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/dcdd9bba3ec468e8c91048925ec2f58753267bba
 Tool: minigzip-ng-fast-commit-5.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.014/1.019/1.023/0.003        0.662/0.669/0.676/0.004      104,067,822
 2     35.391%      1.735/1.754/1.763/0.007        0.674/0.685/0.692/0.005       82,195,416
 3     33.698%      2.228/2.248/2.257/0.008        0.654/0.661/0.667/0.004       78,262,436
 4     32.989%      2.557/2.572/2.580/0.007        0.642/0.650/0.656/0.004       76,616,183
 5     32.483%      2.819/2.833/2.841/0.006        0.635/0.643/0.648/0.004       75,441,984
 6     32.318%      3.435/3.452/3.462/0.007        0.638/0.644/0.648/0.003       75,058,801
 7     32.061%      4.779/4.799/4.812/0.009        0.642/0.649/0.653/0.003       74,461,300
 8     31.978%      7.292/7.314/7.325/0.008        0.643/0.648/0.652/0.003       74,269,032
 9     35.245%      3.604/3.619/3.628/0.006        0.673/0.687/0.692/0.004       81,855,360

 avg1  34.552%                        3.290                          0.660
 tot                                888.322                        178.080      722,228,334

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/8dcb0b86775cbcab4983fd8c79ae211ede8cd41b
 Tool: minigzip-ng-fast-commit-6.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.022/1.027/1.033/0.003        0.659/0.669/0.677/0.005      104,067,822
 2     35.391%      1.756/1.769/1.776/0.005        0.681/0.690/0.696/0.005       82,195,416
 3     33.698%      2.265/2.279/2.287/0.006        0.654/0.664/0.671/0.005       78,262,436
 4     32.989%      2.586/2.603/2.612/0.007        0.644/0.652/0.656/0.003       76,616,183
 5     32.483%      2.848/2.858/2.867/0.005        0.638/0.648/0.653/0.003       75,441,984
 6     32.318%      3.456/3.471/3.480/0.007        0.637/0.647/0.652/0.004       75,058,801
 7     32.061%      4.787/4.806/4.813/0.007        0.641/0.650/0.654/0.004       74,461,300
 8     31.978%      7.295/7.319/7.330/0.009        0.644/0.649/0.654/0.003       74,269,032
 9     31.727%      9.183/9.214/9.230/0.011        0.638/0.648/0.653/0.004       73,685,100

 avg1  34.161%                        3.927                          0.657
 tot                               1060.358                        177.489      714,058,074

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80
 Tool: minigzip-ng-fast-commit-7.exe Levels: 1-9
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.809%      1.021/1.028/1.033/0.004        0.657/0.668/0.674/0.004      104,067,822
 2     35.391%      1.750/1.768/1.776/0.006        0.673/0.688/0.694/0.005       82,195,416
 3     33.698%      2.255/2.279/2.287/0.007        0.653/0.663/0.668/0.004       78,262,436
 4     32.989%      2.579/2.599/2.605/0.006        0.640/0.651/0.657/0.004       76,616,183
 5     32.483%      2.840/2.857/2.864/0.006        0.639/0.648/0.653/0.004       75,441,984
 6     32.318%      3.451/3.473/3.483/0.008        0.635/0.645/0.651/0.004       75,058,801
 7     32.061%      4.788/4.810/4.821/0.007        0.642/0.650/0.654/0.003       74,461,300
 8     31.978%      7.306/7.326/7.334/0.008        0.641/0.649/0.654/0.003       74,269,032
 9     31.727%      9.196/9.223/9.236/0.012        0.642/0.647/0.652/0.003       73,685,100

 avg1  34.161%                        3.929                          0.657
 tot                               1060.823                        177.309      714,058,074

~0.5% compression speed loss
~0.8% compression size gain (545KB)

Perf shows the following profiles when decompressing a 2.4GiB .gz file:
Baseline e2705f826e281917c2c0b3ba4abaf594f7b85f37
  Children      Self       sys       usr  Command          Symbol
+   52.57%    51.47%     0.00%    51.47%  minigzip-baseli  [.] zng_inflate_fast
+   24.03%    24.02%     0.00%    24.02%  minigzip-baseli  [.] crc32_little
+    7.80%     7.79%     0.00%     7.79%  minigzip-baseli  [.] zng_inflate_table
+    7.19%     6.62%     0.00%     6.62%  minigzip-baseli  [.] chunkcopy_avx
+    3.31%     3.31%     0.00%     3.31%  minigzip-baseli  [.] zng_inflate
+    1.03%     1.01%     0.00%     1.01%  minigzip-baseli  [.] chunkcopy_safe_avx
+    0.94%     0.92%     0.00%     0.92%  minigzip-baseli  [.] chunkmemset_avx
     0.04%     0.02%     0.00%     0.02%  minigzip-baseli  [.] chunkmemset_safe_avx
     0.01%     0.01%     0.00%     0.01%  minigzip-baseli  [.] gz_read
     0.01%     0.01%     0.00%     0.01%  minigzip-baseli  [.] memcpy@plt
     0.01%     0.01%     0.00%     0.01%  minigzip-baseli  [.] gz_decomp
     0.01%     0.01%     0.00%     0.01%  minigzip-baseli  [.] zng_gzread

PR828 edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80
  Children      Self       sys       usr  Command          Symbol
+   52.57%    51.47%     0.00%    51.47%  minigzip-pr828-  [.] zng_inflate_fast
+   24.06%    24.05%     0.00%    24.05%  minigzip-pr828-  [.] crc32_little
+    7.70%     7.69%     0.00%     7.69%  minigzip-pr828-  [.] zng_inflate_table
+    7.25%     6.67%     0.00%     6.67%  minigzip-pr828-  [.] chunkcopy_avx
+    3.28%     3.27%     0.00%     3.27%  minigzip-pr828-  [.] zng_inflate
+    1.08%     1.06%     0.00%     1.06%  minigzip-pr828-  [.] chunkcopy_safe_avx
+    0.94%     0.91%     0.00%     0.91%  minigzip-pr828-  [.] chunkmemset_avx
     0.04%     0.02%     0.00%     0.02%  minigzip-pr828-  [.] chunkmemset_safe_avx
     0.01%     0.01%     0.00%     0.01%  minigzip-pr828-  [.] gz_read
     0.01%     0.01%     0.00%     0.01%  minigzip-pr828-  [.] memcpy@plt
     0.01%     0.01%     0.00%     0.01%  minigzip-pr828-  [.] gz_decomp
     0.01%     0.01%     0.00%     0.01%  minigzip-pr828-  [.] zng_gzread

Baseline e56238cbc4433b71b75f08deac35addb8426fef6 x86-64
   text    data     bss     dec     hex filename
 113433    1376      32  114841   1c099 libz-ng.so.2

 Tool: minigzip   Levels: 1-9
 Runs: 30         Trim worst: 15

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.165%      2.975/3.007/3.022/0.014        1.647/1.675/1.690/0.015      264,231,515
 2     43.875%      2.950/2.991/3.006/0.013        0.992/1.008/1.022/0.011      124,277,644
 3     42.382%      2.980/2.997/3.010/0.008        0.800/0.813/0.823/0.007      100,039,412
 4     41.669%      2.730/2.749/2.766/0.012        0.616/0.631/0.643/0.007       78,685,354
 5     41.215%      2.924/2.933/2.946/0.007        0.565/0.580/0.589/0.007       71,342,944
 6     41.036%      2.804/2.823/2.834/0.009        0.461/0.473/0.478/0.005       58,118,026
 7     40.781%      2.723/2.738/2.748/0.008        0.352/0.362/0.371/0.006       44,921,649
 8     40.702%      3.009/3.015/3.021/0.004        0.310/0.317/0.324/0.005       38,429,965
 9     40.698%      2.774/2.793/2.801/0.009        0.253/0.264/0.270/0.005       32,021,745

 avg1  42.947%                        2.894                          0.680
 tot                                390.693                         91.864      812,068,254

PR #828 edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80 x86-64
   text    data     bss     dec     hex filename
 118505    1384      32  119921   1d471 libz-ng.so.2

 Tool: minigzip   Levels: 1-9
 Runs: 30         Trim worst: 15

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.165%      3.002/3.024/3.040/0.012        1.645/1.668/1.688/0.017      264,231,515
 2     43.875%      3.055/3.066/3.080/0.009        0.982/1.007/1.016/0.009      124,277,644
 3     42.382%      2.996/3.025/3.046/0.017        0.779/0.810/0.823/0.011      100,039,412
 4     41.669%      2.768/2.785/2.796/0.008        0.622/0.634/0.642/0.007       78,685,354
 5     41.215%      2.954/2.976/2.994/0.013        0.558/0.581/0.588/0.008       71,342,944
 6     41.036%      2.832/2.857/2.869/0.010        0.459/0.472/0.478/0.006       58,118,026
 7     40.781%      2.781/2.796/2.805/0.008        0.348/0.365/0.371/0.006       44,921,649
 8     40.702%      3.054/3.068/3.078/0.007        0.307/0.313/0.317/0.004       38,429,965
 9     40.421%      2.976/2.988/2.996/0.005        0.245/0.257/0.265/0.006       31,804,100

 avg1  42.916%                        2.954                          0.678
 tot                                398.783                         91.589      811,850,609

Not sure what changed, but it does seem better now.
I have no objections at this point, and would feel good getting this merged.

Baseline 834e7d83eae9ff7bfb1b9769d9f311ea7ca8e746 aarch64
   text    data     bss     dec     hex filename
 105194    1576      16  106786   1a122 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.746/2.764/2.780/0.011        0.965/0.993/1.015/0.013       42,618,858
 2     43.879%      2.819/2.851/2.870/0.017        0.563/0.601/0.631/0.022       20,714,938
 3     42.383%      3.713/3.758/3.780/0.020        0.565/0.580/0.592/0.008       20,008,755
 4     41.660%      2.768/2.802/2.818/0.015        0.353/0.372/0.381/0.008       13,111,391
 5     41.216%      3.014/3.031/3.051/0.012        0.365/0.375/0.383/0.005       12,971,746
 6     41.039%      3.505/3.539/3.555/0.014        0.358/0.372/0.384/0.009       12,916,025
 7     40.778%      2.239/2.270/2.284/0.011        0.168/0.175/0.181/0.004        6,416,924
 8     40.704%      2.769/2.800/2.809/0.010        0.168/0.179/0.188/0.007        6,405,244
 9     40.696%      2.983/3.016/3.029/0.013        0.160/0.172/0.180/0.007        6,404,084

 avg1  42.947%                        2.981                          0.424
 tot                                402.450                         57.285      141,567,965

PR #828 edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80 aarch64
   text    data     bss     dec     hex filename
 109130    1624      16  110770   1b0b2 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.767/2.795/2.816/0.016        0.952/0.987/1.005/0.017       42,618,858
 2     43.879%      3.010/3.050/3.069/0.016        0.549/0.592/0.621/0.022       20,714,938
 3     42.383%      3.913/3.958/3.977/0.021        0.543/0.578/0.597/0.017       20,008,755
 4     41.660%      2.937/2.972/2.996/0.018        0.345/0.376/0.385/0.011       13,111,391
 5     41.216%      3.186/3.216/3.240/0.017        0.339/0.365/0.380/0.011       12,971,746
 6     41.039%      3.770/3.796/3.818/0.015        0.344/0.366/0.379/0.009       12,916,025
 7     40.778%      2.641/2.658/2.669/0.010        0.160/0.175/0.185/0.008        6,416,924
 8     40.704%      3.270/3.284/3.293/0.007        0.152/0.175/0.186/0.010        6,405,244
 9     40.409%      3.364/3.389/3.401/0.011        0.168/0.181/0.192/0.009        6,358,951

 avg1  42.915%                        3.235                          0.422
 tot                                436.783                         56.904      141,522,832

Overall 8.5% slower compression
Level 1: 1.1% slower
Level 3: 5.3% slower
Level 6: 7.2% slower
Level 7: 17% slower
Level 8: 17% slower
Level 9: 12.3% slower, 0.7% better compression
Why does this PR have such a big impact on ARM and not on x86..

@Dead2 ARM has a lot more general purpose registers and no separate vector registers. Obviously some types of code benefit from having more registers. If function has a lot of variables with close to maximum number of bits, ARM might still run out of usable registers as all the registers are overlaid on same register bank. There might also be different penalty in using smaller integer types vs. larger integer types.

@mtl1979 Yes, I am also thinking that might be the reason. But what part of the code causes that and can we do something to improve it? That of course requires us to first positively identify the culprit(s).
I am running some (slooooow) profiling to see whether I can narrow it down.

@Dead2 There is so many small changes that might cause the slowdown... After all we did try to optimize code so it works better on all architectures, so we replaced some complex calculations with intrinsics that are basically single CPU instruction.

Preliminary aarch64 perf results:
PR #828 edf52a15e70e2ecb8c5cbf671ebb93c2e6afee80
  Overhead       sys       usr  Command          Symbol
+   39.95%     0.00%    39.95%  minigzip-pr828-  [.] longest_match_unaligned_64
+   24.32%     0.00%    24.32%  minigzip-pr828-  [.] deflate_medium
+   13.97%     0.00%    13.97%  minigzip-pr828-  [.] insert_string_acle
+    7.98%     0.00%     7.98%  minigzip-pr828-  [.] quick_insert_string_acle
+    5.76%     0.00%     5.76%  minigzip-pr828-  [.] compress_block
+    1.67%     0.00%     1.67%  minigzip-pr828-  [.] pqdownheap
+    1.50%     0.00%     1.50%  minigzip-pr828-  [.] slide_hash_neon
     0.39%     0.00%     0.39%  minigzip-pr828-  [.] build_tree
     0.37%     0.00%     0.37%  minigzip-pr828-  [.] crc32_acle
     0.12%     0.00%     0.12%  minigzip-pr828-  [.] send_tree

Baseline
  Overhead       sys       usr  Command          Symbol
+   43.50%     0.00%    43.50%  minigzip-pr828-  [.] longest_match_unaligned_64
+   23.69%     0.00%    23.69%  minigzip-pr828-  [.] deflate_medium
+   13.19%     0.00%    13.19%  minigzip-pr828-  [.] insert_string_acle
+    7.56%     0.00%     7.56%  minigzip-pr828-  [.] quick_insert_string_acle
+    5.63%     0.00%     5.63%  minigzip-pr828-  [.] compress_block
+    1.61%     0.00%     1.61%  minigzip-pr828-  [.] pqdownheap
+    1.45%     0.00%     1.45%  minigzip-pr828-  [.] slide_hash_neon
     0.39%     0.00%     0.39%  minigzip-pr828-  [.] build_tree
     0.36%     0.00%     0.36%  minigzip-pr828-  [.] crc32_acle
     0.12%     0.00%     0.12%  minigzip-pr828-  [.] send_tree

Unsurprisingly, dcdd9bba3ec468e8c91048925ec2f58753267bba is the commit that make all levels slower.
I also updated the above benchmarks with a small patch that decreases the performance impact.

I wonder if we can reorder the if statements to make it faster for the other levels..

Added another patch above, but it does not change performance measurably.

Ah I had not seen that.

Well, longest_match is a template. So we could use that and have a functable.longest_match_slow, so that only those portions of the code is turned on for that.

Currently testing another revision of the above change that might be more accurate, with a little fewer branches for the non-9 levels.

(Baseline from above repeated for easier comparison)
Baseline 834e7d83eae9ff7bfb1b9769d9f311ea7ca8e746 aarch64
   text    data     bss     dec     hex filename
 105194    1576      16  106786   1a122 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.746/2.764/2.780/0.011        0.965/0.993/1.015/0.013       42,618,858
 2     43.879%      2.819/2.851/2.870/0.017        0.563/0.601/0.631/0.022       20,714,938
 3     42.383%      3.713/3.758/3.780/0.020        0.565/0.580/0.592/0.008       20,008,755
 4     41.660%      2.768/2.802/2.818/0.015        0.353/0.372/0.381/0.008       13,111,391
 5     41.216%      3.014/3.031/3.051/0.012        0.365/0.375/0.383/0.005       12,971,746
 6     41.039%      3.505/3.539/3.555/0.014        0.358/0.372/0.384/0.009       12,916,025
 7     40.778%      2.239/2.270/2.284/0.011        0.168/0.175/0.181/0.004        6,416,924
 8     40.704%      2.769/2.800/2.809/0.010        0.168/0.179/0.188/0.007        6,405,244
 9     40.696%      2.983/3.016/3.029/0.013        0.160/0.172/0.180/0.007        6,404,084

 avg1  42.947%                        2.981                          0.424
 tot                                402.450                         57.285      141,567,965

This PR + the patch below
   text    data     bss     dec     hex filename
 109122    1624      16  110762   1b0aa libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.752/2.787/2.802/0.015        0.963/0.984/1.001/0.011       42,618,858
 2     43.879%      2.915/2.950/2.987/0.020        0.544/0.596/0.618/0.021       20,714,938
 3     42.383%      3.810/3.845/3.867/0.017        0.557/0.582/0.599/0.012       20,008,755
 4     41.660%      2.824/2.846/2.865/0.014        0.355/0.376/0.388/0.009       13,111,391
 5     41.216%      3.051/3.080/3.099/0.014        0.343/0.363/0.371/0.008       12,971,746
 6     41.039%      3.576/3.601/3.615/0.011        0.352/0.366/0.381/0.009       12,916,025
 7     40.778%      2.459/2.469/2.477/0.007        0.164/0.175/0.181/0.007        6,416,924
 8     40.704%      2.969/2.991/3.003/0.009        0.156/0.174/0.185/0.010        6,405,244
 9     41.453%      3.601/3.617/3.624/0.007        0.171/0.195/0.210/0.013        6,523,213

 avg1  43.031%                        3.132                          0.423
 tot                                422.782                         57.158      141,687,094

Overall 5% slower compression
Level 1: 0.8% slower
Level 3: 2.3% slower
Level 6: 1.75% slower
Level 7: 8.7% slower
Level 8: 6.8% slower
Level 9: 19.9% slower, 0.7% better compression
Seems to be a lot better for all levels except level 9, but level 9 does take a big hit because its code is no longer in the hot-path.
diff --git a/deflate.c b/deflate.c
index 186ae77b..5280a5c7 100644
--- a/deflate.c
+++ b/deflate.c
@@ -1250,7 +1250,7 @@ void Z_INTERNAL fill_window(deflate_state *s) {
         /* Initialize the hash value now that we have some input: */
         if (s->lookahead + s->insert >= STD_MIN_MATCH) {
             unsigned int str = s->strstart - s->insert;
-            if (s->max_chain_length > 1024) {
+            if (UNLIKELY(s->max_chain_length > 1024)) {
                 s->ins_h = s->update_hash(s, s->window[str], s->window[str+1]);
             } else if (str >= 1) {
                 s->quick_insert_string(s, str + 2 - STD_MIN_MATCH);
diff --git a/match_tpl.h b/match_tpl.h
index 827fd655..bf697f03 100644
--- a/match_tpl.h
+++ b/match_tpl.h
@@ -103,7 +103,8 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
      */
     limit = limit_base = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0;

-    if (best_len >= STD_MIN_MATCH && rolling_hash) {
+    if (UNLIKELY(rolling_hash)) {
+      if (best_len >= STD_MIN_MATCH) {
         /* We're continuing search (lazy evaluation). */
         uint32_t i, hash;
         Pos pos;
@@ -132,6 +133,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
             goto break_matching;
         mbase_start -= match_offset;
         mbase_end -= match_offset;
+      }
     }

     Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
@@ -208,7 +210,8 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
             scan_end0 = *(bestcmp_t *)(scan+offset+1);
 #endif
             /* Look for a better string offset */
-            if (len > STD_MIN_MATCH && match_start + len < strstart && rolling_hash) {
+            if (UNLIKELY(rolling_hash)) {
+              if (len > STD_MIN_MATCH && match_start + len < strstart) {
                 Pos pos, next_pos;
                 uint32_t i, hash;
                 unsigned char *scan_endstr;
@@ -254,6 +257,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
                 mbase_start = window-match_offset;
                 mbase_end = (mbase_start+offset);
                 continue;
+              }
             } else {
                 mbase_end = (mbase_start+offset);
             }

I think in that last patch it should have another  else { mbase_end = (mbase_start+offset); } if len > STD_MIN_MATCH && match_start + len < strstart == false.
Anyways, do you think we should go this route or use a new functable function?

@nmoinvaz Right you are, one is missing. I was wondering where to put it (inside or out), never considered it should go both places 😄
But yes, I think it is definitely worth at least making a test with two different versions of longest_match. It will increase code-size, but it should have much less impact on performance. At least the Slow version would no longer need to check for early_exit, so that might actually make the slow version slightly less painful.
 A define selecting Default/All/None perhaps. Just a thought.
Another thought I had regarding level switches during mid-stream, would it be possible to then clear out the old non-chained hashes and re-do what is in the history buffer with the new chained hashes (and the other way around)? Not really needed for this PR, but unless I am missing something, that would avoid a drop in compression efficiency after level switches (or chain length tweaks if someone does that mid-stream).

Rebased.

Fixed wording in comment and updated author email in commits.

@Dead2, I think if we added longest_match to the config_s it might work. It would have to be set to either longest_match_stub or longest_match_slow_stub. Then when compression level changes, it can set s->longest_match, in which case that would be used for the deflate algorithm function.

We also may be able to make the early_exit stuff a config option too.

ZLIB-NG https://github.com/zlib-ng/zlib-ng/commit/21050e06c511a67f3239d1bca444616be6853bfe
 Tool: minigzip-ng-develop.exe Levels: 1-9
 Level 1-9: C:\Users\Nathan\Source\deflatebench\silesia.tar  202.1 MiB   211,957,760 B
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.409%      0.973/0.989/0.999/0.006        0.613/0.622/0.628/0.004       94,127,290
 2     35.518%      1.590/1.609/1.620/0.009        0.627/0.637/0.642/0.004       75,282,961
 3     33.882%      2.192/2.209/2.235/0.012        0.609/0.617/0.624/0.005       71,816,478
 4     33.174%      2.427/2.454/2.474/0.013        0.598/0.606/0.611/0.004       70,315,668
 5     32.660%      2.573/2.597/2.611/0.009        0.592/0.605/0.609/0.004       69,225,542
 6     32.508%      3.005/3.031/3.048/0.010        0.592/0.603/0.610/0.005       68,902,222
 7     32.255%      3.983/4.005/4.021/0.011        0.590/0.601/0.605/0.004       68,366,800
 8     32.167%      6.189/6.216/6.235/0.013        0.594/0.599/0.604/0.003       68,180,776
 9     32.156%      8.577/8.645/8.668/0.019        0.590/0.601/0.606/0.004       68,156,160

 avg1  34.303%                        3.528                          0.610
 tot                                952.695                        164.737      654,373,897

ZLIB-NG https://github.com/zlib-ng/zlib-ng/pull/828/commits/3296080e954d86159b03ac3dcd48050acb68f164
 Tool: minigzip-ng-fast-zlib.exe Levels: 1-9
 Level 1-9: C:\Users\Nathan\Source\deflatebench\silesia.tar  202.1 MiB   211,957,760 B
 Runs: 70         Trim worst: 40

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.409%      0.974/0.984/0.991/0.005        0.622/0.632/0.638/0.005       94,127,290
 2     35.518%      1.614/1.641/1.657/0.011        0.635/0.652/0.659/0.006       75,282,961
 3     33.882%      2.197/2.230/2.248/0.012        0.621/0.630/0.637/0.005       71,816,478
 4     33.174%      2.462/2.479/2.493/0.007        0.616/0.624/0.629/0.003       70,315,668
 5     32.660%      2.587/2.610/2.634/0.013        0.611/0.623/0.628/0.005       69,225,542
 6     32.508%      3.002/3.032/3.042/0.009        0.615/0.629/0.635/0.006       68,902,222
 7     32.255%      4.123/4.153/4.178/0.015        0.607/0.614/0.619/0.004       68,366,800
 8     32.167%      6.317/6.363/6.394/0.020        0.603/0.612/0.618/0.004       68,180,776
 9     31.887%      6.573/6.643/6.677/0.023        0.603/0.610/0.615/0.003       67,586,442

 avg1  34.273%                        3.348                          0.625
 tot                                904.046                        168.751      653,804,179

Regarding config_s, is that handled correctly when it comes to applications being able to save the state and resume later? If I remember correctly, it should be able to handle that the deflate state is loaded into a different process than the one used originally.

I think maybe you forgot to reorder the if statements with rolling_hash as the first check, that would skip the block earlier for non-level9 and only do the extra checks on level9.

Baseline 21050e06c511a67f3239d1bca444616be6853bfe x86-64
   text    data     bss     dec     hex filename
 115241    1416      32  116689   1c7d1 libz-ng.so.2

Activated multiple generated file mode. Source: ../silesia-small.tar
Level 1: /tmp/deflatebench-1.tmp  465.2 MiB   487,825,920 B
Level 2: /tmp/deflatebench-2.tmp  270.1 MiB   283,253,760 B
Level 3: /tmp/deflatebench-3.tmp  225.1 MiB   236,044,800 B
Level 4: /tmp/deflatebench-4.tmp  180.1 MiB   188,835,840 B
Level 5: /tmp/deflatebench-5.tmp  165.1 MiB   173,099,520 B
Level 6: /tmp/deflatebench-6.tmp  135.1 MiB   141,626,880 B
Level 7: /tmp/deflatebench-7.tmp  105.1 MiB   110,154,240 B
Level 8: /tmp/deflatebench-8.tmp   90.0 MiB    94,417,920 B
Level 9: /tmp/deflatebench-9.tmp   75.0 MiB    78,681,600 B

 Tool: minigzip   Levels: 1-9
 Runs: 40         Trim worst: 20

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.165%      2.892/2.928/2.946/0.017        1.661/1.669/1.678/0.005      264,231,515
 2     43.875%      2.974/3.002/3.015/0.010        0.984/1.002/1.017/0.010      124,277,644
 3     42.382%      3.003/3.018/3.032/0.009        0.786/0.812/0.825/0.011      100,039,412
 4     41.669%      2.718/2.737/2.743/0.007        0.622/0.634/0.645/0.006       78,685,354
 5     41.215%      2.868/2.911/2.926/0.016        0.568/0.578/0.585/0.006       71,342,944
 6     41.036%      2.763/2.776/2.785/0.007        0.441/0.469/0.478/0.009       58,118,026
 7     40.781%      2.717/2.735/2.742/0.007        0.358/0.367/0.371/0.004       44,921,649
 8     40.702%      2.996/3.009/3.017/0.007        0.297/0.313/0.321/0.007       38,429,965
 9     40.698%      2.783/2.795/2.801/0.005        0.247/0.259/0.266/0.006       32,021,745

 avg1  42.947%                        2.879                          0.678
 tot                                518.191                        122.066      812,068,254

PR #828 3296080e954d86159b03ac3dcd48050acb68f164 x86-64
   text    data     bss     dec     hex filename
 126257    1432      32  127721   1f2e9 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.165%      2.942/2.964/2.976/0.009        1.640/1.669/1.683/0.011      264,231,515
 2     43.875%      2.970/2.989/2.998/0.008        0.991/1.005/1.013/0.006      124,277,644
 3     42.382%      2.958/2.981/2.992/0.010        0.801/0.813/0.823/0.006      100,039,412
 4     41.669%      2.693/2.712/2.721/0.009        0.620/0.634/0.644/0.009       78,685,354
 5     41.215%      2.887/2.905/2.919/0.009        0.560/0.575/0.583/0.007       71,342,944
 6     41.036%      2.720/2.752/2.760/0.010        0.460/0.472/0.480/0.006       58,118,026
 7     40.781%      2.793/2.807/2.815/0.006        0.357/0.369/0.374/0.005       44,921,649
 8     40.702%      3.054/3.069/3.078/0.007        0.290/0.312/0.320/0.008       38,429,965
 9     40.421%      3.000/3.016/3.023/0.007        0.248/0.258/0.265/0.005       31,804,100

 avg1  42.916%                        2.910                          0.679
 tot                                523.889                        122.160      811,850,609

Overall 1% slower compression
Level 1: 1.2% slower
Level 3: 1.1% faster
Level 6: 0.8% faster
Level 7: 2.6% slower
Level 8: 2% slower
Level 9: 7.9% slower, 0.68% smaller compressed size

Baseline 21050e06c511a67f3239d1bca444616be6853bfe aarch64
   text    data     bss     dec     hex filename
 105234    1576      16  106826   1a14a libz-ng.so.2

Level 1: /tmp/deflatebench-1.tmp   75.0 MiB    78,681,600 B
Level 2: /tmp/deflatebench-2.tmp   45.0 MiB    47,208,960 B
Level 3: /tmp/deflatebench-3.tmp   45.0 MiB    47,208,960 B
Level 4: /tmp/deflatebench-4.tmp   30.0 MiB    31,472,640 B
Level 5: /tmp/deflatebench-5.tmp   30.0 MiB    31,472,640 B
Level 6: /tmp/deflatebench-6.tmp   30.0 MiB    31,472,640 B
Level 7: /tmp/deflatebench-7.tmp   15.0 MiB    15,736,320 B
Level 8: /tmp/deflatebench-8.tmp   15.0 MiB    15,736,320 B
Level 9: /tmp/deflatebench-9.tmp   15.0 MiB    15,736,320 B

 Tool: minigzip   Levels: 1-9
 Runs: 40         Trim worst: 20

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.729/2.769/2.790/0.019        0.974/0.998/1.014/0.014       42,618,858
 2     43.879%      2.821/2.856/2.872/0.012        0.583/0.601/0.613/0.009       20,714,938
 3     42.383%      3.722/3.745/3.766/0.016        0.568/0.588/0.600/0.010       20,008,755
 4     41.660%      2.782/2.802/2.818/0.011        0.350/0.376/0.390/0.012       13,111,391
 5     41.216%      3.001/3.035/3.052/0.014        0.339/0.371/0.388/0.013       12,971,746
 6     41.039%      3.511/3.541/3.555/0.013        0.345/0.369/0.379/0.010       12,916,025
 7     40.778%      2.260/2.273/2.286/0.009        0.170/0.181/0.187/0.004        6,416,924
 8     40.704%      2.785/2.805/2.817/0.010        0.149/0.177/0.191/0.011        6,405,244
 9     40.696%      2.997/3.021/3.034/0.009        0.165/0.180/0.190/0.008        6,404,084

 avg1  42.947%                        2.983                          0.427
 tot                                536.961                         76.853      141,567,965

PR #828 3296080e954d86159b03ac3dcd48050acb68f164 aarch64
   text    data     bss     dec     hex filename
 112394    1640      16  114050   1bd82 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.750/2.804/2.830/0.021        0.959/1.003/1.019/0.018       42,618,858
 2     43.879%      2.792/2.827/2.860/0.021        0.574/0.601/0.616/0.012       20,714,938
 3     42.383%      3.703/3.725/3.740/0.012        0.563/0.583/0.599/0.011       20,008,755
 4     41.660%      2.754/2.780/2.798/0.013        0.353/0.375/0.387/0.010       13,111,391
 5     41.216%      2.980/3.017/3.036/0.014        0.340/0.363/0.375/0.011       12,971,746
 6     41.039%      3.491/3.518/3.533/0.012        0.335/0.367/0.381/0.012       12,916,025
 7     40.778%      2.473/2.486/2.494/0.007        0.149/0.175/0.183/0.008        6,416,924
 8     40.704%      2.982/3.011/3.025/0.012        0.164/0.178/0.186/0.006        6,405,244
 9     40.409%      3.191/3.221/3.230/0.009        0.171/0.190/0.202/0.009        6,358,951

 avg1  42.915%                        3.043                          0.426
 tot                                547.750                         76.702      141,522,832

Overall 2% slower compression
Level 1: 1.2% slower
Level 3: 0.5% faster
Level 6: 0.65% faster
Level 7: 9.3% slower
Level 8: 7.3% slower
Level 9: 6.6% slower, 0.7% better compression

Interesting that all deflate_fast and deflate_medium levels are showing a consistent speed improvement now on both aarch64 and x86-64. I would have dismissed it as a fluke if it wasn't so consistent for not only all the levels for both algos but also on two architectures (and also two different gcc versions (8.3.0 vs 4.8.5), not so sure now..
Deflate_slow is still taking a big speed hit on aarch64, that is not so great.
I am unable to reproduce @nmoinvaz incredible speedup in level 9 on x86_64, not sure what happened there? What compiler and cpu are you on, perhaps one of those now sees an opportunity for optimization on the new code.

I think it more so has to do with the data. I see a big increase with the silestia.tar which is what I'm using but with other data not so much.

The speed increase might be easy to explain. I got rid of a else statement in longest_match that I think helped the compiler.

Testing another minor patch
diff --git a/deflate_slow.c b/deflate_slow.c
index 19bd09fb..0c6dd249 100644
--- a/deflate_slow.c
+++ b/deflate_slow.c
@@ -55,7 +55,10 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
              * of window index 0 (in particular we have to avoid a match
              * of the string with itself at the start of the input file).
              */
-            match_len = functable.longest_match_slow(s, hash_head);
+            if (UNLIKELY(s->max_chain_length > 1024))
+                match_len = functable.longest_match_slow(s, hash_head);
+            else
+                match_len = functable.longest_match(s, hash_head);
             /* longest_match() sets match_start */

             if (match_len <= 5 && (s->strategy == Z_FILTERED)) {
diff --git a/match_tpl.h b/match_tpl.h
index e79cad19..dff1ecc9 100644
--- a/match_tpl.h
+++ b/match_tpl.h
@@ -109,7 +109,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
      */
     limit = limit_base = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0;
 #ifdef LONGEST_MATCH_SLOW
-    if (UNLIKELY(best_len >= STD_MIN_MATCH && rolling_hash)) {
+    if (best_len >= STD_MIN_MATCH) {
         /* We're continuing search (lazy evaluation). */
         uint32_t i, hash;
         Pos pos;
@@ -215,7 +215,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
 #endif
 #ifdef LONGEST_MATCH_SLOW
             /* Look for a better string offset */
-            if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart && rolling_hash)) {
+            if (len > STD_MIN_MATCH && match_start + len < strstart) {
                 Pos pos, next_pos;
                 uint32_t i, hash;
                 unsigned char *scan_endstr;

Still running benchmarks, but it looks like levels 7 and 8 gain back some of the speed. Code size is a bit reduced as well.

@Dead2 in your last minor patch we can use a longest_match callback typedef and do that check only once at the top of the deflate function.

@nmoinvaz The benchmarks showed that level9 got a lot slower, and after some checking it turns out that the UNLIKELY at line 218 should stay unlikely. But the one at line 112 should still go away in this case (I'll edit the above patch just to avoid confusion and try to reduce the churn in here).
The numbers are looking good so far, so I am looking forward to seeing the results in some minutes.

Benchmark results for the patch 3 comments above ^
PR #828 Patched x86-64 Rev3
   text    data     bss     dec     hex filename
 125841    1432      32  127305   1f149 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.165%      2.909/2.933/2.954/0.013        1.646/1.670/1.683/0.012      264,231,515
 2     43.875%      2.939/2.969/2.986/0.014        0.988/1.008/1.020/0.009      124,277,644
 3     42.382%      2.951/2.964/2.975/0.007        0.795/0.816/0.828/0.010      100,039,412
 4     41.669%      2.704/2.721/2.733/0.008        0.615/0.633/0.645/0.009       78,685,354
 5     41.215%      2.834/2.867/2.883/0.013        0.561/0.578/0.587/0.007       71,342,944
 6     41.036%      2.743/2.759/2.771/0.007        0.448/0.467/0.477/0.007       58,118,026
 7     40.781%      2.726/2.744/2.753/0.007        0.355/0.366/0.372/0.006       44,921,649
 8     40.702%      3.003/3.016/3.023/0.006        0.300/0.313/0.320/0.006       38,429,965
 9     40.421%      2.968/2.984/2.990/0.005        0.245/0.258/0.265/0.007       31,804,100

 avg1  42.916%                        2.884                          0.679
 tot                                519.146                        122.207      811,850,609

Compared to    baseline    3296080e(pr282)
Overall        -0.2%        0.9%
Level 1:       -0.2%        1.1%
Level 3:        1.8%        0.6%
Level 6:        0.7%       -0.3%
Level 7:       -0.3%        2.2%
Level 8:       -0.2%        1.7%
Level 9:       -6.7%        1.1%
(Negative means slower, positive is faster)

PR #828 Patched aarch64 Rev3
   text    data     bss     dec     hex filename
 112282    1640      16  113938   1bd12 libz-ng.so.2

 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     54.166%      2.767/2.793/2.812/0.016        0.964/1.004/1.022/0.016       42,618,858
 2     43.879%      2.781/2.832/2.857/0.022        0.567/0.601/0.620/0.017       20,714,938
 3     42.383%      3.681/3.724/3.748/0.017        0.563/0.577/0.588/0.008       20,008,755
 4     41.660%      2.730/2.775/2.794/0.016        0.355/0.380/0.391/0.010       13,111,391
 5     41.216%      2.999/3.019/3.037/0.010        0.356/0.370/0.380/0.007       12,971,746
 6     41.039%      3.486/3.518/3.540/0.015        0.356/0.369/0.377/0.005       12,916,025
 7     40.778%      2.392/2.419/2.431/0.010        0.164/0.180/0.189/0.007        6,416,924
 8     40.704%      2.935/2.949/2.964/0.010        0.156/0.175/0.186/0.009        6,405,244
 9     40.409%      3.337/3.366/3.381/0.013        0.172/0.190/0.200/0.008        6,358,951

 avg1  42.915%                        3.044                          0.427
 tot                                547.900                         76.921      141,522,832

 Compared to    baseline    3296080e(pr282)
Overall        -2.0%       -0.0%
Level 1:       -0.9%        0.4%
Level 3:        0.6%        0.0%
Level 6:        0.6%        0.0%
Level 7:       -6.4%        2.7%
Level 8:       -5.1%        3.1%
Level 9:      -11.4%       -4.5%
(Negative means slower, positive is faster)

As we can see above, the patched version compared quite favorably.
For aarch64 all levels except level 9 becomes faster, with levels 7 and 8 gaining the most.
For x86-64 it shows an improvement for all deflate_slow levels, nearly negating the performance penalty entirely for levels 8 and 9.
In both cases the code size shows a sizeable drop compared to current pr828.

@Dead2 are you able to do a test against silestia.tar? To at least see if you get benefit on that type of data.

@nmoinvaz This was silesia-small.tar, but I can run a shorter test with the full silesia.tar

Baseline silesia.tar x86-64
 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.409%      1.167/1.187/1.197/0.009        0.715/0.745/0.756/0.012       94,127,290
 2     35.518%      2.072/2.087/2.096/0.006        0.754/0.769/0.784/0.009       75,282,961
 3     33.882%      2.560/2.592/2.603/0.013        0.729/0.744/0.753/0.009       71,816,478
 4     33.174%      2.933/2.954/2.967/0.011        0.704/0.722/0.733/0.009       70,315,668
 5     32.660%      3.354/3.394/3.404/0.013        0.704/0.720/0.731/0.008       69,225,542
 6     32.508%      3.938/4.000/4.024/0.022        0.690/0.717/0.724/0.009       68,902,222
 7     32.255%      5.329/5.382/5.394/0.017        0.704/0.716/0.723/0.006       68,366,800
 8     32.167%      8.593/8.620/8.633/0.011        0.690/0.716/0.723/0.008       68,180,776
 9     32.156%   12.278/12.335/12.351/0.019        0.692/0.713/0.723/0.009       68,156,160

 avg1  34.303%                        4.728                          0.729
 tot                                638.274                         98.450      654,373,897

PR828 silesia.tar x86-64
 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.409%      1.180/1.195/1.203/0.007        0.722/0.739/0.748/0.009       94,127,290
 2     35.518%      2.047/2.076/2.088/0.010        0.744/0.762/0.778/0.011       75,282,961
 3     33.882%      2.531/2.545/2.557/0.010        0.725/0.739/0.745/0.007       71,816,478
 4     33.174%      2.884/2.917/2.937/0.018        0.692/0.725/0.733/0.011       70,315,668
 5     32.660%      3.337/3.358/3.365/0.008        0.692/0.719/0.731/0.015       69,225,542
 6     32.508%      3.937/3.969/3.982/0.014        0.690/0.713/0.725/0.011       68,902,222
 7     32.255%      5.478/5.501/5.516/0.011        0.705/0.715/0.725/0.006       68,366,800
 8     32.167%      8.724/8.774/8.789/0.016        0.692/0.713/0.725/0.011       68,180,776
 9     31.887%      9.234/9.254/9.265/0.009        0.707/0.713/0.720/0.005       67,586,442

 avg1  34.273%                        4.399                          0.727
 tot                                593.846                         98.099      653,804,179

Patched silesia.tar x86-64
 Level   Comp   Comptime min/avg/max/stddev  Decomptime min/avg/max/stddev  Compressed size
 1     44.409%      1.170/1.193/1.202/0.011        0.709/0.738/0.756/0.014       94,127,290
 2     35.518%      2.063/2.077/2.088/0.007        0.754/0.768/0.780/0.008       75,282,961
 3     33.882%      2.520/2.552/2.567/0.014        0.712/0.738/0.749/0.011       71,816,478
 4     33.174%      2.860/2.897/2.908/0.013        0.701/0.727/0.739/0.011       70,315,668
 5     32.660%      3.331/3.364/3.377/0.013        0.682/0.712/0.724/0.011       69,225,542
 6     32.508%      3.920/3.945/3.965/0.015        0.686/0.715/0.727/0.010       68,902,222
 7     32.255%      5.375/5.395/5.408/0.011        0.703/0.714/0.720/0.005       68,366,800
 8     32.167%      8.576/8.599/8.615/0.013        0.695/0.715/0.726/0.008       68,180,776
 9     31.887%      9.114/9.133/9.153/0.015        0.695/0.704/0.711/0.005       67,586,442

 avg1  34.273%                        4.350                          0.726
 tot                                587.314                         97.954      653,804,179

This is good so you are seeing the same benefits on this type of data.

Did the same test on aarch64 for completeness:
Baseline silesia.tar aarch64