# intel compiler で Apache が 400% 高速化 - URL: https://www.drk7.jp/MT/archives/000772.html - 公開: 2005.03.17 / 最終更新: 2005.09.24 - カテゴリ: Installノウハウ - 著者: drk ![intel compiler で Apache が 400% 高速化のイメージ(挿絵)](https://www.drk7.jp/media/opt/posts/000772/illust.jpg.w1600.webp) 「[無料で30%のパフォーマンスUP!! - intel compiler](https://www.drk7.jp/MT/archives/000767.html)」でも書いた intel compiler ですが、今度は Apache 1.3.33 + mod_perl 1.29 を再構築してみました。 apache bench で速度を測ってみたら、ナント 400% も高速化していました。( ̄□ ̄;)ナント!! 本当かぁ??と思って数回試してみましたが、結果は同じでした。スゴイ! 以下、インストールメモと apache bench のログです。 ## icc で Apache + mod_perl を再構築する やっていることは次の通りです。 1. /usr/bin/gcc を gcc.bk に退避して、icc へのシンボリックリンクに差し替える。 2. /usr/local/src/icc に Apache 1.3.33 と mod_perl 1.0 系の最新版 (1.29) のソースを取ってきて展開する。 3. mod_perl を、既に入っている Apache の apxs を使って (USE_APXS=1) ビルドしてインストールする。最適化オプションは OPTIMIZE で渡します。 4. Apache 本体を CC=icc と CFLAGS を指定して configure し、ビルドしてインストールする。 5. 最後に gcc のシンボリックリンクを消して、退避しておいた本物の gcc を元に戻す。 icc に渡している最適化オプションは mod_perl も Apache も同じで、-O3 -tpp7 -xWNB -axWNB -ip です。 Apache のモジュールは、so と rewrite を有効にして、userdir / status / asis / imap / auth / include / setenvif / negotiation は外しています。 ``` mv /usr/bin/gcc /usr/bin/gcc.bk ln -s /opt/intel_cc_80/bin/icc /usr/bin/gcc mkdir /usr/local/src/icc cd /usr/local/src/icc wget http://www.meisei-u.ac.jp/mirror/apache/dist/httpd/apache_1.3.33.tar.gz tar xvfz apache_1.3.33.tar.gz cd /usr/local/src/icc wget http://perl.apache.org/dist/mod_perl-1.0-current.tar.gz tar xvfz mod_perl-1.0-current.tar.gz cd mod_perl-1.29 perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/local/apache/bin/apxs EVERYTHING=1 OPTIMIZE="-O3 -tpp7 -xWNB -axWNB -ip" make make install cd /usr/local/src/icc cd apache_1.3.33 CC=icc CFLAGS="-O3 -tpp7 -xWNB -axWNB -ip" LIBS=-lpthread ./configure --prefix=/usr/local/apache --enable-module=so \ --enable-module=rewrite \ --disable-module=userdir \ --disable-module=status \ --disable-module=asis \ --disable-module=imap \ --disable-module=auth \ --disable-module=include \ --disable-module=setenvif \ --disable-module=negotiation make make install rm -rf /usr/bin/gcc mv /usr/bin/gcc.bk /usr/bin/gcc ``` で Apache + mod_perl を再構築。 ## apache bench で速度を測る テスト用に、リダイレクトするだけの CGI を作成します。 ``` echo 'print "Location: http://www.drk7.jp/MT/\n\n";' > index.cgi chmod 755 index.cgi ``` この CGI に対して ab を実行しました。 ``` /usr/local/apache/bin/ab -n 100 -c 10 http://localhost/index.cgi ``` ## 計測結果 gcc バージョン ``` Requests per second: 129.98 [#/sec] (mean) Time per request: 76.933 [ms] (mean) Time per request: 7.693 [ms] (mean, across all concurrent requests) Transfer rate: 57.19 [Kbytes/sec] received ``` icc バージョン ``` Requests per second: 473.69 [#/sec] (mean) Time per request: 21.111 [ms] (mean) Time per request: 2.111 [ms] (mean, across all concurrent requests) Transfer rate: 208.42 [Kbytes/sec] received ``` 並べてみるとこうなります。 | 項目 | gcc バージョン | icc バージョン | | - | - | - | | Requests per second (1秒あたりの処理リクエスト数) | 129.98 | 473.69 | | Time per request (1リクエストあたりの時間) | 76.933 ms | 21.111 ms | | Time per request (同時接続分をならした値) | 7.693 ms | 2.111 ms | | Transfer rate (転送速度) | 57.19 Kbytes/sec | 208.42 Kbytes/sec | Requests per second が 129.98 から 473.69 へ。1リクエストあたりの時間も 76.933 ms から 21.111 ms に縮んでいます。 ## 追記(2005年3月18日) icc でコンパイルしたモノを動かす際には、必要となる環境変数を /opt/intel_cc_80/bin/iccvars.sh で設定しなければなりません。/etc/init.d/httpd の中でこれを読み込んでおかないと、 ``` /usr/local/apache/bin/httpd: error while loading shared libraries: libimf.so: cannot open shared object file: No such file or directory ``` というエラーでプロセスが落ちますのでご注意を。