Skip to content

Commit

Permalink
zstd: Increase speed on incompressible data for best
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
klauspost committed Feb 5, 2021
1 parent bf241f6 commit e10ac60
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions zstd/enc_best.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (e *bestFastEncoder) Encode(blk *blockEnc, src []byte) {
// Override src
src = e.hist
sLimit := int32(len(src)) - inputMargin
const kSearchStrength = 12
const kSearchStrength = 10

// nextEmit is where in src the next emitLiteral should start from.
nextEmit := s
Expand Down Expand Up @@ -186,9 +186,11 @@ encodeLoop:
best = bestOf(best, matchAt(s-offset1+1, s+1, uint32(cv>>8), 1))
best = bestOf(best, matchAt(s-offset2+1, s+1, uint32(cv>>8), 2))
best = bestOf(best, matchAt(s-offset3+1, s+1, uint32(cv>>8), 3))
best = bestOf(best, matchAt(s-offset1+3, s+3, uint32(cv>>24), 1))
best = bestOf(best, matchAt(s-offset2+3, s+3, uint32(cv>>24), 2))
best = bestOf(best, matchAt(s-offset3+3, s+3, uint32(cv>>24), 3))
if best.length > 0 {
best = bestOf(best, matchAt(s-offset1+3, s+3, uint32(cv>>24), 1))
best = bestOf(best, matchAt(s-offset2+3, s+3, uint32(cv>>24), 2))
best = bestOf(best, matchAt(s-offset3+3, s+3, uint32(cv>>24), 3))
}
}
// Load next and check...
e.longTable[nextHashL] = prevEntry{offset: s + e.cur, prev: candidateL.offset}
Expand Down

0 comments on commit e10ac60

Please sign in to comment.