Skip to content

Commit

Permalink
enable Cloudflare zlib performance library by default for Nginx zlib
Browse files Browse the repository at this point in the history
- 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 39c7610
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion centmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
52 changes: 32 additions & 20 deletions inc/zlib.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -206,7 +203,10 @@ nginxzlib_install() {
echo
echo "zlib cloudflare installed"
echo
else
fi
}

install_stdzlib() {
echo
echo "install zlib ${NGINX_ZLIBVER}..."
echo
Expand Down Expand Up @@ -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.