Use new paramSwitch enum for LDM
This commit is contained in:
parent
b5c35d7ea3
commit
06f42c3bfd
@ -272,8 +272,10 @@ static int ZSTD_allocateChainTable(const ZSTD_strategy strategy,
|
|||||||
* enable long distance matching (wlog >= 27, strategy >= btopt).
|
* enable long distance matching (wlog >= 27, strategy >= btopt).
|
||||||
* Returns 0 otherwise.
|
* Returns 0 otherwise.
|
||||||
*/
|
*/
|
||||||
static U32 ZSTD_CParams_shouldEnableLdm(const ZSTD_compressionParameters* const cParams) {
|
static ZSTD_paramSwitch_e ZSTD_resolveEnableLdm(ZSTD_paramSwitch_e mode,
|
||||||
return cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 27;
|
const ZSTD_compressionParameters* const cParams) {
|
||||||
|
if (mode != ZSTD_ps_auto) return mode;
|
||||||
|
return (cParams->strategy >= ZSTD_btopt && cParams->windowLog >= 27) ? ZSTD_ps_enable : ZSTD_ps_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
||||||
@ -285,15 +287,12 @@ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
|
|||||||
cctxParams.cParams = cParams;
|
cctxParams.cParams = cParams;
|
||||||
|
|
||||||
/* Adjust advanced params according to cParams */
|
/* Adjust advanced params according to cParams */
|
||||||
if (ZSTD_CParams_shouldEnableLdm(&cParams)) {
|
cctxParams.ldmParams.enableLdm = ZSTD_resolveEnableLdm(cctxParams.ldmParams.enableLdm, &cParams);
|
||||||
DEBUGLOG(4, "ZSTD_makeCCtxParamsFromCParams(): Including LDM into cctx params");
|
if (cctxParams.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
cctxParams.ldmParams.enableLdm = 1;
|
|
||||||
/* LDM is enabled by default for optimal parser and window size >= 128MB */
|
|
||||||
ZSTD_ldm_adjustParameters(&cctxParams.ldmParams, &cParams);
|
ZSTD_ldm_adjustParameters(&cctxParams.ldmParams, &cParams);
|
||||||
assert(cctxParams.ldmParams.hashLog >= cctxParams.ldmParams.bucketSizeLog);
|
assert(cctxParams.ldmParams.hashLog >= cctxParams.ldmParams.bucketSizeLog);
|
||||||
assert(cctxParams.ldmParams.hashRateLog < 32);
|
assert(cctxParams.ldmParams.hashRateLog < 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
cctxParams.useBlockSplitter = ZSTD_resolveBlockSplitterMode(cctxParams.useBlockSplitter, &cParams);
|
cctxParams.useBlockSplitter = ZSTD_resolveBlockSplitterMode(cctxParams.useBlockSplitter, &cParams);
|
||||||
cctxParams.useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(cctxParams.useRowMatchFinder, &cParams);
|
cctxParams.useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(cctxParams.useRowMatchFinder, &cParams);
|
||||||
assert(!ZSTD_checkCParams(cParams));
|
assert(!ZSTD_checkCParams(cParams));
|
||||||
@ -356,13 +355,9 @@ static void ZSTD_CCtxParams_init_internal(ZSTD_CCtx_params* cctxParams, ZSTD_par
|
|||||||
cctxParams->compressionLevel = compressionLevel;
|
cctxParams->compressionLevel = compressionLevel;
|
||||||
cctxParams->useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(cctxParams->useRowMatchFinder, ¶ms->cParams);
|
cctxParams->useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(cctxParams->useRowMatchFinder, ¶ms->cParams);
|
||||||
cctxParams->useBlockSplitter = ZSTD_resolveBlockSplitterMode(cctxParams->useBlockSplitter, ¶ms->cParams);
|
cctxParams->useBlockSplitter = ZSTD_resolveBlockSplitterMode(cctxParams->useBlockSplitter, ¶ms->cParams);
|
||||||
DEBUGLOG(4, "ZSTD_CCtxParams_init_internal: useRowMatchFinder=%d, useBlockSplitter=%d", cctxParams->useRowMatchFinder, cctxParams->useBlockSplitter);
|
cctxParams->ldmParams.enableLdm = ZSTD_resolveEnableLdm(cctxParams->ldmParams.enableLdm, ¶ms->cParams);
|
||||||
|
DEBUGLOG(4, "ZSTD_CCtxParams_init_internal: useRowMatchFinder=%d, useBlockSplitter=%d ldm=%d",
|
||||||
if (ZSTD_CParams_shouldEnableLdm(¶ms->cParams)) {
|
cctxParams->useRowMatchFinder, cctxParams->useBlockSplitter, cctxParams->ldmParams.enableLdm);
|
||||||
/* Enable LDM by default for optimal parser and window size >= 128MB */
|
|
||||||
DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
|
|
||||||
cctxParams->ldmParams.enableLdm = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params)
|
size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params)
|
||||||
@ -849,7 +844,7 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
|
|||||||
return CCtxParams->enableDedicatedDictSearch;
|
return CCtxParams->enableDedicatedDictSearch;
|
||||||
|
|
||||||
case ZSTD_c_enableLongDistanceMatching :
|
case ZSTD_c_enableLongDistanceMatching :
|
||||||
CCtxParams->ldmParams.enableLdm = (value!=0);
|
CCtxParams->ldmParams.enableLdm = (ZSTD_paramSwitch_e)value;
|
||||||
return CCtxParams->ldmParams.enableLdm;
|
return CCtxParams->ldmParams.enableLdm;
|
||||||
|
|
||||||
case ZSTD_c_ldmHashLog :
|
case ZSTD_c_ldmHashLog :
|
||||||
@ -1412,7 +1407,7 @@ ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(
|
|||||||
srcSizeHint = CCtxParams->srcSizeHint;
|
srcSizeHint = CCtxParams->srcSizeHint;
|
||||||
}
|
}
|
||||||
cParams = ZSTD_getCParams_internal(CCtxParams->compressionLevel, srcSizeHint, dictSize, mode);
|
cParams = ZSTD_getCParams_internal(CCtxParams->compressionLevel, srcSizeHint, dictSize, mode);
|
||||||
if (CCtxParams->ldmParams.enableLdm) cParams.windowLog = ZSTD_LDM_DEFAULT_WINDOW_LOG;
|
if (CCtxParams->ldmParams.enableLdm == ZSTD_ps_enable) cParams.windowLog = ZSTD_LDM_DEFAULT_WINDOW_LOG;
|
||||||
ZSTD_overrideCParams(&cParams, &CCtxParams->cParams);
|
ZSTD_overrideCParams(&cParams, &CCtxParams->cParams);
|
||||||
assert(!ZSTD_checkCParams(cParams));
|
assert(!ZSTD_checkCParams(cParams));
|
||||||
/* srcSizeHint == 0 means 0 */
|
/* srcSizeHint == 0 means 0 */
|
||||||
@ -1483,7 +1478,7 @@ static size_t ZSTD_estimateCCtxSize_usingCCtxParams_internal(
|
|||||||
|
|
||||||
size_t const ldmSpace = ZSTD_ldm_getTableSize(*ldmParams);
|
size_t const ldmSpace = ZSTD_ldm_getTableSize(*ldmParams);
|
||||||
size_t const maxNbLdmSeq = ZSTD_ldm_getMaxNbSeq(*ldmParams, blockSize);
|
size_t const maxNbLdmSeq = ZSTD_ldm_getMaxNbSeq(*ldmParams, blockSize);
|
||||||
size_t const ldmSeqSpace = ldmParams->enableLdm ?
|
size_t const ldmSeqSpace = ldmParams->enableLdm == ZSTD_ps_enable ?
|
||||||
ZSTD_cwksp_aligned_alloc_size(maxNbLdmSeq * sizeof(rawSeq)) : 0;
|
ZSTD_cwksp_aligned_alloc_size(maxNbLdmSeq * sizeof(rawSeq)) : 0;
|
||||||
|
|
||||||
|
|
||||||
@ -1852,7 +1847,8 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
|||||||
|
|
||||||
assert(params->useRowMatchFinder != ZSTD_ps_auto);
|
assert(params->useRowMatchFinder != ZSTD_ps_auto);
|
||||||
assert(params->useBlockSplitter != ZSTD_ps_auto);
|
assert(params->useBlockSplitter != ZSTD_ps_auto);
|
||||||
if (params->ldmParams.enableLdm) {
|
assert(params->ldmParams.enableLdm != ZSTD_ps_auto);
|
||||||
|
if (params->ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
/* Adjust long distance matching parameters */
|
/* Adjust long distance matching parameters */
|
||||||
ZSTD_ldm_adjustParameters(&zc->appliedParams.ldmParams, ¶ms->cParams);
|
ZSTD_ldm_adjustParameters(&zc->appliedParams.ldmParams, ¶ms->cParams);
|
||||||
assert(params->ldmParams.hashLog >= params->ldmParams.bucketSizeLog);
|
assert(params->ldmParams.hashLog >= params->ldmParams.bucketSizeLog);
|
||||||
@ -1952,7 +1948,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
|||||||
zc->outBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffOutSize);
|
zc->outBuff = (char*)ZSTD_cwksp_reserve_buffer(ws, buffOutSize);
|
||||||
|
|
||||||
/* ldm bucketOffsets table */
|
/* ldm bucketOffsets table */
|
||||||
if (params->ldmParams.enableLdm) {
|
if (params->ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
/* TODO: avoid memset? */
|
/* TODO: avoid memset? */
|
||||||
size_t const numBuckets =
|
size_t const numBuckets =
|
||||||
((size_t)1) << (params->ldmParams.hashLog -
|
((size_t)1) << (params->ldmParams.hashLog -
|
||||||
@ -1979,7 +1975,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
|||||||
ZSTD_resetTarget_CCtx), "");
|
ZSTD_resetTarget_CCtx), "");
|
||||||
|
|
||||||
/* ldm hash table */
|
/* ldm hash table */
|
||||||
if (params->ldmParams.enableLdm) {
|
if (params->ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
/* TODO: avoid memset? */
|
/* TODO: avoid memset? */
|
||||||
size_t const ldmHSize = ((size_t)1) << params->ldmParams.hashLog;
|
size_t const ldmHSize = ((size_t)1) << params->ldmParams.hashLog;
|
||||||
zc->ldmState.hashTable = (ldmEntry_t*)ZSTD_cwksp_reserve_aligned(ws, ldmHSize * sizeof(ldmEntry_t));
|
zc->ldmState.hashTable = (ldmEntry_t*)ZSTD_cwksp_reserve_aligned(ws, ldmHSize * sizeof(ldmEntry_t));
|
||||||
@ -2226,8 +2222,10 @@ static size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx,
|
|||||||
params.cParams = srcCCtx->appliedParams.cParams;
|
params.cParams = srcCCtx->appliedParams.cParams;
|
||||||
assert(srcCCtx->appliedParams.useRowMatchFinder != ZSTD_ps_auto);
|
assert(srcCCtx->appliedParams.useRowMatchFinder != ZSTD_ps_auto);
|
||||||
assert(srcCCtx->appliedParams.useBlockSplitter != ZSTD_ps_auto);
|
assert(srcCCtx->appliedParams.useBlockSplitter != ZSTD_ps_auto);
|
||||||
|
assert(srcCCtx->appliedParams.ldmParams.enableLdm != ZSTD_ps_auto);
|
||||||
params.useRowMatchFinder = srcCCtx->appliedParams.useRowMatchFinder;
|
params.useRowMatchFinder = srcCCtx->appliedParams.useRowMatchFinder;
|
||||||
params.useBlockSplitter = srcCCtx->appliedParams.useBlockSplitter;
|
params.useBlockSplitter = srcCCtx->appliedParams.useBlockSplitter;
|
||||||
|
params.ldmParams = srcCCtx->appliedParams.ldmParams;
|
||||||
params.fParams = fParams;
|
params.fParams = fParams;
|
||||||
ZSTD_resetCCtx_internal(dstCCtx, ¶ms, pledgedSrcSize,
|
ZSTD_resetCCtx_internal(dstCCtx, ¶ms, pledgedSrcSize,
|
||||||
/* loadedDictSize */ 0,
|
/* loadedDictSize */ 0,
|
||||||
@ -2849,7 +2847,7 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
|
|||||||
zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i];
|
zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i];
|
||||||
}
|
}
|
||||||
if (zc->externSeqStore.pos < zc->externSeqStore.size) {
|
if (zc->externSeqStore.pos < zc->externSeqStore.size) {
|
||||||
assert(!zc->appliedParams.ldmParams.enableLdm);
|
assert(zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_disable);
|
||||||
/* Updates ldmSeqStore.pos */
|
/* Updates ldmSeqStore.pos */
|
||||||
lastLLSize =
|
lastLLSize =
|
||||||
ZSTD_ldm_blockCompress(&zc->externSeqStore,
|
ZSTD_ldm_blockCompress(&zc->externSeqStore,
|
||||||
@ -2858,7 +2856,7 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
|
|||||||
zc->appliedParams.useRowMatchFinder,
|
zc->appliedParams.useRowMatchFinder,
|
||||||
src, srcSize);
|
src, srcSize);
|
||||||
assert(zc->externSeqStore.pos <= zc->externSeqStore.size);
|
assert(zc->externSeqStore.pos <= zc->externSeqStore.size);
|
||||||
} else if (zc->appliedParams.ldmParams.enableLdm) {
|
} else if (zc->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
rawSeqStore_t ldmSeqStore = kNullRawSeqStore;
|
rawSeqStore_t ldmSeqStore = kNullRawSeqStore;
|
||||||
|
|
||||||
ldmSeqStore.seq = zc->ldmSequences;
|
ldmSeqStore.seq = zc->ldmSequences;
|
||||||
@ -4081,7 +4079,7 @@ size_t ZSTD_referenceExternalSequences(ZSTD_CCtx* cctx, rawSeq* seq, size_t nbSe
|
|||||||
{
|
{
|
||||||
RETURN_ERROR_IF(cctx->stage != ZSTDcs_init, stage_wrong,
|
RETURN_ERROR_IF(cctx->stage != ZSTDcs_init, stage_wrong,
|
||||||
"wrong cctx stage");
|
"wrong cctx stage");
|
||||||
RETURN_ERROR_IF(cctx->appliedParams.ldmParams.enableLdm,
|
RETURN_ERROR_IF(cctx->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable,
|
||||||
parameter_unsupported,
|
parameter_unsupported,
|
||||||
"incompatible with ldm");
|
"incompatible with ldm");
|
||||||
cctx->externSeqStore.seq = seq;
|
cctx->externSeqStore.seq = seq;
|
||||||
@ -4122,7 +4120,7 @@ static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx,
|
|||||||
ms->forceNonContiguous = 0;
|
ms->forceNonContiguous = 0;
|
||||||
ms->nextToUpdate = ms->window.dictLimit;
|
ms->nextToUpdate = ms->window.dictLimit;
|
||||||
}
|
}
|
||||||
if (cctx->appliedParams.ldmParams.enableLdm) {
|
if (cctx->appliedParams.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
ZSTD_window_update(&cctx->ldmState.window, src, srcSize, /* forceNonContiguous */ 0);
|
ZSTD_window_update(&cctx->ldmState.window, src, srcSize, /* forceNonContiguous */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4191,7 +4189,7 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
|
|||||||
{
|
{
|
||||||
const BYTE* ip = (const BYTE*) src;
|
const BYTE* ip = (const BYTE*) src;
|
||||||
const BYTE* const iend = ip + srcSize;
|
const BYTE* const iend = ip + srcSize;
|
||||||
int const loadLdmDict = params->ldmParams.enableLdm && ls != NULL;
|
int const loadLdmDict = params->ldmParams.enableLdm == ZSTD_ps_enable && ls != NULL;
|
||||||
|
|
||||||
/* Assert that we the ms params match the params we're being given */
|
/* Assert that we the ms params match the params we're being given */
|
||||||
ZSTD_assertEqualCParams(params->cParams, ms->cParams);
|
ZSTD_assertEqualCParams(params->cParams, ms->cParams);
|
||||||
@ -5557,14 +5555,9 @@ static size_t ZSTD_CCtx_init_compressStream2(ZSTD_CCtx* cctx,
|
|||||||
¶ms, cctx->pledgedSrcSizePlusOne-1,
|
¶ms, cctx->pledgedSrcSizePlusOne-1,
|
||||||
dictSize, mode);
|
dictSize, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZSTD_CParams_shouldEnableLdm(¶ms.cParams)) {
|
|
||||||
/* Enable LDM by default for optimal parser and window size >= 128MB */
|
|
||||||
DEBUGLOG(4, "LDM enabled by default (window size >= 128MB, strategy >= btopt)");
|
|
||||||
params.ldmParams.enableLdm = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
params.useBlockSplitter = ZSTD_resolveBlockSplitterMode(params.useBlockSplitter, ¶ms.cParams);
|
params.useBlockSplitter = ZSTD_resolveBlockSplitterMode(params.useBlockSplitter, ¶ms.cParams);
|
||||||
|
params.ldmParams.enableLdm = ZSTD_resolveEnableLdm(params.ldmParams.enableLdm, ¶ms.cParams);
|
||||||
params.useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params.useRowMatchFinder, ¶ms.cParams);
|
params.useRowMatchFinder = ZSTD_resolveRowMatchFinderMode(params.useRowMatchFinder, ¶ms.cParams);
|
||||||
|
|
||||||
#ifdef ZSTD_MULTITHREAD
|
#ifdef ZSTD_MULTITHREAD
|
||||||
|
@ -266,7 +266,7 @@ typedef struct {
|
|||||||
} ldmState_t;
|
} ldmState_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
U32 enableLdm; /* 1 if enable long distance matching */
|
ZSTD_paramSwitch_e enableLdm; /* ZSTD_ps_enable to enable LDM. ZSTD_ps_auto by default */
|
||||||
U32 hashLog; /* Log size of hashTable */
|
U32 hashLog; /* Log size of hashTable */
|
||||||
U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
|
U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
|
||||||
U32 minMatchLength; /* Minimum match length */
|
U32 minMatchLength; /* Minimum match length */
|
||||||
|
@ -159,12 +159,12 @@ size_t ZSTD_ldm_getTableSize(ldmParams_t params)
|
|||||||
size_t const ldmBucketSize = ((size_t)1) << (params.hashLog - ldmBucketSizeLog);
|
size_t const ldmBucketSize = ((size_t)1) << (params.hashLog - ldmBucketSizeLog);
|
||||||
size_t const totalSize = ZSTD_cwksp_alloc_size(ldmBucketSize)
|
size_t const totalSize = ZSTD_cwksp_alloc_size(ldmBucketSize)
|
||||||
+ ZSTD_cwksp_alloc_size(ldmHSize * sizeof(ldmEntry_t));
|
+ ZSTD_cwksp_alloc_size(ldmHSize * sizeof(ldmEntry_t));
|
||||||
return params.enableLdm ? totalSize : 0;
|
return params.enableLdm == ZSTD_ps_enable ? totalSize : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize)
|
size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize)
|
||||||
{
|
{
|
||||||
return params.enableLdm ? (maxChunkSize / params.minMatchLength) : 0;
|
return params.enableLdm == ZSTD_ps_enable ? (maxChunkSize / params.minMatchLength) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ZSTD_ldm_getBucket() :
|
/** ZSTD_ldm_getBucket() :
|
||||||
|
@ -467,7 +467,7 @@ ZSTDMT_serialState_reset(serialState_t* serialState,
|
|||||||
ZSTD_dictContentType_e dictContentType)
|
ZSTD_dictContentType_e dictContentType)
|
||||||
{
|
{
|
||||||
/* Adjust parameters */
|
/* Adjust parameters */
|
||||||
if (params.ldmParams.enableLdm) {
|
if (params.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
DEBUGLOG(4, "LDM window size = %u KB", (1U << params.cParams.windowLog) >> 10);
|
DEBUGLOG(4, "LDM window size = %u KB", (1U << params.cParams.windowLog) >> 10);
|
||||||
ZSTD_ldm_adjustParameters(¶ms.ldmParams, ¶ms.cParams);
|
ZSTD_ldm_adjustParameters(¶ms.ldmParams, ¶ms.cParams);
|
||||||
assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
|
assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
|
||||||
@ -478,7 +478,7 @@ ZSTDMT_serialState_reset(serialState_t* serialState,
|
|||||||
serialState->nextJobID = 0;
|
serialState->nextJobID = 0;
|
||||||
if (params.fParams.checksumFlag)
|
if (params.fParams.checksumFlag)
|
||||||
XXH64_reset(&serialState->xxhState, 0);
|
XXH64_reset(&serialState->xxhState, 0);
|
||||||
if (params.ldmParams.enableLdm) {
|
if (params.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
ZSTD_customMem cMem = params.customMem;
|
ZSTD_customMem cMem = params.customMem;
|
||||||
unsigned const hashLog = params.ldmParams.hashLog;
|
unsigned const hashLog = params.ldmParams.hashLog;
|
||||||
size_t const hashSize = ((size_t)1 << hashLog) * sizeof(ldmEntry_t);
|
size_t const hashSize = ((size_t)1 << hashLog) * sizeof(ldmEntry_t);
|
||||||
@ -564,7 +564,7 @@ static void ZSTDMT_serialState_update(serialState_t* serialState,
|
|||||||
/* A future job may error and skip our job */
|
/* A future job may error and skip our job */
|
||||||
if (serialState->nextJobID == jobID) {
|
if (serialState->nextJobID == jobID) {
|
||||||
/* It is now our turn, do any processing necessary */
|
/* It is now our turn, do any processing necessary */
|
||||||
if (serialState->params.ldmParams.enableLdm) {
|
if (serialState->params.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
size_t error;
|
size_t error;
|
||||||
assert(seqStore.seq != NULL && seqStore.pos == 0 &&
|
assert(seqStore.seq != NULL && seqStore.pos == 0 &&
|
||||||
seqStore.size == 0 && seqStore.capacity > 0);
|
seqStore.size == 0 && seqStore.capacity > 0);
|
||||||
@ -594,7 +594,7 @@ static void ZSTDMT_serialState_update(serialState_t* serialState,
|
|||||||
if (seqStore.size > 0) {
|
if (seqStore.size > 0) {
|
||||||
size_t const err = ZSTD_referenceExternalSequences(
|
size_t const err = ZSTD_referenceExternalSequences(
|
||||||
jobCCtx, seqStore.seq, seqStore.size);
|
jobCCtx, seqStore.seq, seqStore.size);
|
||||||
assert(serialState->params.ldmParams.enableLdm);
|
assert(serialState->params.ldmParams.enableLdm == ZSTD_ps_enable);
|
||||||
assert(!ZSTD_isError(err));
|
assert(!ZSTD_isError(err));
|
||||||
(void)err;
|
(void)err;
|
||||||
}
|
}
|
||||||
@ -672,7 +672,7 @@ static void ZSTDMT_compressionJob(void* jobDescription)
|
|||||||
if (dstBuff.start==NULL) JOB_ERROR(ERROR(memory_allocation));
|
if (dstBuff.start==NULL) JOB_ERROR(ERROR(memory_allocation));
|
||||||
job->dstBuff = dstBuff; /* this value can be read in ZSTDMT_flush, when it copies the whole job */
|
job->dstBuff = dstBuff; /* this value can be read in ZSTDMT_flush, when it copies the whole job */
|
||||||
}
|
}
|
||||||
if (jobParams.ldmParams.enableLdm && rawSeqStore.seq == NULL)
|
if (jobParams.ldmParams.enableLdm == ZSTD_ps_enable && rawSeqStore.seq == NULL)
|
||||||
JOB_ERROR(ERROR(memory_allocation));
|
JOB_ERROR(ERROR(memory_allocation));
|
||||||
|
|
||||||
/* Don't compute the checksum for chunks, since we compute it externally,
|
/* Don't compute the checksum for chunks, since we compute it externally,
|
||||||
@ -680,7 +680,7 @@ static void ZSTDMT_compressionJob(void* jobDescription)
|
|||||||
*/
|
*/
|
||||||
if (job->jobID != 0) jobParams.fParams.checksumFlag = 0;
|
if (job->jobID != 0) jobParams.fParams.checksumFlag = 0;
|
||||||
/* Don't run LDM for the chunks, since we handle it externally */
|
/* Don't run LDM for the chunks, since we handle it externally */
|
||||||
jobParams.ldmParams.enableLdm = 0;
|
jobParams.ldmParams.enableLdm = ZSTD_ps_disable;
|
||||||
/* Correct nbWorkers to 0. */
|
/* Correct nbWorkers to 0. */
|
||||||
jobParams.nbWorkers = 0;
|
jobParams.nbWorkers = 0;
|
||||||
|
|
||||||
@ -1144,7 +1144,7 @@ size_t ZSTDMT_toFlushNow(ZSTDMT_CCtx* mtctx)
|
|||||||
static unsigned ZSTDMT_computeTargetJobLog(const ZSTD_CCtx_params* params)
|
static unsigned ZSTDMT_computeTargetJobLog(const ZSTD_CCtx_params* params)
|
||||||
{
|
{
|
||||||
unsigned jobLog;
|
unsigned jobLog;
|
||||||
if (params->ldmParams.enableLdm) {
|
if (params->ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
/* In Long Range Mode, the windowLog is typically oversized.
|
/* In Long Range Mode, the windowLog is typically oversized.
|
||||||
* In which case, it's preferable to determine the jobSize
|
* In which case, it's preferable to determine the jobSize
|
||||||
* based on cycleLog instead. */
|
* based on cycleLog instead. */
|
||||||
@ -1188,7 +1188,7 @@ static size_t ZSTDMT_computeOverlapSize(const ZSTD_CCtx_params* params)
|
|||||||
int const overlapRLog = 9 - ZSTDMT_overlapLog(params->overlapLog, params->cParams.strategy);
|
int const overlapRLog = 9 - ZSTDMT_overlapLog(params->overlapLog, params->cParams.strategy);
|
||||||
int ovLog = (overlapRLog >= 8) ? 0 : (params->cParams.windowLog - overlapRLog);
|
int ovLog = (overlapRLog >= 8) ? 0 : (params->cParams.windowLog - overlapRLog);
|
||||||
assert(0 <= overlapRLog && overlapRLog <= 8);
|
assert(0 <= overlapRLog && overlapRLog <= 8);
|
||||||
if (params->ldmParams.enableLdm) {
|
if (params->ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
/* In Long Range Mode, the windowLog is typically oversized.
|
/* In Long Range Mode, the windowLog is typically oversized.
|
||||||
* In which case, it's preferable to determine the jobSize
|
* In which case, it's preferable to determine the jobSize
|
||||||
* based on chainLog instead.
|
* based on chainLog instead.
|
||||||
@ -1275,7 +1275,7 @@ size_t ZSTDMT_initCStream_internal(
|
|||||||
ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(mtctx->targetSectionSize));
|
ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(mtctx->targetSectionSize));
|
||||||
{
|
{
|
||||||
/* If ldm is enabled we need windowSize space. */
|
/* If ldm is enabled we need windowSize space. */
|
||||||
size_t const windowSize = mtctx->params.ldmParams.enableLdm ? (1U << mtctx->params.cParams.windowLog) : 0;
|
size_t const windowSize = mtctx->params.ldmParams.enableLdm == ZSTD_ps_enable ? (1U << mtctx->params.cParams.windowLog) : 0;
|
||||||
/* Two buffers of slack, plus extra space for the overlap
|
/* Two buffers of slack, plus extra space for the overlap
|
||||||
* This is the minimum slack that LDM works with. One extra because
|
* This is the minimum slack that LDM works with. One extra because
|
||||||
* flush might waste up to targetSectionSize-1 bytes. Another extra
|
* flush might waste up to targetSectionSize-1 bytes. Another extra
|
||||||
@ -1587,7 +1587,7 @@ static int ZSTDMT_doesOverlapWindow(buffer_t buffer, ZSTD_window_t window)
|
|||||||
|
|
||||||
static void ZSTDMT_waitForLdmComplete(ZSTDMT_CCtx* mtctx, buffer_t buffer)
|
static void ZSTDMT_waitForLdmComplete(ZSTDMT_CCtx* mtctx, buffer_t buffer)
|
||||||
{
|
{
|
||||||
if (mtctx->params.ldmParams.enableLdm) {
|
if (mtctx->params.ldmParams.enableLdm == ZSTD_ps_enable) {
|
||||||
ZSTD_pthread_mutex_t* mutex = &mtctx->serial.ldmWindowMutex;
|
ZSTD_pthread_mutex_t* mutex = &mtctx->serial.ldmWindowMutex;
|
||||||
DEBUGLOG(5, "ZSTDMT_waitForLdmComplete");
|
DEBUGLOG(5, "ZSTDMT_waitForLdmComplete");
|
||||||
DEBUGLOG(5, "source [0x%zx, 0x%zx)",
|
DEBUGLOG(5, "source [0x%zx, 0x%zx)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user