Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Hip HopHip Hop
Il compilatore PHP made in FacebookIl compilatore PHP made in Facebook
Linux Day 2010 PerugiaLinux Day 2010 Perugia
Paolo BernardiPaolo Bernardi
PHP the standard way
Text + PHP
Parser
Bytecode
Zend Engine II
PHP the standard way
Web Server
HTML request
HTML file
PHP request
PHP
PHP the cached way
Il bytecode viene rigenerato ad ogni richiesta... È uno spreco!!!
Bytecode caching (es. APC)
PHP the cached way
Se il sorgente PHP cambia troppo spesso il caching non è efficace
HipHop
2007, Haiping Zhao
PHP files
PHP the HipHop way
HipHop compiler
Web Server
PHP request
HTML file
HipHop compiler
PHP files
HipHop compiler
C++ files
Web server
C++ compiler
HipHop compiler
● Usa il g++
● Solo per x86_64
● Supporta PHP 5.2 (5.3 in progress)
● … salvo eval & co.
Funziona?
● 50% CPU time per pagine web
● 30% CPU time per API
Installazione (Ubuntu 10.10)
sudo aptget install gitcore cmake g++
libboostdev libmysqlclientdev libxml2dev
libmcryptdev libicudev openssl binutilsdev
libcapdev libgd2xpmdev zlib1gdev libtbbdev
libonigdev libpcre3dev autoconf libtool
libcurl4openssldev libboostsystemdev
libboostprogramoptionsdev libboost
filesystemdev wget memcached libreadlinedev
libncursesdev libmemcacheddev libicudev
libbz2dev
Installazione
A)mkdir hiphop
B)cd hiphop
C)git clone git://github.com/facebook/hiphop
php.git
D)cd hiphopphp
E)export CMAKE_PREFIX_PATH=`/bin/pwd`/../
F)export HPHP_HOME=`/bin/pwd`
G)export HPHP_LIB=`/bin/pwd`/bin
H)git submodule init
I)git submodule update
J)cd ..
Installazione
A)wget http://www.monkey.org/~provos/libevent
1.4.13stable.tar.gz
B)tar xzvf libevent1.4.13stable.tar.gz
C)cd libevent1.4.13stable
D)cp ../hiphopphp/src/third_party/libevent
1.4.13.fbchanges.diff .
E)patch p1 < libevent1.4.13.fbchanges.diff
F)./configure prefix=$CMAKE_PREFIX_PATH
G)make
H)make install
I)cd ..
Installazione (Ubuntu 10.10)
A)cd hiphopphp
B)cmake .
C)make
… semplice, non è vero?
Utilizzo
A)$ cd ..
B)$ export HPHP_HOME=`pwd`
C)$ export HPHP_LIB=`pwd`/bin
D)$ export CMAKE_PREFIX_PATH=$(pwd)/../
E)$ hphp/hphp test.php keeptempdir=1 log=3
F)$ /tmp/hphp_p6vSsP/program m server p 8080
G)$ hphpi/hphpi f test.php
That's all, folks!That's all, folks!