Yichun Zhang (agentzh)
July 29, 2014 05:24PM
Hello!

On Tue, Jul 29, 2014 at 1:46 PM, Richard Stanway wrote:
> I recently came across a modified version of zlib with code contributed by
> Intel [1] that makes use of modern CPU instructions to increase performance.
> In testing, the performance gains seemed substantial, however when I tried
> to use this version with nginx, the following alert types appeared in the
> error_log on gzip requests:
>
[...]
>
> Is there a chance this version could be supported by nginx, or a
> configuration option made available to control the allocation size?
>

Well, I used to write a patch to enable IPP zlib (8.0) support in
NGINX (enabled by ./configure --with-ipp-zlib), just for your
reference:

# HG changeset patch
# User Yichun Zhang <agentzh@gmail.com>
# Date 1406668777 25200
# Tue Jul 29 14:19:37 2014 -0700
# Node ID 2a54efe7a747af2f70cb8af0cff62910d6b84a7f
# Parent c038cc33739bbfab2ed50819191298471f22d233
Gzip: added support for IPP zlib 8.0.

This feature can now be enabled by ./configure --with-zlib-ipp.

diff -r c038cc33739b -r 2a54efe7a747 auto/lib/zlib/conf
--- a/auto/lib/zlib/conf Fri Jul 25 14:43:29 2014 -0700
+++ b/auto/lib/zlib/conf Tue Jul 29 14:19:37 2014 -0700
@@ -6,6 +6,15 @@
if [ $ZLIB != NONE ]; then
CORE_INCS="$CORE_INCS $ZLIB"

+ if [ "$ZLIB_IPP" = YES ]; then
+cat << END
+
+$0: error: option --with-zlib-ipp conflicts with --with-zlib=<path>.
+
+END
+ exit 1
+ fi
+
case "$NGX_CC_NAME" in

msvc* | owc* | bcc)
@@ -53,18 +62,26 @@ else
ngx_feature_incs="#include <zlib.h>"
ngx_feature_path=
ngx_feature_libs="-lz"
+
ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
. auto/feature


if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
- ZLIB=YES
+
+ if [ "$ZLIB_IPP" = YES ]; then
+ have=NGX_HAVE_ZLIB_IPP . auto/have
+ ZLIB=IPP
+ else
+ ZLIB=YES
+ fi
+
ngx_found=no
fi
fi

- if [ $ZLIB != YES ]; then
+ if [ $ZLIB != YES -a $ZLIB != IPP ]; then
cat << END

$0: error: the HTTP gzip module requires the zlib library.
diff -r c038cc33739b -r 2a54efe7a747 auto/options
--- a/auto/options Fri Jul 25 14:43:29 2014 -0700
+++ b/auto/options Tue Jul 29 14:19:37 2014 -0700
@@ -133,6 +133,7 @@ SHA1_OPT=
SHA1_ASM=NO

USE_ZLIB=NO
+ZLIB_IPP=NO
ZLIB=NONE
ZLIB_OPT=
ZLIB_ASM=NO
@@ -299,6 +300,7 @@ use the \"--without-http_limit_conn_modu
--with-sha1-opt=*) SHA1_OPT="$value" ;;
--with-sha1-asm) SHA1_ASM=YES ;;

+ --with-zlib-ipp) ZLIB_IPP=YES ;;
--with-zlib=*) ZLIB="$value" ;;
--with-zlib-opt=*) ZLIB_OPT="$value" ;;
--with-zlib-asm=*) ZLIB_ASM="$value" ;;
diff -r c038cc33739b -r 2a54efe7a747 auto/summary
--- a/auto/summary Fri Jul 25 14:43:29 2014 -0700
+++ b/auto/summary Tue Jul 29 14:19:37 2014 -0700
@@ -65,6 +65,7 @@ esac

case $ZLIB in
YES) echo " + using system zlib library" ;;
+ IPP) echo " + using IPP zlib library" ;;
NONE) echo " + zlib library is not used" ;;
*) echo " + using zlib library: $ZLIB" ;;
esac
diff -r c038cc33739b -r 2a54efe7a747
src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c Fri Jul 25
14:43:29 2014 -0700
+++ b/src/http/modules/ngx_http_gzip_filter_module.c Tue Jul 29
14:19:37 2014 -0700
@@ -521,7 +521,18 @@ ngx_http_gzip_filter_memory(ngx_http_req
* *) 5920 bytes on amd64 and sparc64
*/

+#if NGX_HAVE_ZLIB_IPP
+ /* Below is from deflate.c in ipp-samples.8.0.0.005 */
+
+ if (wbits == 8) {
+ wbits = 9;
+ }
+
+ ctx->allocated = 8192 + 5 * (1 << (memlevel + 6)) + (1 << (wbits + 1))
+ + (1 << (wbits + 2)) + (1 << (memlevel + 9));
+#else
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
+#endif
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Support for 3rd party zlib libraries

Richard Stanway July 29, 2014 04:48PM

Re: Support for 3rd party zlib libraries

Yichun Zhang (agentzh) July 29, 2014 05:24PM

Re: Support for 3rd party zlib libraries

Richard Stanway July 29, 2014 06:48PM

Re: Support for 3rd party zlib libraries

Yichun Zhang (agentzh) July 29, 2014 07:08PM

Re: Support for 3rd party zlib libraries

Piotr Sikora July 29, 2014 07:10PM

Re: Support for 3rd party zlib libraries

Yichun Zhang (agentzh) July 29, 2014 07:16PM

Re: Support for 3rd party zlib libraries

Maxim Dounin July 29, 2014 08:06PM

Re: Support for 3rd party zlib libraries

Maxim Dounin July 29, 2014 10:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready