Install and run OSS Performance - PPC64/hhvm GitHub Wiki
OSS Performance is a benchmark suite. This suite includes a framework collection configured with a sample dataset designed to approximate an average installation to benchmark something near to real-world situations. This suite also includes some unrealistic microbenchmarks - comparing the results of these is fairly pointless, however they can still be useful to profile, to find optimization opportunities that may carry over to a real site.
This script configures and runs nginx, siege, and PHP7/HHVM over FastCGI, over a TCP socket. Configuration is as close to identical as possible.
The script will run 300 warmup requests, then as many requests as possible in 1 minute. Statistics are only collected for the second set of data.
Packages installation
Using sudo or as root user: (it is recommended that you run sudo apt-get update and sudo apt-get upgrade first, or you may receive errors)
sudo apt-get install nginx php php-cgi mysql-server mysql-client php-gd php-mysql php-mbstring php-xml siege
Important note: when installing nginx make sure you don't have something like an apache server running, since it uses the same port as nginx and causes the installation to fail.
Getting OSS Performance source-code
git clone https://github.com/hhvm/oss-performance
Next thing will need to install composer. To install composer go to https://getcomposer.org/download/ and follow the install instructions.
After download and install, run the following command:
php composer.phar install
Configure Nginx
Enable fast-cgi
Create a hhvm.conf
file in /etc/nginx
with the following content:
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Edit sites default
Open the file /etc/nginx/sites-enable/default
and edit server
variable to include hhvm.conf
. You configuration should be something like bellow:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www-word;
index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
include hhvm.conf;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?q=$uri&$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
}
Now restart nginx service: sudo service nginx restart
.
Configure HHVM
Ini Settings
You need to create two ini settings file to HHVM, php.ini
and server.ini
in /etc/hhvm
:
On php.ini
you have to put the following lines:
; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions
session.gc_maxlifetime = 1440
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
hhvm.hack.lang.auto_typecheck = 0
hhvm.jit = true
hhvm.jit_relocation_size = 0
Copy the following line to server.ini
; php options
pid = /var/run/hhvm/pid
; hhvm specific
hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
Create HHVM service
First create a hhvm service: sudo vim /etc/systemd/system/hhvm.service
and put the following lines:
[Unit]
Description=HipHop Virtual Machine
[Service]
ExecStart=/usr/local/bin/hhvm -m daemon -u nginx -c /etc/hhvm/server.ini
ExecStop=rm /var/run/hhvm.pid
PIDFile=/var/run/hhvm.pid
[Install]
WantedBy=multi-user.target
Create a service on init.d: sudo vim /etc/init.d/hhvm
:
#!/bin/sh
#
# /etc/init.d/hhvm -- startup script for HHVM FastCGI
#
### BEGIN INIT INFO
# Provides: hhvm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts The HHVM FastCGI Daemon
### END INIT INFO
# Author: Dominic Luechinger <[email protected]>
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="HHVM FastCGI Daemon"
NAME=hhvm
DAEMON=/usr/local/bin/hhvm
PIDFILE=/var/run/hhvm/pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Default values. This values can be overwritten in '/etc/default/hhvm'
CONFIG_FILE="/etc/hhvm/server.ini"
SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini"
RUN_AS_USER="www-data"
RUN_AS_GROUP="www-data"
ADDITIONAL_ARGS=""
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
DAEMON_ARGS="--config ${SYSTEM_CONFIG_FILE} \
--config ${CONFIG_FILE} \
--user ${RUN_AS_USER} \
--mode daemon \
-vPidFile=${PIDFILE} \
${ADDITIONAL_ARGS}"
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
check_run_dir() {
# Only perform folder creation, if the PIDFILE location was not modified
PIDFILE_BASEDIR=$(dirname ${PIDFILE})
# We might have a tmpfs /var/run.
if [ "/var/run/hhvm" = "${PIDFILE_BASEDIR}" ] && [ ! -d /var/run/hhvm ]; then
mkdir -p -m0755 /var/run/hhvm
chown $RUN_AS_USER:$RUN_AS_GROUP /var/run/hhvm
fi
}
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
touch $PIDFILE
chown $RUN_AS_USER:$RUN_AS_GROUP $PIDFILE
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
check_run_dir
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the #
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
check_run_dir
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
Install HHVM
If you compile from source you need to install hhvm on path. Just enter in checkout folder and do sudo make install
after make. Note: if you don't pass a prefix option this will be installed at /etc/local/bin
. If you pass a prefix and install it other than /etc/local/
you must edit the paths on files /etc/systemd/system/hhvm.service
and /etc/init.d/hhvm
.
After that you can restart hhvm: sudo service hhvm restart
.
Important: OSS-Performance will only run on hhvm in Release mode. If you need to run HHVM on Debug mode for some reason you must edit the file base/hhvm_config_check.php
on oss-performance checkout folder change:
'HHVM build type' =>
feature(ini_get('hhvm.build_type'), 'Release')
to
'HHVM build type' =>
feature(ini_get('hhvm.build_type'), 'Debug')
Note: you can run in Debug mode passing the option: --im-not-benchmarking
.
Running OSS Performance
You can run oss-performance by enter in checkout folder and do the following command:
hhvm perf.php --toys-fibonacci --hhvm=/usr/local/bin/hhvm
or alternatively you can run oss-performance with PHP:
hhvm perf.php --toys-fibonacci --php5=/usr/local/bin/php-cgi
This command will run fibonnaci benchmark. For others command line options please check the documentation at: https://github.com/hhvm/oss-performance/
Important: You may see some oss-performance error messages due TCP reuse or CPU frequency. Those are common troubles and the fixes are described at time_wait.md
and cpu-freq.md
files.
Only the following frameworks are supported on POWER:
--toys-fibonacci
--toys-hello-world
--mediawiki
--wordpress
--codeigniter-hello
The others frameworks will fail. For more details see: https://github.com/PPC64/hhvm/issues/130