Skip to content

Commit e10ac60

Browse files
committed
zstd: Increase speed on incompressible data for best
Increase speed of incompressible data for "best" mode. Should not have any impact on compressible data: before/after... ``` sharnd.out.2gb zskp 4 2147483647 2147581961 52931 38.69 sharnd.out.2gb zskp 4 2147483647 2147581961 15426 132.76 silesia.tar zskp 4 211947520 61381950 8394 24.08 silesia.tar zskp 4 211947520 61327981 8142 24.82 ```
1 parent bf241f6 commit e10ac60

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

zstd/enc_best.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (e *bestFastEncoder) Encode(blk *blockEnc, src []byte) {
112112
// Override src
113113
src = e.hist
114114
sLimit := int32(len(src)) - inputMargin
115-
const kSearchStrength = 12
115+
const kSearchStrength = 10
116116

117117
// nextEmit is where in src the next emitLiteral should start from.
118118
nextEmit := s
@@ -186,9 +186,11 @@ encodeLoop:
186186
best = bestOf(best, matchAt(s-offset1+1, s+1, uint32(cv>>8), 1))
187187
best = bestOf(best, matchAt(s-offset2+1, s+1, uint32(cv>>8), 2))
188188
best = bestOf(best, matchAt(s-offset3+1, s+1, uint32(cv>>8), 3))
189-
best = bestOf(best, matchAt(s-offset1+3, s+3, uint32(cv>>24), 1))
190-
best = bestOf(best, matchAt(s-offset2+3, s+3, uint32(cv>>24), 2))
191-
best = bestOf(best, matchAt(s-offset3+3, s+3, uint32(cv>>24), 3))
189+
if best.length > 0 {
190+
best = bestOf(best, matchAt(s-offset1+3, s+3, uint32(cv>>24), 1))
191+
best = bestOf(best, matchAt(s-offset2+3, s+3, uint32(cv>>24), 2))
192+
best = bestOf(best, matchAt(s-offset3+3, s+3, uint32(cv>>24), 3))
193+
}
192194
}
193195
// Load next and check...
194196
e.longTable[nextHashL] = prevEntry{offset: s + e.cur, prev: candidateL.offset}

0 commit comments

Comments
 (0)