Join the community today
Become a Member

Nginx Guide To GCC & Clang Compiler Selection For Nginx Installs

Discussion in 'Centmin Mod Insights' started by eva2000, Jan 15, 2018.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    32,419
    7,192
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,945
    Local Time:
    4:00 PM
    Nginx 1.13.x
    MariaDB 5.5

    Guide To GCC & Clang Compiler Selection For Nginx Installs



    Centmin Mod 123.09beta01 LEMP stack can allow users to optionally select their own choice of compilers for Nginx and PHP-FPM. Below is example for Nginx where you can choose between native CentOS GCC version, GCC 5.3.1, GCC 6.3.1, GCC 7.2.1, Clang 3.4.2, Clang 4.0.1 and soon GCC 8.0 and Clang 5.0 & Clang 6.0. As discussed here, depending on pairing of compiler and specific cpu model, you can get better Nginx or PHP-FPM performance usually between 5-10%. Which may offset some of the performance loss due to Linux Kernel Page Table Isolation updates to fix Meltdown/Spectre vulnerabilities :)

    Below is a list of persisent config file /etc/centminmod/custom_config.inc variables controlling which compiler and version is used for GCC or Clang compilers with Nginx + switching from default LibreSSL 2.6.4 to OpenSSL 1.1.0g. You set these variables BEFORE you run centmin.sh menu option 4 to recompile your Nginx versions.

    You can check nginx -V output's built by line for details.

    For GCC 8.0 - note experimental and not enabled in public Centmin Mod 123.09beta01 code yet and undergoing private testing right now.
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='n'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='y'
    NGINX_DEVTOOLSETGCC='y'
    

    For GCC 7.2.1
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='n'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='y'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

    For GCC 6.3.1
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='n'
    DEVTOOLSETSIX='y'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

    For GCC 5.3.1
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='n'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

    For GCC 4.8.5 native CentOS 7.4 OS provided
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='n'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='n'
    

    For Clang 3.4.2
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG='y'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='n'
    

    For Clang 4.0.1 add CLANG_FOUR='y'
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG_FOUR='y'
    CLANG='y'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

    For Clang 5.0.1 add CLANG_FIVE='y' - note experimental and not enabled in public Centmin Mod 123.09beta01 code yet and undergoing private testing right now
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG_FIVE='y'
    CLANG='y'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

    For Clang 6.0.0 add CLANG_SIX='y' - note experimental and not enabled in public Centmin Mod 123.09beta01 code yet and undergoing private testing right now
    Code (Text):
    LIBRESSL_SWITCH='n'
    CLANG_SIX='y'
    CLANG='y'
    DEVTOOLSETSIX='n'
    DEVTOOLSETSEVEN='n'
    DEVTOOLSETEIGHT='n'
    NGINX_DEVTOOLSETGCC='y'
    

     
  2. eva2000

    eva2000 Administrator Staff Member

    32,419
    7,192
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,945
    Local Time:
    4:00 PM
    Nginx 1.13.x
    MariaDB 5.5
    Doing some quick Siege static web serving benchmarks on 2 cpu thread OpenVZ VPS server which sports an Intel E5-1650v3 @3.50Ghz processor running Centmin Mod 123.09beta01 on CentOS 7.4 64bit.

    Siege test paramaters and changing comment marker for each respective GCC version tested
    Code (Text):
    comment='gcc8'
    siege -b -d1s -c100 -r500 -m $comment http://localhost | tee "siege-${comment}-$(date +"%d%m%y-%H%M%S").log"
    

    Results running each Nginx + GCC pairing through 3x runs of Siege benchmarking and average of 3 runs shown.

    Notes:
    • These are just quick tests as the results aren't entirely accurate as you probably need to do more than 3x runs and being on OpenVZ virtualized server means you're subject to noisy neighbours and resource contention still.
    • Do not take these results as gospel as performance depends on your compiler + cpu model pairing. You may have a different cpu model and that may perform differently to below results. Finding the right compiler + cpu pairing is part of the fun :D

    siege-chart-gcc8-nginx-140118-01.png
     
    • Like Like x 1
Thread Status:
Not open for further replies.