Visible to Intel only — GUID: GUID-39C36306-26FF-4DD6-946D-BB585CDAE84B
Visible to Intel only — GUID: GUID-39C36306-26FF-4DD6-946D-BB585CDAE84B
Profiling Applications in Performance Monitoring Unit (PMU)-Enabled Google Cloud* Virtual Machines (NEW)
This recipe helps you set up a virtual machine (VM) instance in the Google Cloud Platform* to profile application performance with Intel® VTune™ Profiler.
Content Expert: Jennifer Dimatteo
Ingredients
Here are the hardware and software tools you need for this performance analysis.
Application: Use any application of your choice.
Tools: Intel® VTune™ Profiler version 2024 (or newer) - Hotspots analysis
Before You Begin
Understand the system requirements to install VTune Profiler on your machine. Your system must have at least 4 GB of RAM and 10 GB of free disk space.
Review the functionality of VTune Profiler available for different types of Google Cloud VMs.
Ensure that the instance of the virtual machine can support a connection over SSH (port 22).
The storage size for the root volume should be at least 10 GB for data collection and results.
Create and Configure a Virtual Machine Instance
Set up a virtual machine (VM). Follow instructions on the Google Cloud website.
Configure the VM Instance for Profiling
The General-purpose C4 type of VM does not enable the PMU by default. While you cannot enable the PMU in the Google GUI console, you can use the command line instead. To configure the PMU, follow instructions in Enable PMU in VMs.
As an example, this gcloud create command enables the PMU in the enhanced mode:
gcloud compute instances create c4pmu --machine-type=c4-standard-96 --performance-monitoring-unit=enhanced --zone=us-central1-b --create-disk=auto-delete=yes,boot=yes,device-name=instance-20240912-163331,image=projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20240830,mode=rw,provisioned-iops=3060,provisioned-throughput=155,size=50,type=hyperdisk-balanced
To enable the most functionality with VTune Profiler, choose the highest level of PMU access that is available for your VM.
For User-Mode sampling collections, set /proc/sys/kernel/yama/ptrace_scope to 0:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
For Hardware Event-Based sampling collections, set /proc/sys/kernel/perf_event_paranoid to 0:
echo 0 | sudo tee /proc/sys/kernel/perf_event_paranoid
For more information on driverless profiling, see Profiling Hardware without Intel Sampling Drivers.
Run Hotspots Analysis
Run a Hotspots analysis using one of these methods:
Use SSH to run a remote collection from VTune Profiler installed locally
Run VTune Profiler directly from the Google Cloud VM
Run VTune Profiler as a web service on the Google Cloud VM
Use SSH to run a remote collection from VTune Profiler installed locally:
Create a project in Intel® VTune™ Profiler.
In the WHERE pane of the Configure Analysis window, select Remote Linux(SSH).
Locate the public IPv4 DNS address for your instance:
In the SSH destination field, enter <VM user>@<public IPv4 for VM>.
Intel® VTune™ Profiler attempts to connect to the remote system to determine if the binaries necessary for data collection have been installed.
A separate command window opens, where you enter a password. Intel® VTune™ Profiler then creates its own SSH key and stores it in <user home>/.ssh. The SSH key is then copied to the authorized_keys file of the VM instance.
If you see a message that the product cannot be found on the target system, click Deploy to install.
In the WHAT pane, specify the location of your application and its working directory.
In the HOW pane, select Hotspots analysis with Hardware Event-Based Sampling collection.
Click to start the collection.
Once the analysis completes, Intel® VTune™ Profiler copies the results to your local system for analysis.
Run VTune Profiler directly from the Google Cloud VM:
Install VTune Profiler. Find installation information here.
Run VTune Profiler.
sudo <vtune_install_dir>/vtune_profiler/bin64/vtune-gui
Create a project.
In the Configure Analysis window,
In the WHERE pane, select Local Host.
In the WHAT pane, specify the location of your application and its working directory.
In the HOW pane, select a preferred collection mode for the Hotspots analysis. For example, select Hardware Event-Based Sampling.
Click to start the collection.
The analysis result opens in the Hotspots by CPU Utilization viewpoint.
Run VTune Profiler as a Web Service on the Google Cloud VM Instance:
Make sure that the VM firewall is configured to allow connections to the 8080 port. Learn more about firewalls.
Install VTune Profiler on the Google Cloud VM. Find installation information here.
Run the VTune Profiler Web Service:
<vtune_install_dir>/latest/bin64/vtune-backend –-allow-remote-access –-enable-server-profiling –-web-port=8080
The vtune-backend command returns a URL with the private IP for the instance as well as a one-time token.
Replace the private IP with the public IP or DNS for the instance.
For example, https://10.128.0.18:8080/?one-time-token=b8cafc89721e781161aba4ddcef5a718 becomes https://18.236.194.236:8080/?one-time-token=b8cafc89721e781161aba4ddcef5a718.
Copy the URL into your browser.
NOTE:The browser may display a warning indicating that the URL might be unsafe. This is because the web service is using a self-signed certificate instead of an officially signed certificate.Create a passphrase at the prompt and proceed to the VTune GUI.
In the Configure Analysis window,
In the WHERE pane, select Local Host.
In the WHAT pane, specify the location of your application and its working directory.
In the HOW pane, select a preferred collection mode for the Hotspots analysis. For example, select Hardware Event-Based Sampling.
Click to start the collection.
The analysis result opens in the Hotspots by CPU Utilization viewpoint.