1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00

Merge pull request #1924 from lz4/dictctx_copy_threshold

Copy the tables of an attached dictionary from 2 KB inputs
This commit is contained in:
Yann Collet
2026-10-21 16:06:06 -07:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

1
NEWS
View File

@@ -24,6 +24,7 @@ perf : faster decompression on aarch64 and x86-64 (up to +19% on Neoverse-V2 and
perf : `LZ4_FAST_DEC_LOOP` enabled on aarch64 with clang, including Android (up to +9% on Cortex-A5xx), by @Nicoshev and @arpadpanyik-arm
perf : `LZ4_FAST_DEC_LOOP` enabled on riscv64 when unaligned accesses are fast (`-mno-strict-align`, or a `-mcpu` with fast unaligned accesses)
perf : faster compression with reused contexts, for blocks >= 1 KB : linked frames (up to +69%), `LZ4_resetStream_fast()` (up to +94%)
perf : faster compression of 2-4 KB blocks with `LZ4_attach_dictionary()` (+3% to +30% on Zen 4)
perf : level 2 compresses slightly better (~0.1-0.5%) and faster (~+1-2%)
perf : faster levels 11 (~+25%) and 12 (~+10%)
perf : `--favor-decSpeed` : faster decompression (~+2-4% at level 12), with fewer sequences

View File

@@ -1734,6 +1734,11 @@ static int LZ4_isDictSmall(const LZ4_stream_t_internal* streamPtr)
return (streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset);
}
/* from this input size (2 KB by default, at most 4 KB),
* copying the tables of an attached dictionary is faster than looking into both tables.
* The copy cost follows the table size. */
#define LZ4_DICTCTX_COPY_THRESHOLD ((LZ4_HASHTABLESIZE / 8 < 4 KB) ? (LZ4_HASHTABLESIZE / 8) : 4 KB)
int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream,
const char* source, char* dest,
@@ -1794,7 +1799,7 @@ int LZ4_compress_fast_continue (LZ4_stream_t* LZ4_stream,
* dictCtx->currentOffset - dictCtx->dictSize. This makes it safe
* to use noDictIssue even when the dict isn't a full 64 KB.
*/
if (inputSize > 4 KB) {
if (inputSize >= LZ4_DICTCTX_COPY_THRESHOLD) {
/* For compressing large blobs, it is faster to pay the setup
* cost to copy the dictionary's tables into the active context,
* so that the compression loop is only looking into one table.