Skip to content
Permalink
Browse files

enable Cloudflare zlib performance library by default for Nginx zlib

- set CLOUDFLARE_ZLIB='y' by default. Very little risk as the routine now has error checking so if Cloudflare zlib library install fails, Centmin Mod will fall back to standard custom zlib 1.2.11 library install for Nginx zlib
- with Cloudflare zlib performance library usage, Nginx HTTP gzip compressed request performance can improve up to 29% over standard zlib 1.2.11 library
  • Loading branch information...
centminmod committed Feb 24, 2018
1 parent de48a18 commit 39c7610025cd8b6d817b476562b404551b6e59a9
Showing with 33 additions and 21 deletions.
  1. +1 −1 centmin.sh
  2. +32 −20 inc/zlib.inc
@@ -558,7 +558,7 @@ OPENSSL_VERSIONFALLBACK='1.0.2n' # fallback if OPENSSL_VERSION uses openssl 1.
OPENSSL_THREADS='y' # control whether openssl 1.1 branch uses threading or not
OPENSSL_CUSTOMPATH='/opt/openssl' # custom directory path for OpenSSL 1.0.2+
CLOUDFLARE_PATCHSSL='n' # set 'y' to implement Cloudflare's chacha20 patch https://github.com/cloudflare/sslconfig
CLOUDFLARE_ZLIB='n' # use Cloudflare optimised zlib fork https://blog.cloudflare.com/cloudflare-fights-cancer/
CLOUDFLARE_ZLIB='y' # use Cloudflare optimised zlib fork https://blog.cloudflare.com/cloudflare-fights-cancer/
CLOUDFLARE_ZLIBPHP='n' # use Cloudflare optimised zlib fork for PHP-FPM zlib instead of system zlib
CLOUDFLARE_ZLIBDEBUG='n' # make install debug verbose mode
CLOUDFLARE_ZLIBVER='1.3.0'
@@ -64,6 +64,20 @@ zlibng_install() {
}

install_cfzlib() {
if [[ "$CLOUDFLARE_ZLIB" = [yY] && "$(cat /proc/cpuinfo | grep -o 'sse4_2' | uniq)" = 'sse4_2' ]]; then
# disable clang compiler and switch to gcc compiler due to clang 3.4.2 errors when enabling
# cloudflare zlib
if [[ "$CLANG" = [yY] && "$CENTOS_SEVEN" -eq '7' ]]; then
CLANG='y'
CLANG_FOUR='y'
elif [[ "$CLANG" = [yY] && "$CENTOS_SIX" -eq '6' ]]; then
CLANG='n'
DEVTOOLSETSIX='y'
else
CLANG='n'
DEVTOOLSETSIX='y'
fi
install_cfzlibstartdir=$(pwd)
echo
echo "install zlib cloudflare..."
echo
@@ -88,35 +102,18 @@ install_cfzlib() {
# ps aufxwww > zlib-process.log
if [[ "$CLOUDFLARE_ZLIBDEBUG" = [Yy] ]]; then
make -d install
cfzlib_check=$?
if [[ "$(uname -m)" = 'x86_64' ]]; then
ln -sf /usr/local/zlib-cf/lib /usr/local/zlib-cf/lib64
fi
else
make install
cfzlib_check=$?
if [[ "$(uname -m)" = 'x86_64' ]]; then
ln -sf /usr/local/zlib-cf/lib /usr/local/zlib-cf/lib64
fi
fi
popd
}

nginxzlib_install() {
if [[ "$NGINX_ZLIBCUSTOM" = [yY] ]]; then
if [[ "$CLOUDFLARE_ZLIB" = [yY] && "$(cat /proc/cpuinfo | grep -o 'sse4_2' | uniq)" = 'sse4_2' ]]; then
# disable clang compiler and switch to gcc compiler due to clang 3.4.2 errors when enabling
# cloudflare zlib
if [[ "$CLANG" = [yY] && "$CENTOS_SEVEN" -eq '7' ]]; then
CLANG='y'
CLANG_FOUR='y'
elif [[ "$CLANG" = [yY] && "$CENTOS_SIX" -eq '6' ]]; then
CLANG='n'
DEVTOOLSETSIX='y'
else
CLANG='n'
DEVTOOLSETSIX='y'
fi
install_cfzlibstartdir=$(pwd)
install_cfzlib
cd install_cfzlibstartdir
if [ -f /usr/local/lib/libz.so ]; then
echo
@@ -206,7 +203,10 @@ nginxzlib_install() {
echo
echo "zlib cloudflare installed"
echo
else
fi
}

install_stdzlib() {
echo
echo "install zlib ${NGINX_ZLIBVER}..."
echo
@@ -310,6 +310,18 @@ nginxzlib_install() {
echo
echo "zlib ${NGINX_ZLIBVER} installed"
echo
}

nginxzlib_install() {
if [[ "$NGINX_ZLIBCUSTOM" = [yY] ]]; then
if [[ "$CLOUDFLARE_ZLIB" = [yY] && "$(cat /proc/cpuinfo | grep -o 'sse4_2' | uniq)" = 'sse4_2' ]]; then
install_cfzlib
if [[ "$cfzlib_check" -ne '0' ]]; then
CLOUDFLARE_ZLIB='n'
install_stdzlib
fi
else
install_stdzlib
fi
fi
}

0 comments on commit 39c7610

Please sign in to comment.
You can’t perform that action at this time.