This file details the process of generating the hot section ordering file used by the gold linker. The first step is to collect data using perf (hf-prod-collect.sh). The data is used by the hfsort tool which generates the file hotfuncs.txt.
Prerequisites
- oss-performance
- HHVM sources
Go to the directory where the HHVM sources are. HHVM must be installed with debug symbols. HHVM_DIR = the install directory of HHVM
cd hhvm_src
./configure -DCMAKE_INSTALL_PREFIX=$HHVM_DIR -DCMAKE_BUILD_TYPE=RelWithDebInfo
make
sudo make installecho "-1" | sudo tee /proc/sys/kernel/perf_event_paranoidThe hf-prod-collect script uses perf to collect data. The script creates a nm file (hhvm.nm) with HHVM symbols and a zip file containing the perf data (perf.pds.gz). Both these files are located in the directory /tmp/hp-prof.
In this example we use the WordPress target to generate the file. The collection starts after the warmup is completed. We need to set some environment variables in order to change the default behavior of hf-prod-collect.sh
SLEEP_TIME: time to profile (should be no more than the time the benchmark runs)HHVM_BIN_PATH: path to HHVM binaryHHVM_PID: default behavior is to get the PID of the oldest running HHVM process. In our case, that will probably match the HHVM process runningperf.phpso we need to override that.
cd hphp/tools/hfsort
/usr/local/hhvm/HHVM-3.8.0/bin/hhvm ${OSS_PERFORMANCE_PATH}/perf.php \
--wordpress \
--i-am-not-benchmarking \
--profBC \
--exec-after-warmup="SLEEP_TIME=60 HHVM_BIN_PATH=${HHVM_BIN_PATH} HHVM_PID=\`pgrep -n hhvm\` hf-prod-collect.sh > dump_hfprod.txt 2>&1 &" \
--hhvm=${HHVM_BIN_PATH} \
--hhvm-extra-arguments "-vEval.KeepPerfPidMap=true -vEval.ProfileHWEnable=false"
Running hfsort will generate the file hotfuncs.txt in the working directory.
hfsort /tmp/hf-prof/hhvm.nm /tmp/hf-prof/perf.pds.gzWhen calling configure, you can specify which file to use at link time (SECTION_ORDERING_FILE).
./configure -DCMAKE_INSTALL_PREFIX=$HHVM_DIR -DSECTION_ORDERING_FILE=$FILE_PATH/hotfuncs.txt