Load more dictionary positions into table if empty
If the hash table is empty load positions into the hash table that we would otherwise skip. | Level | Data Set | Improvement | |-------|--------------|-------------| | 1 | github | 0.44% | | 1 | hg-changelog | 0.13% | | 1 | hg-commands | 1.28% | | 1 | hg-manifest | 0.70% | | 3 | github | 0.74% | | 3 | hg-changelog | 0.87% | | 3 | hg-commands | 1.74% | | 3 | hg-manifest | 0.23% |dev
parent
04c00f9388
commit
9a211d1f05
|
@ -21,12 +21,23 @@ void ZSTD_fillDoubleHashTable(ZSTD_CCtx* cctx, const void* end, const U32 mls)
|
||||||
const BYTE* const base = cctx->base;
|
const BYTE* const base = cctx->base;
|
||||||
const BYTE* ip = base + cctx->nextToUpdate;
|
const BYTE* ip = base + cctx->nextToUpdate;
|
||||||
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
||||||
const size_t fastHashFillStep = 3;
|
const U32 fastHashFillStep = 3;
|
||||||
|
|
||||||
while(ip <= iend) {
|
/* Always insert every fastHashFillStep position into the hash tables.
|
||||||
hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = (U32)(ip - base);
|
* Insert the other positions into the large hash table if their entry
|
||||||
hashLarge[ZSTD_hashPtr(ip, hBitsL, 8)] = (U32)(ip - base);
|
* is empty.
|
||||||
ip += fastHashFillStep;
|
*/
|
||||||
|
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
||||||
|
U32 const current = (U32)(ip - base);
|
||||||
|
U32 i;
|
||||||
|
for (i = 0; i < fastHashFillStep; ++i) {
|
||||||
|
size_t const smHash = ZSTD_hashPtr(ip + i, hBitsS, mls);
|
||||||
|
size_t const lgHash = ZSTD_hashPtr(ip + i, hBitsL, 8);
|
||||||
|
if (i == 0)
|
||||||
|
hashSmall[smHash] = current + i;
|
||||||
|
if (i == 0 || hashLarge[lgHash] == 0)
|
||||||
|
hashLarge[lgHash] = current + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,19 @@ void ZSTD_fillHashTable (ZSTD_CCtx* zc, const void* end, const U32 mls)
|
||||||
const BYTE* const base = zc->base;
|
const BYTE* const base = zc->base;
|
||||||
const BYTE* ip = base + zc->nextToUpdate;
|
const BYTE* ip = base + zc->nextToUpdate;
|
||||||
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
|
||||||
const size_t fastHashFillStep = 3;
|
const U32 fastHashFillStep = 3;
|
||||||
|
|
||||||
while(ip <= iend) {
|
/* Always insert every fastHashFillStep position into the hash table.
|
||||||
hashTable[ZSTD_hashPtr(ip, hBits, mls)] = (U32)(ip - base);
|
* Insert the other positions if their hash entry is empty.
|
||||||
ip += fastHashFillStep;
|
*/
|
||||||
|
for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
|
||||||
|
U32 const current = (U32)(ip - base);
|
||||||
|
U32 i;
|
||||||
|
for (i = 0; i < fastHashFillStep; ++i) {
|
||||||
|
size_t const hash = ZSTD_hashPtr(ip + i, hBits, mls);
|
||||||
|
if (i == 0 || hashTable[hash] == 0)
|
||||||
|
hashTable[hash] = current + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue