[nginx] Gzip: compatibility with recent zlib-ng 2.2.x versions.
noreply at nginx.com
noreply at nginx.com
Thu Jan 9 13:20:02 UTC 2025
details: https://github.com/nginx/nginx/commit/57d54fd922e7ecbebb78598d13adc9df1a4b69c0
branches: master
commit: 57d54fd922e7ecbebb78598d13adc9df1a4b69c0
user: Sergey Kandaurov <pluknet at nginx.com>
date: Mon, 23 Dec 2024 17:57:45 +0400
description:
Gzip: compatibility with recent zlib-ng 2.2.x versions.
It now uses 5/4 times more memory for the pending buffer.
Further, a single allocation is now used, which takes additional 56 bytes
for deflate_allocs in 64-bit mode aligned to 16, to store sub-allocation
pointers, and the total allocation size now padded up to 128 bytes, which
takes theoretically 200 additional bytes in total. This fits though into
"4 * (64 + sizeof(void*))" additional space for ZALLOC used in zlib-ng
2.1.x versions. The comment was updated to reflect this.
---
src/http/modules/ngx_http_gzip_filter_module.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
index b55527845..7113df695 100644
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -516,8 +516,10 @@ ngx_http_gzip_filter_memory(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx)
/*
* Another zlib variant, https://github.com/zlib-ng/zlib-ng.
* It used to force window bits to 13 for fast compression level,
- * uses (64 + sizeof(void*)) additional space on all allocations
- * for alignment, 16-byte padding in one of window-sized buffers,
+ * used (64 + sizeof(void*)) additional space on all allocations
+ * for alignment and 16-byte padding in one of window-sized buffers,
+ * uses a single allocation with up to 200 bytes for alignment and
+ * internal pointers, 5/4 times more memory for the pending buffer,
* and 128K hash.
*/
@@ -526,7 +528,7 @@ ngx_http_gzip_filter_memory(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx)
}
ctx->allocated = 8192 + 16 + (1 << (wbits + 2))
- + 131072 + (1 << (memlevel + 8))
+ + 131072 + (5 << (memlevel + 6))
+ 4 * (64 + sizeof(void*));
ctx->zlib_ng = 1;
}
More information about the nginx-devel
mailing list