HipHop for PHPãã¤ã³ã¹ãã¼ã«ãã¦ã¿ã
FacebookãéçºããPHPããC++ã«å¤æãããã¼ã«ãHipHop for PHPããã¤ã³ã¹ãã¼ã«ãã¦ã¿ãã
ã
ã¤ã³ã¹ãã¼ã«
極åyumã§å ¥ããã
# install php 5.2 yum -y install apr apr-util gmp yum -y install --enablerepo=c5-testing --disablerepo=base,updates php php-cli php-common php-mbstring php-pear python-devel # install dependency yum -y install --enablerepo=rpmforge cmake gcc-c++ gcc44 gcc44-c++ flex bison re2c mysql mysql-devel libxml2 libxml2-devel libmcrypt libmcrypt-devel php-mcrypt openssl binutils binutils-devel libcap libcap-devel gd zlib bzip2 bzip2-libs bzip2-devel pcre pcre-devel expat expat-devel gd gd-devel openldap openldap-devel readline readline-devel libc-client libc-client-devel ncurses ncurses-devel pam pam-devel # install tbb cd /usr/local/src/ wget http://www.threadingbuildingblocks.org/uploads/78/146/2.2%20update%202/tbb22_012oss_lin.tgz tar -xvf tbb22_012oss_lin.tgz mv tbb22_012oss /usr/local/ export TBB_INSTALL_DIR="/usr/local/tbb22_012oss" export TBB_ARCH_PLATFORM="intel64/cc4.1.0_libc2.4_kernel2.6.16.21" # install libmbfl yum -y install libtool git clone git://github.com/scottmac/libmbfl.git cd libmbfl/ ./buildconf ./configure make make install # install oniguruma cd /usr/local/src/ wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.2.tar.gz tar -xvf onig-5.9.2.tar.gz cd onig-5.9.2 ./configure make make install # download hiphop cd /usr/local/src/ git clone git://github.com/facebook/hiphop-php.git # install libcurl cd /usr/local/src/ wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2 tar -xvf curl-7.20.0.tar.bz2 cp hiphop-php/src/third_party/libcurl.fb-changes.diff curl-7.20.0/ cd curl-7.20.0 sed -i 's/curl-old\///g' libcurl.fb-changes.diff sed -i 's/curl-new\///g' libcurl.fb-changes.diff patch -p0 < libcurl.fb-changes.diff ./configure --with-ssl --with-zlib --with-libidn --enable-sspi --enable-ldap --enable-ldaps make make install # install libevent cd /usr/local/src/ wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz tar -xvf libevent-1.4.13-stable.tar.gz cp hiphop-php/src/third_party/libevent-1.4.13.fb-changes.diff libevent-1.4.13-stable/ cd libevent-1.4.13-stable sed -i 's/libevent-1.4.13-stable\///g' libevent-1.4.13.fb-changes.diff sed -i 's/libevent-1.4.13-stable-fb\///g' libevent-1.4.13.fb-changes.diff patch -p0 < libevent-1.4.13.fb-changes.diff ./configure make make install # install memcached cd /usr/local/src/ wget http://packages.sw.be/perl-Net-SSLeay/perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm yum -y install perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm yum -y install --enablerepo=rpmforge memcached # install libmemcache cd /usr/local/src/ wget http://download.tangent.org/libmemcached-0.43.tar.gz tar -xvf libmemcached-0.43.tar.gz cd libmemcached-0.43 ./configure make make install # install libicu cd /usr/local/src/ wget http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz tar xvf icu4c-4_2_1-src.tgz cd icu/source chmod +x runConfigureICU configure install-sh ./runConfigureICU Linux gmake gmake install # install boost cd /usr/local/src/ wget 'http://downloads.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.45.0%2F&ts=1293050553&use_mirror=jaist' tar -xvf boost_1_45_0.tar.bz2 cd boost_1_45_0 export CC=gcc44 export CXX=g++44 ./bootstrap.sh --prefix=/usr/local ./bjam ./bjam --prefix=/usr/local install # install hiphop cd /usr/local/src/ cd hiphop-php/ export HPHP_HOME=`pwd` export HPHP_LIB=`pwd`/bin export CC=gcc44 export CXX=g++44 cmake . make make install
ã
ã³ã³ãã¤ã«
ãã echoããã ãããã¤ã¾ããªãããåã«ä½ã£ãHTTP_OAuthProviderã®ãµã³ãã«ãåããã¦ã¿ãã
/usr/local/srcã«ç½®ãã£ã±ãªããªã®ã¯ãã¨ããããæ°ã«ããªãã
# /usr/local/src/hiphop-php/src/hphp/hphp `find . -name '*.php'` --keep-tempdir=1 --log=3 --include-path=. --include-path=/usr/share/pear running hphp... creating temporary directory /tmp/hphp_DGs7aM ... parsing inputs... parsing inputs took 0'00" (83 ms) wall time pre-optimizing... pre-optimizing took 0'00" (100 ms) wall time inferring types... inferring types took 0'00" (40 ms) wall time post-optimizing... post-optimizing took 0'00" (17 ms) wall time creating CPP files... creating CPP files took 0'00" (339 ms) wall time saving code errors... compiling and linking CPP files... compiling and linking CPP files took 4'21" (261282 ms) wall time all files saved in /tmp/hphp_DGs7aM ... running hphp took 4'22" (262053 ms) wall time
ã
ãµã¼ãèµ·å
åããã
# /tmp/hphp_DGs7aM/program -m server mapping self... mapping self took 0'04" (4334 ms) wall time loading static content... loading static content took 0'00" (0 ms) wall time page server started admin server started all servers started
ã
æ°ãã¤ããç¹
ã«ã¬ã³ããã£ã¬ã¯ããªä»¥å¤ããèªã¿è¾¼ãã©ã¤ãã©ãªï¼Pearã¨ãï¼ã§ãFactoryMethodãã¿ã¼ã³ã¨ã使ã£ã¦ãincludeãããã¨ãã¦ãPHPãã¡ã¤ã«ãis_file()ãã¦ãã¨å¿
ãfalseãè¿ã£ã¦ãã¾ããï¼æ¡å¼µåãcppã ããï¼
å®éã«ã¢ã¯ã»ã¹ãã¦ã¿ãã¨ãã³ã³ã½ã¼ã«ã«ãã°ãåºã¦ãã
HipHop Notice: Tried to invoke /usr/share/pear/HTTP/OAuthProvider/Store/CacheLite.php but file not found.
ã
使ããªãé¢æ°
get_magic_quotes_runtime
set_magic_quotes_runtime
eval
ã
(set|get)_magic_quotes_runtimeã¯ãPearã§ãã使ããã¦ããããPearã®ã©ã¤ãã©ãªã®ä¸èº«ããããå¿
è¦ãããããã
æåæã£ã¦ãããã¯é¢åèããªãããã ãã©ãæç´ãã¯å¿
è¦ãªã¬ãã«ã
ã
ãã³ããã¼ã¯
ABã§http://127.0.0.1/consumer_http_oauthconsumer.phpã¸ãªã¯ã¨ã¹ããè¡ãã
consumer_http_oauthconsumer.phpã¯ã3legged_request.phpã«å¯¾ãã¦HTTPãªã¯ã¨ã¹ããè¡ãã
3legged_request.phpã¯ãèªè¨¼ãã§ãã¯ãã¦ãªã¯ã¨ã¹ããã¼ã¯ã³ãçºè¡ããã
ã
Apacheã®æ¹ãé¥ãã«éãâ¦ï¼
OAuthèªè¨¼ã®å ´åãCã§å®è£
ãããé¢æ°ã大éã«ä½¿ã£ã¦ããããªã®ããã
Smartyã¨ãViewãå«ãã æ®éã®Webã¢ããªã±ã¼ã·ã§ã³ãªãéãã®ããã
ãã¨ã¯ãã¼ããå¾
ã¡åãã¦ãããã°ã©ã ã®å·®ãªã®ããã
ããã«ãã¦ã4åã¨ã¯ãããããã«ã
ã
HipHop for PHP
# ab -n 1000 -c 100 http://127.0.0.1/consumer_http_oauthconsumer.php This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Finished 1000 requests Server Software: Server Hostname: 127.0.0.1 Server Port: 80 Document Path: /consumer_http_oauthconsumer.php Document Length: 519 bytes Concurrency Level: 100 Time taken for tests: 95.260325 seconds Complete requests: 1000 Failed requests: 980 (Connect: 0, Length: 980, Exceptions: 0) Write errors: 0 Total transferred: 664794 bytes HTML transferred: 351794 bytes Requests per second: 10.50 [#/sec] (mean) Time per request: 9526.032 [ms] (mean) Time per request: 95.260 [ms] (mean, across all concurrent requests) Transfer rate: 6.81 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 2 8.7 0 38 Processing: 18 9382 2001.9 10003 10073 Waiting: 16 9380 2001.6 10001 10073 Total: 32 9385 1997.4 10003 10098 Percentage of the requests served within a certain time (ms) 50% 10003 66% 10011 75% 10017 80% 10020 90% 10036 95% 10052 98% 10064 99% 10073 100% 10098 (longest request)
ã
Apache
# ab -n 1000 -c 100 http://127.0.0.1/consumer_http_oauthconsumer.php This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Finished 1000 requests Server Software: Apache/2.2.8 Server Hostname: 127.0.0.1 Server Port: 80 Document Path: /consumer_http_oauthconsumer.php Document Length: 507 bytes Concurrency Level: 100 Time taken for tests: 23.967652 seconds Complete requests: 1000 Failed requests: 894 (Connect: 0, Length: 894, Exceptions: 0) Write errors: 0 Total transferred: 896892 bytes HTML transferred: 508892 bytes Requests per second: 41.72 [#/sec] (mean) Time per request: 2396.765 [ms] (mean) Time per request: 23.968 [ms] (mean, across all concurrent requests) Transfer rate: 36.51 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 5.9 0 23 Processing: 79 2376 3796.3 1126 23926 Waiting: 79 1989 2820.5 1111 14996 Total: 79 2378 3801.2 1126 23948 Percentage of the requests served within a certain time (ms) 50% 1126 66% 1218 75% 1309 80% 1387 90% 7765 95% 8484 98% 20845 99% 21469 100% 23948 (longest request)
ã
ç°å¢
OS : CentOS 5.5 64bit on XenServer
VCPU : 1
MEM : 1GB
ã
åèURL
HipHopã®ãã«ãã¨ã¤ã³ã¹ãã¼ã«æ¹æ³(å訳) : candycane development blog
http://blog.candycane.jp/archives/295
ã
ã¤ãã«å
¬éï¼Facebook-HipHop-PHP - ãªããæ°å¦è
ã«ã¯ã¯ã¤ã³å¥½ããå¤ã
http://d.hatena.ne.jp/tullio/20100221/1266760473
ã
HipHop for PHP ã¤ã³ã¹ãã¼ã«ãã° - modules/mod_girl.so
http://d.hatena.ne.jp/mod_girl/20101020/1287558769