From d228b6b0d0c83cbec268f4917fe3480bccdf362c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Fri, 29 Dec 2017 19:14:18 +0100 Subject: [PATCH] btlazy2 : optimization for dictionary compression we want the dictionary table to be fully sorted, not just lazily filled. Dictionary loading is a bit more intensive, but it saves cpu cycles for match search during compression. --- lib/compress/zstd_compress.c | 6 +----- tests/playTests.sh | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 4e05e287..32d15116 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -1950,11 +1950,7 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_CCtx* zc, const void* src, size_t ZSTD_insertAndFindFirstIndex(zc, iend-HASH_READ_SIZE, zc->appliedParams.cParams.searchLength); break; - case ZSTD_btlazy2: - if (srcSize >= HASH_READ_SIZE) - ZSTD_updateDUBT(zc, iend-HASH_READ_SIZE, iend, zc->appliedParams.cParams.searchLength); - break; - + case ZSTD_btlazy2: /* we want the dictionary table fully sorted */ case ZSTD_btopt: case ZSTD_btultra: if (srcSize >= HASH_READ_SIZE) diff --git a/tests/playTests.sh b/tests/playTests.sh index fa1efeb5..ee93b10a 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -322,9 +322,14 @@ $ECHO "- Create first dictionary " TESTFILE=../programs/zstdcli.c $ZSTD --train *.c ../programs/*.c -o tmpDict cp $TESTFILE tmp +$ECHO "- Dictionary compression roundtrip" $ZSTD -f tmp -D tmpDict $ZSTD -d tmp.zst -D tmpDict -fo result $DIFF $TESTFILE result +$ECHO "- Dictionary compression with btlazy2 strategy" +$ZSTD -f tmp -D tmpDict --zstd=strategy=6 +$ZSTD -d tmp.zst -D tmpDict -fo result +$DIFF $TESTFILE result if [ -n "$hasMT" ] then $ECHO "- Test dictionary compression with multithreading "