diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index bbca6729d..b88d53de5 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -342,7 +342,7 @@ size_t ZSTDMT_initializeCCtxParameters(ZSTD_CCtx_params* params, unsigned nbThre static size_t ZSTD_ldm_initializeParameters(ldmParams_t* params, U32 enableLdm) { - assert(LDM_BUCKET_SIZE_LOG <= ZSTD_LDM_BUCKETSIZELOG_MAX); + ZSTD_STATIC_ASSERT(LDM_BUCKET_SIZE_LOG <= ZSTD_LDM_BUCKETSIZELOG_MAX); params->enableLdm = enableLdm>0; params->hashLog = LDM_HASH_LOG; params->bucketSizeLog = LDM_BUCKET_SIZE_LOG; @@ -3568,8 +3568,6 @@ size_t ZSTD_compressBlock_ldm_generic(ZSTD_CCtx* cctx, } ip += rLength; anchor = ip; - - continue; /* faster when present ... (?) */ } } @@ -3836,12 +3834,11 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCa const U32 current = (U32)(istart-base); size_t lastLLSize; const BYTE* anchor; + U32 const extDict = zc->lowLimit < zc->dictLimit; const ZSTD_blockCompressor blockCompressor = - zc->appliedParams.ldmParams.enableLdm ? - (zc->lowLimit < zc->dictLimit ? ZSTD_compressBlock_ldm_extDict : - ZSTD_compressBlock_ldm) : - ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, - zc->lowLimit < zc->dictLimit); + zc->appliedParams.ldmParams.enableLdm + ? (extDict ? ZSTD_compressBlock_ldm_extDict : ZSTD_compressBlock_ldm) + : ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, extDict); if (srcSize < MIN_CBLOCK_SIZE+ZSTD_blockHeaderSize+1) return 0; /* don't even attempt compression below a certain srcSize */ ZSTD_resetSeqStore(&(zc->seqStore)); diff --git a/lib/zstd.h b/lib/zstd.h index 4879c4a63..662657b23 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -979,7 +979,7 @@ typedef enum { /* advanced parameters - may not remain available after API update */ ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize, * even when referencing into Dictionary content (default:0) */ - ZSTD_p_enableLongDistanceMatching, /* Enable long distance matching. + ZSTD_p_enableLongDistanceMatching=1200, /* Enable long distance matching. * This parameter is designed to improve the compression * ratio for large inputs with long distance matches. * This increases the memory usage as well as window size. diff --git a/programs/zstd.1 b/programs/zstd.1 index 13c804ae5..0fad1d277 100644 --- a/programs/zstd.1 +++ b/programs/zstd.1 @@ -327,7 +327,7 @@ Determine \fBoverlapSize\fR, amount of data reloaded from previous job\. This pa The minimum \fIovlog\fR is 0, and the maximum is 9\. 0 means "no overlap", hence completely independent jobs\. 9 means "full overlap", meaning up to \fBwindowSize\fR is reloaded from previous job\. Reducing \fIovlog\fR by 1 reduces the amount of reload by a factor 2\. Default \fIovlog\fR is 6, which means "reload \fBwindowSize / 8\fR"\. Exception : the maximum compression level (22) has a default \fIovlog\fR of 9\. . .TP -\fBldmHashLog\fR=\fIldmHlog\fR, \fBldmHlog\fR=\fIldmHlog\fR +\fBldmHashLog\fR=\fIldmhlog\fR, \fBldmhlog\fR=\fIldmhlog\fR Specify the maximum size for a hash table used for long distance matching\. . .IP @@ -337,10 +337,10 @@ This option is ignored unless long distance matching is enabled\. Bigger hash tables usually improve compression ratio at the expense of more memory during compression and a decrease in compression speed\. . .IP -The minimum \fIldmHlog\fR is 6 and the maximum is 26 (default: 20)\. +The minimum \fIldmhlog\fR is 6 and the maximum is 26 (default: 20)\. . .TP -\fBldmSearchLength\fR=\fIldmSlen\fR, \fBldmSlen\fR=\fIldmSlen\fR +\fBldmSearchLength\fR=\fIldmslen\fR, \fBldmSlen\fR=\fIldmslen\fR Specify the minimum searched length of a match for long distance matching\. . .IP @@ -350,10 +350,10 @@ This option is ignored unless long distance matching is enabled\. Larger/very small values usually decrease compression ratio\. . .IP -The minumum \fIldmSlen\fR is 4 and the maximum is 4096 (default: 64)\. +The minumum \fIldmslen\fR is 4 and the maximum is 4096 (default: 64)\. . .TP -\fBldmBucketSizeLog\fR=\fIldmBucketSizeLog\fR +\fBldmBucketSizeLog\fR=\fIldmblog\fR, \fBldmblog\fR=\fIldmblog\fR Specify the size of each bucket for the hash table used for long distance matching\. . .IP @@ -363,10 +363,10 @@ This option is ignored unless long distance matching is enabled\. Larger bucket sizes improve collision resolution but decrease compression speed\. . .IP -The minimum \fIldmBucketSizeLog\fR is 0 and the maximum is 8 (default: 3)\. +The minimum \fIldmblog\fR is 0 and the maximum is 8 (default: 3)\. . .TP -\fBldmHashEveryLog\fR=\fIldmHashEveryLog\fR +\fBldmHashEveryLog\fR=\fIldmhevery\fR, \fBldmhevery\fR=\fIldmhevery\fR Specify the frequency of inserting entries into the long distance matching hash table\. . .IP @@ -376,7 +376,7 @@ This option is ignored unless long distance matching is enabled\. Larger values will improve compression speed\. Deviating far from the default value will likely result in a decrease in compression ratio\. . .IP -The default value is \fBwLog \- ldmHlog\fR\. +The default value is \fBwlog \- ldmhlog\fR\. . .SS "\-B#:" Select the size of each compression job\. This parameter is available only when multi\-threading is enabled\. Default value is \fB4 * windowSize\fR, which means it varies depending on compression level\. \fB\-B#\fR makes it possible to select a custom value\. Note that job size must respect a minimum value which is enforced transparently\. This minimum is either 1 MB, or \fBoverlapSize\fR, whichever is largest\. diff --git a/programs/zstd.1.md b/programs/zstd.1.md index 5f6aa4500..2fcedde3c 100644 --- a/programs/zstd.1.md +++ b/programs/zstd.1.md @@ -333,7 +333,7 @@ The list of available _options_: Default _ovlog_ is 6, which means "reload `windowSize / 8`". Exception : the maximum compression level (22) has a default _ovlog_ of 9. -- `ldmHashLog`=_ldmHlog_, `ldmHlog`=_ldmHlog_: +- `ldmHashLog`=_ldmhlog_, `ldmhlog`=_ldmhlog_: Specify the maximum size for a hash table used for long distance matching. This option is ignored unless long distance matching is enabled. @@ -341,18 +341,18 @@ The list of available _options_: Bigger hash tables usually improve compression ratio at the expense of more memory during compression and a decrease in compression speed. - The minimum _ldmHlog_ is 6 and the maximum is 26 (default: 20). + The minimum _ldmhlog_ is 6 and the maximum is 26 (default: 20). -- `ldmSearchLength`=_ldmSlen_, `ldmSlen`=_ldmSlen_: +- `ldmSearchLength`=_ldmslen_, `ldmslen`=_ldmslen_: Specify the minimum searched length of a match for long distance matching. This option is ignored unless long distance matching is enabled. Larger/very small values usually decrease compression ratio. - The minumum _ldmSlen_ is 4 and the maximum is 4096 (default: 64). + The minumum _ldmslen_ is 4 and the maximum is 4096 (default: 64). -- `ldmBucketSizeLog`=_ldmBucketSizeLog_: +- `ldmBucketSizeLog`=_ldmblog_, `ldmblog`=_ldmblog_: Specify the size of each bucket for the hash table used for long distance matching. @@ -361,9 +361,9 @@ The list of available _options_: Larger bucket sizes improve collision resolution but decrease compression speed. - The minimum _ldmBucketSizeLog_ is 0 and the maximum is 8 (default: 3). + The minimum _ldmblog_ is 0 and the maximum is 8 (default: 3). -- `ldmHashEveryLog`=_ldmHashEveryLog_: +- `ldmHashEveryLog`=_ldmhevery_, `ldmhevery`=_ldmhevery_: Specify the frequency of inserting entries into the long distance matching hash table. @@ -372,8 +372,8 @@ The list of available _options_: Larger values will improve compression speed. Deviating far from the default value will likely result in a decrease in compression ratio. - The default value is `wLog - ldmHlog`. - + The default value is `wlog - ldmhlog`. + ### -B#: Select the size of each compression job. This parameter is available only when multi-threading is enabled. diff --git a/programs/zstdcli.c b/programs/zstdcli.c index a60537a0c..a3d508515 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -310,10 +310,10 @@ static unsigned parseCompressionParameters(const char* stringPtr, ZSTD_compressi if (longCommandWArg(&stringPtr, "targetLength=") || longCommandWArg(&stringPtr, "tlen=")) { params->targetLength = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } if (longCommandWArg(&stringPtr, "strategy=") || longCommandWArg(&stringPtr, "strat=")) { params->strategy = (ZSTD_strategy)(readU32FromChar(&stringPtr)); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } if (longCommandWArg(&stringPtr, "overlapLog=") || longCommandWArg(&stringPtr, "ovlog=")) { g_overlapLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } - if (longCommandWArg(&stringPtr, "ldmHashLog=") || longCommandWArg(&stringPtr, "ldmHlog=")) { g_ldmHashLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } - if (longCommandWArg(&stringPtr, "ldmSearchLength=") || longCommandWArg(&stringPtr, "ldmSlen=")) { g_ldmMinMatch = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } - if (longCommandWArg(&stringPtr, "ldmBucketSizeLog=")) { g_ldmBucketSizeLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } - if (longCommandWArg(&stringPtr, "ldmHashEveryLog=")) { g_ldmHashEveryLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } + if (longCommandWArg(&stringPtr, "ldmHashLog=") || longCommandWArg(&stringPtr, "ldmhlog=")) { g_ldmHashLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } + if (longCommandWArg(&stringPtr, "ldmSearchLength=") || longCommandWArg(&stringPtr, "ldmslen=")) { g_ldmMinMatch = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } + if (longCommandWArg(&stringPtr, "ldmBucketSizeLog=") || longCommandWArg(&stringPtr, "ldmblog")) { g_ldmBucketSizeLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } + if (longCommandWArg(&stringPtr, "ldmHashEveryLog=") || longCommandWArg(&stringPtr, "ldmhevery")) { g_ldmHashEveryLog = readU32FromChar(&stringPtr); if (stringPtr[0]==',') { stringPtr++; continue; } else break; } return 0; }