Some times we need to deeg deeper to understand what’s going on. Recently i was faced with a problem to tune a session consuming a lot of CPU power, so i begin by analysing the session stats and to get more info i decided to use the perf tools on the system level but it gives me nothing. After some checks it appears that the system was running on a virtual machine.
For more info on perf tool :
The first question is : Can we use perf tool to profile system performance on VMWARE ?
Hopefully,if your virtual machine use vSphere 5.1 than you are good to go. In fact the core performance counters can be accessed from within a virtual machine by using the Virtual Performance Monitor Counter (vPMC) feature.
Update 27/02/2015 : We can still use the other events (Software Event,TracePoint event,etc) without other configuration.(Example : perf top -e cpu-clock).So the restriction is only on the Hardware related events like Cycle,Instructions,etc.
The second question is : How to enable it ?
Of coure there are some prerequisite :
- VM compatibility is ESXi 5.1 and later.
- Verify that Intel VT-x or AMD-V is enabled in the BIOS so that hardware-assisted virtualization is possible.
- Intel Nehalem Generation (Xeon Core i7) or later processors or AMD Opteron Generation 3 (“Greyhound”) or later processors are installed.
- Enable vPMC in vSphere Web Client
- ESXi must not be in an EVC enabled DRS cluster
Also the behavior of the virtual performance counters across VMM ( Virtual Machine Manager) intercepts is configurable.During runtime of a VM instructions can be executed :
- directly on the guest
- by the hypervisor (VMM) on behalf of the guest (Ex :the CPUID instruction will trap into the VMM that will decode and emulate the guest CPUID instruction and increment the virtual instruction pointer, retiring the CPUID instruction using emulation. )
There is three mode identified by the value of the parameter “vpmc.freezeMode“: guest,vcpu,hybrid
For more info on this modes take a look at :
That’s it 😀