From: Yann Collet Date: Fri, 8 Apr 2016 00:02:12 +0000 (+0200) Subject: faster level 1 at 256 KB X-Git-Tag: v0.6.0^2~17^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dbf2874eed427047951e0fae6292d19e9f563b8;p=thirdparty%2Fzstd.git faster level 1 at 256 KB --- diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index e6b13ca3e..1a02f63c3 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -2642,6 +2642,7 @@ size_t ZSTD_compress_usingPreparedCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* prepare } { size_t const cSize = ZSTD_compressContinue(cctx, dst, dstCapacity, src, srcSize); if (ZSTD_isError(cSize)) return cSize; + { size_t const endSize = ZSTD_compressEnd(cctx, (char*)dst+cSize, dstCapacity-cSize); if (ZSTD_isError(endSize)) return endSize; return cSize + endSize; @@ -2749,7 +2750,7 @@ static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEV { /* for srcSize <= 256 KB */ /* W, C, H, S, L, T, strat */ { 0, 0, 0, 0, 0, 0, ZSTD_fast }, /* level 0 */ - { 18, 14, 15, 1, 6, 4, ZSTD_fast }, /* level 1 */ + { 18, 13, 14, 1, 6, 4, ZSTD_fast }, /* level 1 */ { 18, 14, 16, 1, 5, 4, ZSTD_fast }, /* level 2 */ { 18, 14, 17, 1, 5, 4, ZSTD_fast }, /* level 3.*/ { 18, 14, 15, 4, 4, 4, ZSTD_greedy }, /* level 4 */ diff --git a/lib/zstd_decompress.c b/lib/zstd_decompress.c index a85ee2b5c..914d14117 100644 --- a/lib/zstd_decompress.c +++ b/lib/zstd_decompress.c @@ -751,23 +751,21 @@ static size_t ZSTD_decompressSequences( const BYTE* ip = (const BYTE*)seqStart; const BYTE* const iend = ip + seqSize; BYTE* const ostart = (BYTE* const)dst; - BYTE* op = ostart; BYTE* const oend = ostart + maxDstSize; + BYTE* op = ostart; const BYTE* litPtr = dctx->litPtr; const BYTE* const litLimit_8 = litPtr + dctx->litBufSize - 8; const BYTE* const litEnd = litPtr + dctx->litSize; - U32* DTableLL = dctx->LLTable; - U32* DTableML = dctx->MLTable; - U32* DTableOffb = dctx->OffTable; + FSE_DTable* DTableLL = dctx->LLTable; + FSE_DTable* DTableML = dctx->MLTable; + FSE_DTable* DTableOffb = dctx->OffTable; const BYTE* const base = (const BYTE*) (dctx->base); const BYTE* const vBase = (const BYTE*) (dctx->vBase); const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd); int nbSeq; /* Build Decoding Tables */ - { size_t const seqHSize = ZSTD_decodeSeqHeaders(&nbSeq, - DTableLL, DTableML, DTableOffb, - ip, seqSize); + { size_t const seqHSize = ZSTD_decodeSeqHeaders(&nbSeq, DTableLL, DTableML, DTableOffb, ip, seqSize); if (ZSTD_isError(seqHSize)) return seqHSize; ip += seqHSize; } @@ -779,29 +777,19 @@ static size_t ZSTD_decompressSequences( memset(&sequence, 0, sizeof(sequence)); sequence.offset = REPCODE_STARTVALUE; - for (U32 i=0; i 200802300) && (pos < 200802400)) - printf("Dpos %6u :%5u literals & match %3u bytes at distance %6u \n", - pos, (U32)sequence.litLength, (U32)sequence.matchLength, (U32)sequence.offset); - } -#endif - oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litLimit_8, base, vBase, dictEnd); - if (ZSTD_isError(oneSeqSize)) return oneSeqSize; - op += oneSeqSize; - } + { size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litLimit_8, base, vBase, dictEnd); + if (ZSTD_isError(oneSeqSize)) return oneSeqSize; + op += oneSeqSize; + } } /* check if reached exact end */ if (nbSeq) return ERROR(corruption_detected); @@ -839,11 +827,11 @@ static size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx, if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong); /* Decode literals sub-block */ - { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize); - if (ZSTD_isError(litCSize)) return litCSize; - ip += litCSize; - srcSize -= litCSize; } - + { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize); + if (ZSTD_isError(litCSize)) return litCSize; + ip += litCSize; + srcSize -= litCSize; + } return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize); } diff --git a/programs/paramgrill.c b/programs/paramgrill.c index 8749e6a38..3dcb2e102 100644 --- a/programs/paramgrill.c +++ b/programs/paramgrill.c @@ -983,8 +983,7 @@ int main(int argc, char** argv) if (argc<1) { badusage(exename); return 1; } - for(i=1; i= '0') && (argument[0]<= '9')) { - proba32 *= 10; - proba32 += argument[0] - '0'; - argument++; - } + { U32 proba32 = 0; + while ((argument[0]>= '0') && (argument[0]<= '9')) + proba32 = (proba32*10) + (*argument++ - '0'); g_compressibility = (double)proba32 / 100.; } break; @@ -1082,8 +1077,7 @@ int main(int argc, char** argv) g_params.strategy = (ZSTD_strategy)(*argument++ - '0'); continue; case 'L': - { - int cLevel = 0; + { int cLevel = 0; argument++; while ((*argument>= '0') && (*argument<='9')) cLevel *= 10, cLevel += *argument++ - '0'; @@ -1100,25 +1094,20 @@ int main(int argc, char** argv) case 'T': argument++; g_target = 0; - while ((*argument >= '0') && (*argument <= '9')) { - g_target *= 10; - g_target += *argument - '0'; - argument++; - } + while ((*argument >= '0') && (*argument <= '9')) + g_target = (g_target*10) + (*argument++ - '0'); break; /* cut input into blocks */ case 'B': - { - g_blockSize = 0; - argument++; - while ((*argument >='0') && (*argument <='9')) - g_blockSize *= 10, g_blockSize += *argument++ - '0'; - if (*argument=='K') g_blockSize<<=10, argument++; /* allows using KB notation */ - if (*argument=='M') g_blockSize<<=20, argument++; - if (*argument=='B') argument++; - DISPLAY("using %u KB block size \n", g_blockSize>>10); - } + g_blockSize = 0; + argument++; + while ((*argument >='0') && (*argument <='9')) + g_blockSize = (g_blockSize*10) + (*argument++ - '0'); + if (*argument=='K') g_blockSize<<=10, argument++; /* allows using KB notation */ + if (*argument=='M') g_blockSize<<=20, argument++; + if (*argument=='B') argument++; + DISPLAY("using %u KB block size \n", g_blockSize>>10); break; /* Unknown command */ @@ -1126,7 +1115,7 @@ int main(int argc, char** argv) } } continue; - } + } /* if (argument[0]=='-') */ /* first provided filename is input */ if (!input_filename) { input_filename=argument; filenamesStart=i; continue; }