mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
removed literalCompression directive
in this version, literal compression is always disabled for ZSTD_fast strategy. Performance parity between ZSTD_compress_advanced() and ZSTD_compress_generic()
This commit is contained in:
@ -867,12 +867,6 @@ size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long
|
|||||||
</b>/* experimental parameters - no stability guaranteed */<b>
|
</b>/* experimental parameters - no stability guaranteed */<b>
|
||||||
</b>/* =================================================================== */<b>
|
</b>/* =================================================================== */<b>
|
||||||
|
|
||||||
ZSTD_p_compressLiterals=1000, </b>/* control huffman compression of literals (enabled) by default.<b>
|
|
||||||
* disabling it improves speed and decreases compression ratio by a large amount.
|
|
||||||
* note : this setting is automatically updated when changing compression level.
|
|
||||||
* positive compression levels set ZSTD_p_compressLiterals to 1.
|
|
||||||
* negative compression levels set ZSTD_p_compressLiterals to 0. */
|
|
||||||
|
|
||||||
ZSTD_p_forceMaxWindow=1100, </b>/* Force back-reference distances to remain < windowSize,<b>
|
ZSTD_p_forceMaxWindow=1100, </b>/* Force back-reference distances to remain < windowSize,<b>
|
||||||
* even when referencing into Dictionary content (default:0) */
|
* even when referencing into Dictionary content (default:0) */
|
||||||
|
|
||||||
|
@ -267,7 +267,6 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
|
|||||||
case ZSTD_p_minMatch:
|
case ZSTD_p_minMatch:
|
||||||
case ZSTD_p_targetLength:
|
case ZSTD_p_targetLength:
|
||||||
case ZSTD_p_compressionStrategy:
|
case ZSTD_p_compressionStrategy:
|
||||||
case ZSTD_p_compressLiterals:
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case ZSTD_p_format:
|
case ZSTD_p_format:
|
||||||
@ -318,7 +317,6 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v
|
|||||||
if (cctx->cdict) return ERROR(stage_wrong);
|
if (cctx->cdict) return ERROR(stage_wrong);
|
||||||
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
|
||||||
|
|
||||||
case ZSTD_p_compressLiterals:
|
|
||||||
case ZSTD_p_contentSizeFlag:
|
case ZSTD_p_contentSizeFlag:
|
||||||
case ZSTD_p_checksumFlag:
|
case ZSTD_p_checksumFlag:
|
||||||
case ZSTD_p_dictIDFlag:
|
case ZSTD_p_dictIDFlag:
|
||||||
@ -367,7 +365,6 @@ size_t ZSTD_CCtxParam_setParameter(
|
|||||||
int cLevel = (int)value; /* cast expected to restore negative sign */
|
int cLevel = (int)value; /* cast expected to restore negative sign */
|
||||||
if (cLevel > ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel();
|
if (cLevel > ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel();
|
||||||
if (cLevel) { /* 0 : does not change current level */
|
if (cLevel) { /* 0 : does not change current level */
|
||||||
CCtxParams->disableLiteralCompression = (cLevel<0); /* negative levels disable huffman */
|
|
||||||
CCtxParams->compressionLevel = cLevel;
|
CCtxParams->compressionLevel = cLevel;
|
||||||
}
|
}
|
||||||
if (CCtxParams->compressionLevel >= 0) return CCtxParams->compressionLevel;
|
if (CCtxParams->compressionLevel >= 0) return CCtxParams->compressionLevel;
|
||||||
@ -415,10 +412,6 @@ size_t ZSTD_CCtxParam_setParameter(
|
|||||||
CCtxParams->cParams.strategy = (ZSTD_strategy)value;
|
CCtxParams->cParams.strategy = (ZSTD_strategy)value;
|
||||||
return (size_t)CCtxParams->cParams.strategy;
|
return (size_t)CCtxParams->cParams.strategy;
|
||||||
|
|
||||||
case ZSTD_p_compressLiterals:
|
|
||||||
CCtxParams->disableLiteralCompression = !value;
|
|
||||||
return !CCtxParams->disableLiteralCompression;
|
|
||||||
|
|
||||||
case ZSTD_p_contentSizeFlag :
|
case ZSTD_p_contentSizeFlag :
|
||||||
/* Content size written in frame header _when known_ (default:1) */
|
/* Content size written in frame header _when known_ (default:1) */
|
||||||
DEBUGLOG(4, "set content size flag = %u", (value>0));
|
DEBUGLOG(4, "set content size flag = %u", (value>0));
|
||||||
@ -530,9 +523,6 @@ size_t ZSTD_CCtxParam_getParameter(
|
|||||||
case ZSTD_p_compressionStrategy :
|
case ZSTD_p_compressionStrategy :
|
||||||
*value = (unsigned)CCtxParams->cParams.strategy;
|
*value = (unsigned)CCtxParams->cParams.strategy;
|
||||||
break;
|
break;
|
||||||
case ZSTD_p_compressLiterals:
|
|
||||||
*value = !CCtxParams->disableLiteralCompression;
|
|
||||||
break;
|
|
||||||
case ZSTD_p_contentSizeFlag :
|
case ZSTD_p_contentSizeFlag :
|
||||||
*value = CCtxParams->fParams.contentSizeFlag;
|
*value = CCtxParams->fParams.contentSizeFlag;
|
||||||
break;
|
break;
|
||||||
@ -2068,9 +2058,10 @@ MEM_STATIC size_t ZSTD_compressSequences_internal(seqStore_t* seqStorePtr,
|
|||||||
/* Compress literals */
|
/* Compress literals */
|
||||||
{ const BYTE* const literals = seqStorePtr->litStart;
|
{ const BYTE* const literals = seqStorePtr->litStart;
|
||||||
size_t const litSize = seqStorePtr->lit - literals;
|
size_t const litSize = seqStorePtr->lit - literals;
|
||||||
|
int const disableLiteralCompression = (cctxParams->cParams.strategy == ZSTD_fast) && (cctxParams->cParams.targetLength > 0);
|
||||||
size_t const cSize = ZSTD_compressLiterals(
|
size_t const cSize = ZSTD_compressLiterals(
|
||||||
&prevEntropy->huf, &nextEntropy->huf,
|
&prevEntropy->huf, &nextEntropy->huf,
|
||||||
cctxParams->cParams.strategy, cctxParams->disableLiteralCompression,
|
cctxParams->cParams.strategy, disableLiteralCompression,
|
||||||
op, dstCapacity,
|
op, dstCapacity,
|
||||||
literals, litSize,
|
literals, litSize,
|
||||||
workspace, bmi2);
|
workspace, bmi2);
|
||||||
@ -2967,10 +2958,9 @@ size_t ZSTD_compress_usingDict(ZSTD_CCtx* cctx,
|
|||||||
const void* dict, size_t dictSize,
|
const void* dict, size_t dictSize,
|
||||||
int compressionLevel)
|
int compressionLevel)
|
||||||
{
|
{
|
||||||
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, srcSize ? srcSize : 1, dict ? dictSize : 0);
|
ZSTD_parameters const params = ZSTD_getParams(compressionLevel, srcSize + (!srcSize), dict ? dictSize : 0);
|
||||||
ZSTD_CCtx_params cctxParams = ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
|
ZSTD_CCtx_params cctxParams = ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
|
||||||
assert(params.fParams.contentSizeFlag == 1);
|
assert(params.fParams.contentSizeFlag == 1);
|
||||||
ZSTD_CCtxParam_setParameter(&cctxParams, ZSTD_p_compressLiterals, compressionLevel>=0);
|
|
||||||
return ZSTD_compress_advanced_internal(cctx, dst, dstCapacity, src, srcSize, dict, dictSize, cctxParams);
|
return ZSTD_compress_advanced_internal(cctx, dst, dstCapacity, src, srcSize, dict, dictSize, cctxParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3293,8 +3283,7 @@ static size_t ZSTD_resetCStream_internal(ZSTD_CStream* cctx,
|
|||||||
const ZSTD_CDict* const cdict,
|
const ZSTD_CDict* const cdict,
|
||||||
ZSTD_CCtx_params const params, unsigned long long const pledgedSrcSize)
|
ZSTD_CCtx_params const params, unsigned long long const pledgedSrcSize)
|
||||||
{
|
{
|
||||||
DEBUGLOG(4, "ZSTD_resetCStream_internal (disableLiteralCompression=%i)",
|
DEBUGLOG(4, "ZSTD_resetCStream_internal");
|
||||||
params.disableLiteralCompression);
|
|
||||||
/* params are supposed to be fully validated at this point */
|
/* params are supposed to be fully validated at this point */
|
||||||
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
||||||
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
||||||
|
@ -181,7 +181,6 @@ struct ZSTD_CCtx_params_s {
|
|||||||
ZSTD_frameParameters fParams;
|
ZSTD_frameParameters fParams;
|
||||||
|
|
||||||
int compressionLevel;
|
int compressionLevel;
|
||||||
int disableLiteralCompression;
|
|
||||||
int forceWindow; /* force back-references to respect limit of
|
int forceWindow; /* force back-references to respect limit of
|
||||||
* 1<<wLog, even for dictionary */
|
* 1<<wLog, even for dictionary */
|
||||||
|
|
||||||
|
@ -961,7 +961,6 @@ static ZSTD_CCtx_params ZSTDMT_initJobCCtxParams(ZSTD_CCtx_params const params)
|
|||||||
jobParams.cParams = params.cParams;
|
jobParams.cParams = params.cParams;
|
||||||
jobParams.fParams = params.fParams;
|
jobParams.fParams = params.fParams;
|
||||||
jobParams.compressionLevel = params.compressionLevel;
|
jobParams.compressionLevel = params.compressionLevel;
|
||||||
jobParams.disableLiteralCompression = params.disableLiteralCompression;
|
|
||||||
|
|
||||||
return jobParams;
|
return jobParams;
|
||||||
}
|
}
|
||||||
@ -1222,8 +1221,8 @@ size_t ZSTDMT_initCStream_internal(
|
|||||||
const ZSTD_CDict* cdict, ZSTD_CCtx_params params,
|
const ZSTD_CDict* cdict, ZSTD_CCtx_params params,
|
||||||
unsigned long long pledgedSrcSize)
|
unsigned long long pledgedSrcSize)
|
||||||
{
|
{
|
||||||
DEBUGLOG(4, "ZSTDMT_initCStream_internal (pledgedSrcSize=%u, nbWorkers=%u, cctxPool=%u, disableLiteralCompression=%i)",
|
DEBUGLOG(4, "ZSTDMT_initCStream_internal (pledgedSrcSize=%u, nbWorkers=%u, cctxPool=%u)",
|
||||||
(U32)pledgedSrcSize, params.nbWorkers, mtctx->cctxPool->totalCCtx, params.disableLiteralCompression);
|
(U32)pledgedSrcSize, params.nbWorkers, mtctx->cctxPool->totalCCtx);
|
||||||
/* params are supposed to be fully validated at this point */
|
/* params are supposed to be fully validated at this point */
|
||||||
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
|
||||||
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
assert(!((dict) && (cdict))); /* either dict or cdict, not both */
|
||||||
|
@ -1052,12 +1052,6 @@ typedef enum {
|
|||||||
/* experimental parameters - no stability guaranteed */
|
/* experimental parameters - no stability guaranteed */
|
||||||
/* =================================================================== */
|
/* =================================================================== */
|
||||||
|
|
||||||
ZSTD_p_compressLiterals=1000, /* control huffman compression of literals (enabled) by default.
|
|
||||||
* disabling it improves speed and decreases compression ratio by a large amount.
|
|
||||||
* note : this setting is automatically updated when changing compression level.
|
|
||||||
* positive compression levels set ZSTD_p_compressLiterals to 1.
|
|
||||||
* negative compression levels set ZSTD_p_compressLiterals to 0. */
|
|
||||||
|
|
||||||
ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
|
ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
|
||||||
* even when referencing into Dictionary content (default:0) */
|
* even when referencing into Dictionary content (default:0) */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user