From 2e91dde43e3ef09cde7ee967316a3af427fcfe8d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 8 Mar 2016 12:22:11 +0100 Subject: [PATCH 1/6] improved memory size evaluation by paramgrill --- lib/zstd_compress.c | 19 +++++++++++++++++-- programs/.gitignore | 4 +++- programs/paramgrill.c | 7 +++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/zstd_compress.c b/lib/zstd_compress.c index 50979ce5..b668a934 100644 --- a/lib/zstd_compress.c +++ b/lib/zstd_compress.c @@ -129,7 +129,7 @@ size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx) return 0; /* reserved as a potential error code in the future */ } -seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx) +seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx) /* hidden interface */ { return ctx->seqStore; } @@ -170,11 +170,26 @@ void ZSTD_validateParams(ZSTD_parameters* params) } +size_t ZSTD_sizeofCCtx(ZSTD_parameters params) /* hidden interface, for paramagrill */ +{ /* copy / pasted from ZSTD_resetCCtx_advanced */ + const size_t blockSize = MIN(BLOCKSIZE, (size_t)1 << params.windowLog); + const U32 contentLog = (params.strategy == ZSTD_fast) ? 1 : params.contentLog; + const U32 divider = (params.searchLength==3) ? 3 : 4; + const size_t maxNbSeq = blockSize / divider; + const size_t tokenSpace = blockSize + 8*maxNbSeq; + const size_t tableSpace = ((1 << contentLog) + (1 << params.hashLog) + (1 << params.hashLog3)) * sizeof(U32); + const size_t optSpace = ((1<