lkml.org 
[lkml]   [2024]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv3 06/19] zram: pass estimated src size hint to zstd
Date
zram works with PAGE_SIZE buffers, so we always know exact
size of the source buffer and hence can pass estimated_src_size
to zstd_get_params().

This hint on x86_64, for example, reduces the size of the work
memory buffer from 1303520 bytes down to 90080 bytes. Given that
compression streams are per-CPU that's quite some memory saving.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/block/zram/backend_zstd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/zram/backend_zstd.c b/drivers/block/zram/backend_zstd.c
index 4da49626f110..4a7734aa1a8a 100644
--- a/drivers/block/zram/backend_zstd.c
+++ b/drivers/block/zram/backend_zstd.c
@@ -35,7 +35,7 @@ static void *zstd_create(void)
return NULL;

ctx->level = ZSTD_defaultCLevel();
- params = zstd_get_params(ctx->level, 0);
+ params = zstd_get_params(ctx->level, PAGE_SIZE);
sz = zstd_cctx_workspace_bound(&params.cParams);
ctx->cctx_mem = vzalloc(sz);
if (!ctx->cctx_mem)
@@ -65,7 +65,7 @@ static int zstd_compress(void *ctx, const unsigned char *src,
unsigned char *dst, size_t *dst_len)
{
struct zstd_ctx *zctx = ctx;
- const zstd_parameters params = zstd_get_params(zctx->level, 0);
+ const zstd_parameters params = zstd_get_params(zctx->level, PAGE_SIZE);
size_t ret;

ret = zstd_compress_cctx(zctx->cctx, dst, *dst_len,
--
2.45.0.rc1.225.g2a3ae87e7f-goog

\
 
 \ /
  Last update: 2024-05-08 09:44    [W:0.102 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site