mirror of
https://github.com/golang/go
synced 2024-11-17 12:44:49 -07:00
compress/flate: remove compressor.hash field
After CL 20929, the only remaining uses of d.hash are immediately after it is set. Benchmarks where benchstat reports a non-zero delta: name old time/op new time/op delta Decode/Newton/Huffman/1e5-12 982µs ± 6% 922µs ± 4% -6.12% (p=0.000 n=10+10) Decode/Newton/Huffman/1e6-12 8.14ms ± 2% 7.71ms ± 2% -5.19% (p=0.000 n=10+10) Encode/Digits/Huffman/1e5-12 241µs ± 0% 239µs ± 0% -0.62% (p=0.000 n=9+10) Encode/Digits/Speed/1e4-12 113µs ± 0% 114µs ± 0% +1.21% (p=0.000 n=9+8) Encode/Digits/Speed/1e5-12 1.04ms ± 0% 1.05ms ± 0% +0.22% (p=0.027 n=9+8) Encode/Digits/Speed/1e6-12 10.3ms ± 0% 10.3ms ± 0% +0.16% (p=0.036 n=9+8) Encode/Digits/Default/1e4-12 193µs ± 0% 195µs ± 1% +0.77% (p=0.010 n=8+8) Encode/Digits/Default/1e5-12 2.92ms ± 1% 2.93ms ± 0% +0.54% (p=0.002 n=8+8) Encode/Digits/Compression/1e4-12 193µs ± 0% 194µs ± 0% +0.67% (p=0.000 n=8+8) Encode/Digits/Compression/1e5-12 2.92ms ± 0% 2.93ms ± 0% +0.53% (p=0.002 n=8+8) Encode/Digits/Compression/1e6-12 31.0ms ± 1% 31.2ms ± 0% +0.80% (p=0.000 n=10+9) Encode/Newton/Huffman/1e4-12 34.8µs ± 1% 34.3µs ± 0% -1.31% (p=0.000 n=9+10) Encode/Newton/Huffman/1e5-12 294µs ± 0% 291µs ± 0% -1.09% (p=0.000 n=8+9) Encode/Newton/Huffman/1e6-12 2.91ms ± 0% 2.89ms ± 0% -0.89% (p=0.000 n=8+9) Encode/Newton/Speed/1e5-12 838µs ± 0% 836µs ± 0% -0.18% (p=0.015 n=8+8) Encode/Newton/Speed/1e6-12 8.35ms ± 0% 8.28ms ± 1% -0.89% (p=0.000 n=8+10) Encode/Newton/Default/1e5-12 3.55ms ± 0% 3.54ms ± 0% -0.23% (p=0.027 n=8+9) Encode/Newton/Default/1e6-12 37.4ms ± 0% 37.3ms ± 0% -0.18% (p=0.001 n=9+8) Encode/Newton/Compression/1e6-12 53.3ms ± 0% 53.1ms ± 0% -0.25% (p=0.010 n=10+9) name old speed new speed delta Decode/Newton/Huffman/1e5-12 102MB/s ± 6% 109MB/s ± 4% +6.48% (p=0.000 n=10+10) Decode/Newton/Huffman/1e6-12 123MB/s ± 2% 130MB/s ± 2% +5.49% (p=0.000 n=10+10) Encode/Digits/Huffman/1e5-12 416MB/s ± 0% 418MB/s ± 0% +0.62% (p=0.000 n=9+10) Encode/Digits/Speed/1e4-12 88.9MB/s ± 0% 87.8MB/s ± 0% -1.19% (p=0.000 n=9+8) Encode/Digits/Speed/1e5-12 95.7MB/s ± 0% 95.5MB/s ± 0% -0.22% (p=0.025 n=9+8) Encode/Digits/Speed/1e6-12 97.5MB/s ± 0% 97.3MB/s ± 0% -0.16% (p=0.026 n=9+8) Encode/Digits/Default/1e4-12 51.7MB/s ± 0% 51.3MB/s ± 1% -0.76% (p=0.007 n=8+8) Encode/Digits/Default/1e5-12 34.3MB/s ± 1% 34.1MB/s ± 0% -0.54% (p=0.001 n=8+8) Encode/Digits/Compression/1e4-12 51.8MB/s ± 0% 51.5MB/s ± 0% -0.66% (p=0.000 n=8+8) Encode/Digits/Compression/1e5-12 34.3MB/s ± 0% 34.1MB/s ± 0% -0.53% (p=0.002 n=8+8) Encode/Digits/Compression/1e6-12 32.3MB/s ± 1% 32.0MB/s ± 0% -0.79% (p=0.000 n=10+9) Encode/Newton/Huffman/1e4-12 288MB/s ± 1% 291MB/s ± 0% +1.33% (p=0.000 n=9+10) Encode/Newton/Huffman/1e5-12 340MB/s ± 0% 344MB/s ± 0% +1.10% (p=0.000 n=8+9) Encode/Newton/Huffman/1e6-12 343MB/s ± 0% 346MB/s ± 0% +0.90% (p=0.000 n=8+9) Encode/Newton/Speed/1e5-12 119MB/s ± 0% 120MB/s ± 0% +0.18% (p=0.014 n=8+8) Encode/Newton/Speed/1e6-12 120MB/s ± 0% 121MB/s ± 1% +0.90% (p=0.000 n=8+10) Encode/Newton/Default/1e5-12 28.2MB/s ± 0% 28.3MB/s ± 0% +0.23% (p=0.029 n=8+9) Encode/Newton/Default/1e6-12 26.7MB/s ± 0% 26.8MB/s ± 0% +0.20% (p=0.000 n=9+7) Encode/Newton/Compression/1e6-12 18.8MB/s ± 0% 18.8MB/s ± 0% +0.25% (p=0.012 n=10+9) Change-Id: I8ba0efcf5d42595d856082656b45f87bb3d7be0f Reviewed-on: https://go-review.googlesource.com/c/go/+/404696 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
de9805c702
commit
949b3e9880
@ -113,7 +113,6 @@ type compressor struct {
|
|||||||
// deflate state
|
// deflate state
|
||||||
length int
|
length int
|
||||||
offset int
|
offset int
|
||||||
hash uint32
|
|
||||||
maxInsertIndex int
|
maxInsertIndex int
|
||||||
err error
|
err error
|
||||||
|
|
||||||
@ -222,7 +221,6 @@ func (d *compressor) fillWindow(b []byte) {
|
|||||||
// Set the head of the hash chain to us.
|
// Set the head of the hash chain to us.
|
||||||
*hh = uint32(di + d.hashOffset)
|
*hh = uint32(di + d.hashOffset)
|
||||||
}
|
}
|
||||||
d.hash = newH
|
|
||||||
}
|
}
|
||||||
// Update window information.
|
// Update window information.
|
||||||
d.windowEnd = n
|
d.windowEnd = n
|
||||||
@ -377,7 +375,6 @@ func (d *compressor) initDeflate() {
|
|||||||
d.offset = 0
|
d.offset = 0
|
||||||
d.byteAvailable = false
|
d.byteAvailable = false
|
||||||
d.index = 0
|
d.index = 0
|
||||||
d.hash = 0
|
|
||||||
d.chainHead = -1
|
d.chainHead = -1
|
||||||
d.bulkHasher = bulkHash4
|
d.bulkHasher = bulkHash4
|
||||||
}
|
}
|
||||||
@ -388,9 +385,6 @@ func (d *compressor) deflate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.maxInsertIndex = d.windowEnd - (minMatchLength - 1)
|
d.maxInsertIndex = d.windowEnd - (minMatchLength - 1)
|
||||||
if d.index < d.maxInsertIndex {
|
|
||||||
d.hash = hash4(d.window[d.index : d.index+minMatchLength])
|
|
||||||
}
|
|
||||||
|
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
@ -423,8 +417,8 @@ Loop:
|
|||||||
}
|
}
|
||||||
if d.index < d.maxInsertIndex {
|
if d.index < d.maxInsertIndex {
|
||||||
// Update the hash
|
// Update the hash
|
||||||
d.hash = hash4(d.window[d.index : d.index+minMatchLength])
|
hash := hash4(d.window[d.index : d.index+minMatchLength])
|
||||||
hh := &d.hashHead[d.hash&hashMask]
|
hh := &d.hashHead[hash&hashMask]
|
||||||
d.chainHead = int(*hh)
|
d.chainHead = int(*hh)
|
||||||
d.hashPrev[d.index&windowMask] = uint32(d.chainHead)
|
d.hashPrev[d.index&windowMask] = uint32(d.chainHead)
|
||||||
*hh = uint32(d.index + d.hashOffset)
|
*hh = uint32(d.index + d.hashOffset)
|
||||||
@ -469,10 +463,10 @@ Loop:
|
|||||||
index := d.index
|
index := d.index
|
||||||
for index++; index < newIndex; index++ {
|
for index++; index < newIndex; index++ {
|
||||||
if index < d.maxInsertIndex {
|
if index < d.maxInsertIndex {
|
||||||
d.hash = hash4(d.window[index : index+minMatchLength])
|
hash := hash4(d.window[index : index+minMatchLength])
|
||||||
// Get previous value with the same hash.
|
// Get previous value with the same hash.
|
||||||
// Our chain should point to the previous value.
|
// Our chain should point to the previous value.
|
||||||
hh := &d.hashHead[d.hash&hashMask]
|
hh := &d.hashHead[hash&hashMask]
|
||||||
d.hashPrev[index&windowMask] = *hh
|
d.hashPrev[index&windowMask] = *hh
|
||||||
// Set the head of the hash chain to us.
|
// Set the head of the hash chain to us.
|
||||||
*hh = uint32(index + d.hashOffset)
|
*hh = uint32(index + d.hashOffset)
|
||||||
@ -488,9 +482,6 @@ Loop:
|
|||||||
// For matches this long, we don't bother inserting each individual
|
// For matches this long, we don't bother inserting each individual
|
||||||
// item into the table.
|
// item into the table.
|
||||||
d.index += d.length
|
d.index += d.length
|
||||||
if d.index < d.maxInsertIndex {
|
|
||||||
d.hash = hash4(d.window[d.index : d.index+minMatchLength])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if len(d.tokens) == maxFlateBlockTokens {
|
if len(d.tokens) == maxFlateBlockTokens {
|
||||||
// The block includes the current character
|
// The block includes the current character
|
||||||
@ -634,7 +625,6 @@ func (d *compressor) reset(w io.Writer) {
|
|||||||
d.tokens = d.tokens[:0]
|
d.tokens = d.tokens[:0]
|
||||||
d.length = minMatchLength - 1
|
d.length = minMatchLength - 1
|
||||||
d.offset = 0
|
d.offset = 0
|
||||||
d.hash = 0
|
|
||||||
d.maxInsertIndex = 0
|
d.maxInsertIndex = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user