This recipe provides configuration steps to enable Intel® VTune™ Amplifier performance analysis for your PHP code running in the HHVM* environment.
Content expert: Denis Pravdin
Advanced Hotspots analysis was integrated into the generic Hotspots analysis starting with VTune Amplifier 2019, and is available via the Hardware Event-based Sampling collection mode.
This section lists the hardware and software tools used for the performance analysis scenario.
Application: test.php. The application is used as a demo and not available for download.
Virtual machine: HHVM*
Performance analysis tools:
- Intel VTune Amplifier 2018: Advanced Hotspots analysis
For trial VTune Amplifier downloads and product support, visit https://software.intel.com/en-us/vtune.
All the Cookbook recipes are scalable and can be applied to VTune Amplifier 2018 and higher. Slight version-specific configuration changes are possible.
Operating system: Linux*, Ubuntu* 16.04
CPU: Intel® processor code named Skylake
Enable the VTune Amplifier Support with HHVM and Run the App
Prerequisites: Make sure the hhvm-vtune-env.sh script (attached) used for this analysis provides the correct path to the VTune Amplifier installation directory on your machine. By default, the path is specified as AGENT_DIR=/opt/intel/vtune/. This script creates a directory for JIT files and sets paths to the VTune Amplifier agents.
Run the hhvm process with the test application specified:
./hhvm -v "Eval.JitUseVtuneAPI=true" ./test.php
The Eval.JitUseVtuneAPI=true option is used to enable the VTune Amplifier support for HHVM profiling.
Configure and Run the VTune Amplifier for the HHVM Profiling
This recipe explores a scenario with the VTune Amplifier attaching to a running PHP application for the analysis, which is also similar to the system-wide profiling. Performance profiling for an application in the Launch Application mode is not HHVM specific and does not require any additional configuration.
Launch the VTune Amplifier:
Click the New Project icon on the toolbar to create a new project.
In the Analysis Target tab, select the Attach to Process target type and specify hhvm as a Process name:
From the right pane, expand the Advanced section and specify path to the copy.sh script as a Custom collector option:
At the moment, the copy.sh script is required to automatically copy the collected data to the result directory as soon as the application run is terminated:
#!/bin/bash JIT_DIR=/tmp/jitdata if [ "$AMPLXE_COLLECT_CMD" = "stop" ]; then cp $JIT_DIR/* $AMPLXE_DATA_DIR fi
Make sure the JIT_DIR value specified in the copy.sh file matches the JIT_DIR value in the hhvm-vtune-env.sh script.
Switch to the Analysis Type tab and select the Advance Hotspots analysis type from the left pane and click Start to run the analysis.
To launch the analysis from the command line, enter:
./amplxe-cl -collect advanced-hotspots -custom-collector=/var/local/copy.sh --target-process=hhvm
For system-wide collection, enter:
./amplxe-cl -collect advanced-hotspots -custom-collector=/var/local/copy.sh --analyze-system -duration 10
When the analysis is complete, the VTune Amplifier opens the result in the Summary view:
Click the top hotspot branchy function to switch to the Bottom-up window for further analysis:
Double-click the hotspot function to view the source code and identify the hottest code line.