📜 ⬆️ ⬇️

HipHop VM: battle exploration for Debian 7 + Nginx + Symfony2

Recently, a lot of “noise” around HipHop VM and kPHP : each social giant praises its brainchild. Most of all interested in a bunch, indicated in the title. It’s still too early to say anything about kPHP, although it is already known that the PLO is not supported. But HipHop VM is already possible to touch. Someone heard about this beast, some tried to install, some succeeded.

The topic describes the procedure for installing HipHop VM from source codes for Debian 7. Perhaps, this topic will save someone some time, nerves and help us step over the rake we went through.



  1. Test drive conditions
  2. Compilation
  3. Configuration and Startup
  4. Nginx setup
  5. Dry oars, sailed
  6. Tests
  7. findings
  8. Conclusion



1. Test drive conditions

DigitalOcian car for $ 5 / month:


2. Compile

Install HipHop VM from source, because No actual packages were found. The author of the HipHop VM package for Debian 7 (Wheezy) presented on GitHub no longer supports the package and its repository is not available (If you know where to find the HipHop VM package for Debian 7 - please write in the comments).
')
Download the HipHop VM source code from GitHub, set the environment variables and install the necessary packages:
mkdir /opt/dev cd /opt/dev git clone git://github.com/facebook/hiphop-php.git export CMAKE_PREFIX_PATH=`pwd`/.. export HPHP_HOME=`pwd` sudo apt-get update sudo apt-get install git-core cmake g++ libboost1.48-dev libmysqlclient-dev \ libxml2-dev libmcrypt-dev libicu-dev openssl build-essential binutils-dev \ libcap-dev libgd2-xpm-dev zlib1g-dev libtbb-dev libonig-dev libpcre3-dev \ autoconf libtool libcurl4-openssl-dev libboost-regex1.48-dev libboost-system1.48-dev \ libboost-program-options1.48-dev libboost-filesystem1.48-dev wget memcached \ libreadline-dev libncurses-dev libmemcached-dev libbz2-dev \ libc-client2007e-dev libgoogle-perftools-dev \ libcloog-ppl0 libelf-dev libdwarf-dev libunwind7-dev subversion 


Packages php5-mcrypt and php5-imagick , which mention the manuals do not install, because we don't need them.

Install third-party programs that will be needed during compilation and during the libevent patch patch from the HipHop VM:
 # libevent git clone git://github.com/libevent/libevent.git cd libevent git checkout release-1.4.14b-stable cat ../hiphop-php/hphp/third_party/libevent-1.4.14.fb-changes.diff | patch -p1 ./autogen.sh ./configure --prefix=$CMAKE_PREFIX_PATH make make install cd .. # curl git clone git://github.com/bagder/curl.git cd curl ./buildconf ./configure --prefix=$CMAKE_PREFIX_PATH make make install cd .. # glog svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog cd google-glog ./configure --prefix=$CMAKE_PREFIX_PATH make make install cd .. # jemaloc wget http://www.canonware.com/download/jemalloc/jemalloc-3.0.0.tar.bz2 tar xjvf jemalloc-3.0.0.tar.bz2 cd jemalloc-3.0.0 ./configure --prefix=$CMAKE_PREFIX_PATH make make install cd .. # libunwind wget 'http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz' tar -zxf libunwind-1.1.tar.gz cd libunwind-1.1 autoreconf -i -f ./configure --prefix=$CMAKE_PREFIX_PATH make install cd .. #   rm -rf libevent curl google-glog jemalloc-3.0.0.tar.bz2 jemalloc-3.0.0 libunwind-1.1 


Please note that libunwind version 1.1 has been installed. With version 1.0., Which is advised in manuals, cmake crashes.

Run the cmake utility:
 cd hiphop-php #    HPHP_HOME,  -  export HPHP_HOME=`pwd` cmake -D CMAKE_PREFIX_PATH=/opt/dev . 


In the CMAKE_PREFIX_PATH parameter, we transfer the directory in which the hiphop-php folder with the HipHop VM source codes is located, otherwise cmake crashes with an error (this is silent in the manuals).

Cross your fingers, run the compilation:
 make 

After a few minutes, the compilation crashes with this error:
[46%] Building CXX object hphp / CMakeFiles / hphp_runtime_static.dir / runtime / vm / bytecode.cpp.o c ++: internal compiler error: Killed (program cc1plus)
 Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions. make[2]: *** [hphp/CMakeFiles/hphp_runtime_static.dir/runtime/vm/bytecode.cpp.o] Error 4 make[1]: *** [hphp/CMakeFiles/hphp_runtime_static.dir/all] Error 2 make: *** [all] Error 2 


We delete the /opt/dev/hiphop-php/CMakeCache.txt file, increase the paging file to 1 GB and re-set the environment variables:
 export CMAKE_PREFIX_PATH=`pwd`/.. export HPHP_HOME=`pwd` 

Restart make and wait an hour and a half ...

3. Configuration and launch

Create a minimal HipHop VP configuration file with the following content:
/opt/dev/hiphop-php/config.hdf
 PidFile = /run/hiphop.pid Server { # ,        Port = 4849 #      SourceRoot = /var/www/www.mysymfony2site.com/web/ } #  ,     app.php VirtualHost { * { Pattern = .* RewriteRules { * { pattern = .* to = app.php qsa = true } } } } 


You can start the HipHop VM as a daemon with the following command:
 /opt/dev/hiphop-php/hphp/hhvm/hhvm --mode daemon --config /opt/dev/hiphop-php/hphp/config.hdf 

We run the HipHop VM server in the console in order to see all of its "mothers" at the time of debugging in real time:
 /opt/dev/hiphop-php/hphp/hhvm/hhvm --mode server --config /opt/dev/hiphop-php/hphp/config.hdf 


4. Configure Nginx

In the Nginx location, which is responsible for processing the dynamics, proxy the request to the HipHop VM:
 location ~ ^/(app|app_dev|config)\.php(/|$) { #   HipHop VP proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_pass http://localhost:4849; } 

5. Dry the oars, sailed

Open the Symfony2 configuration page www.mysymfony2site.com/config.php and see several problems and recommendations:



There is no intl extension, which is critical for us. It was not possible to find a way to deliver it (perhaps you will tell something about this).

Go ahead and open the main site www.mysymfony2site.com and see the following error message in the open console of the HipHop VP server:
request.CRITICAL ...
 request.CRITICAL: Doctrine\ODM\MongoDB\Mapping\MappingException: No identifier/primary key specified for Document 'Project\MyBundle\Document\Visitor'. Every Document must have an identifier/primary key. (uncaught exception) at /var/www/www.mysymfony2site.com/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/MappingException.php line 94 [] [] request.CRITICAL: Exception thrown when handling an exception (Doctrine\ODM\MongoDB\Mapping\MappingException: No identifier/primary key specified for Document 'Project\MyBundle\Document\Visitor'. Every Document must have an identifier/primary key.) [] [] 


The fact that HipHop VP does not support annotations was known, but it was decided to try for the following reasons:

Unfortunately, hopes were not justified. Perhaps with future releases the situation will change.

6. Tests

Since it so happened that the HipHop VM took off, but without Symfony2 on board, some testing was done. The script and load parameters are taken from a topic three years ago dedicated to HipHop-PHP. Conditions and objects of testing, of course, differ, but still, for the sake of curiosity ...
test.php
 <?php for($i = 0; $i < 1000; $i++) { echo var_dump($_SERVER); } 


The possibility of the influence of the database, to which the developers of HipHop VM often refer, is excluded. Appeals will be made through Nginx for greater proximity to reality:
 ab -n 1000 -c 5 http://www.mysymfony2site.com/test.php 

Hiphop vm
 Concurrency Level: 5 Time taken for tests: 24.912 seconds Complete requests: 1000 Failed requests: 97 (Connect: 0, Receive: 0, Length: 97, Exceptions: 0) Write errors: 0 Total transferred: 1588072000 bytes HTML transferred: 1587891000 bytes Requests per second: 40.14 [#/sec] (mean) Time per request: 124.558 [ms] (mean) Time per request: 24.912 [ms] (mean, across all concurrent requests) Transfer rate: 62254.02 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.3 0 7 Processing: 44 124 26.9 120 268 Waiting: 38 103 23.5 101 231 Total: 44 124 26.9 120 268 

PHP5-FPM + APC
 Concurrency Level: 5 Time taken for tests: 387.404 seconds Complete requests: 1000 Failed requests: 85 (Connect: 0, Receive: 0, Length: 85, Exceptions: 0) Write errors: 0 Total transferred: 4263063000 bytes HTML transferred: 4262907000 bytes Requests per second: 2.58 [#/sec] (mean) Time per request: 1937.018 [ms] (mean) Time per request: 387.404 [ms] (mean, across all concurrent requests) Transfer rate: 10746.28 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.5 0 10 Processing: 1163 1936 214.5 1865 3365 Waiting: 1 11 63.6 3 1371 Total: 1163 1936 214.6 1865 3365 


7. Conclusions

We look at the test results, draw conclusions.

8. Conclusion

Thank you all, good luck with screwing HipHop VM to your projects.

Source: https://habr.com/ru/post/189960/


All Articles