<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vPivot &#187; timekeeping</title>
	<atom:link href="http://vpivot.com/tag/timekeeping/feed/" rel="self" type="application/rss+xml" />
	<link>http://vpivot.com</link>
	<description>Scott Drummonds on Virtualization</description>
	<lastBuildDate>Wed, 01 Feb 2012 06:46:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Inaccuracy of In-guest Performance Counters</title>
		<link>http://vpivot.com/2010/02/10/inaccuracy-of-in-guest-performance-counters/</link>
		<comments>http://vpivot.com/2010/02/10/inaccuracy-of-in-guest-performance-counters/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 23:33:43 +0000</pubDate>
		<dc:creator>drummonds</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[perfmon]]></category>
		<category><![CDATA[scheduler]]></category>
		<category><![CDATA[timekeeping]]></category>
		<category><![CDATA[vmkernel]]></category>

		<guid isPermaLink="false">http://vpivot.com/?p=268</guid>
		<description><![CDATA[Every couple of months I receive a request for an explanation as to why performance counters in a virtual machine cannot be trusted.  While it is unfairly cynical to say that in-guest counters are never right, accurate capacity management and troubleshooting should rely on the counters provided by vSphere in either vCenter or esxtop.  The [...]]]></description>
			<content:encoded><![CDATA[<p>Every couple of months I receive a request for an explanation as to why performance counters in a virtual machine cannot be trusted.  While it is unfairly cynical to say that in-guest counters are never right, accurate capacity management and troubleshooting should rely on the counters provided by vSphere in either <a href="http://communities.vmware.com/docs/DOC-5600">vCenter</a> or <a href="http://communities.vmware.com/docs/DOC-9279">esxtop</a>.  The explanation is too short to merit a white paper but I hope a blog article will serve as the authoritative comment on the subject.</p>
<p><span id="more-268"></span>Usually this issue arises inside a new VMware customer or an established customer that has added new staff to the virtualization team.  In both cases the administrators are familiar with existing tools and require good reason to retool their thinking and environment around a new measurement system.</p>
<p>I was discussing the response to these concerns with my friend and colleague Kaushik Banerjee, the head of VMware&#8217;s outbound engineering group.  Kaushik and I spend a lot of time thinking about communicating technical details to our customers and in this case we chose different approaches to answer the question.  Both responses are complementary, so choose the one that suits your needs.</p>
<h2>Kaushik&#8217;s Approach: The Killer Examples</h2>
<p>Kaushik suggested that if we show cases where the guest OS&#8217;s counters were obviously wrong that a naturally suspicious VI admin would never trust the guest counters again.  To that end, I offer the following screen shots to make our point.</p>
<div id="attachment_285" class="wp-caption alignnone" style="width: 610px"><a href="http://vpivot.com/wp-content/uploads/2010/02/utilization_guest_higher.jpg"><img class="size-full wp-image-285" title="Guest Utilization Higher Than Host" src="http://vpivot.com/wp-content/uploads/2010/02/utilization_guest_higher.jpg" alt="Guest Utilization Higher Than Host" width="600" /></a><p class="wp-caption-text">Perfmon&#39;s counters show utilization higher in the guest than the host reports.</p></div>
<p>This screen shot shows two counters available in Perfmon inside a Windows guest with the <a href="http://vpivot.com/2009/09/17/using-perfmon-for-accurate-esx-performance-counters">vmStatsProvider</a> installed (available by default since vSphere).  The darker, red line is the CPU utilization as reported by the guest.  The lighter, greenish (?) line is CPU utilization of the virtual machine, from the host&#8217;s perspective.  This is the real CPU utilization passed up to the host by vmStatsProvider.  Notice how the host is always reporting higher utilization than the guest.  This is due to one of the reasons why guest counters cannot be trusted: they are unaware of hypervisor overheads.</p>
<p>This second screen shot shows a different case where the host utilization is lower than that reported by the guest.  Again, the dark red line represents the guest OS&#8217;s report of CPU utilization and the lighter line shows the real CPU utilization as reported by ESX.</p>
<div id="attachment_284" class="wp-caption alignnone" style="width: 610px"><a href="http://vpivot.com/wp-content/uploads/2010/02/utilization_host_higher.jpg"><img class="size-full wp-image-284" title="Host Utilization Higher Than Guest" src="http://vpivot.com/wp-content/uploads/2010/02/utilization_host_higher.jpg" alt="Host Utilization Higher Than Guest" width="600" /></a><p class="wp-caption-text">Perfmon&#39;s counters report a higher CPU utilization than ESX&#39;s.</p></div>
<p>The reason the host shows lower utilization than the guest is because the guest is unaware that it is only getting a fraction of the host&#8217;s CPU, time-sliced by ESX&#8217;s scheduler.  In this case the virtual machine was contending for CPU with other active virtual machines but this just the same principle would apply had a CPU limit been set.</p>
<h2>Scott&#8217;s Approach: A Detailed Explanation</h2>
<p>My approach to convincing VI admins to avoid guest tools is based on bottomless thirst for information that is common to technophiles.  If I can provide an explanation for the underlying system of resource scheduling and manipulation, then our admins will be able to deal with the guest counter issue and maybe solve other issues with their newfound knowledge.</p>
<p>There are four reasons why guest counters cannot be trusted:</p>
<ol>
<li>The guest is unaware of virtualization overheads.  As screen shot one showed above, the hypervisor will increase the CPU load as it virtualizes the hardware for the guest operating system.  That additional CPU work is not seeing by guest tools.</li>
<li>The guest is unaware that it is only seeing the portion of CPU that ESX&#8217;s scheduler is allowing it to see.  Because of contention or resource restrictions, virtual machines only get a slice of the CPU&#8217;s time.  When a guest thinks it is getting 100% of the CPU it may not know that the processor is being shared by eight other virtual machines.  See the second screen shot above.</li>
<li>Time skew in virtual machines can change the sample window for time-based counters.  This means that the guest may have measured 10 milliseconds of time passage during a read command when 12 milliseconds have elapsed.  This is more common on older versions of ESX and when the host CPU is saturated.  More on this below.</li>
<li>The virtual machines are unaware that they are being de-scheduled when idle, which means that they appear to be working more of the time than they are.  Consider a case where a virtual machine is idle 90% of the time.  If ESX does not schedule the VM during its idle time then the guest will think that its processor queues are full 100% of the time that it is being executed.</li>
</ol>
<p>The time drift explanation (item three) was historically the most problematic for VMware.  On older versions of our products time drift was common.  As ESX has matured we have reduced the amount of drift which has improved the accuracy of guest counters.  But the timer hardware is still being virtualized in software running on the host CPU.  This means that if host processor is fully utilized, the timer may not be scheduled on time, resulting in a delay in some ticks and a resultant skew in guest time.</p>
<h2>References</h2>
<p><a href="https://www.vmware.com/pdf/VI3.5_Performance.pdf">Performance Best Practices and Benchmarking Guidelines</a>.  This white paper was the last version that we printed that included benchmarking best practices, which contains some discussion on the need to measure performance from outside the host-under-test.</p>
<p><a href="http://www.vmware.com/pdf/vmware_timekeeping.pdf">Timekeeping in Virtual Machines</a>.  This document&#8211;not updated since VI3 but still accurate in its theory&#8211;will give the background on VMware-based time keeping and provide an explanation as to how skew can occur.</p>
<p><a href="http://www.vmware.com/files/pdf/perf-vsphere-cpu_scheduler.pdf">VMware vSphere™ 4: The CPU Scheduler in VMware® ESX™ 4</a>.  This white paper provides great detail how the scheduler works which will fully explains the notion of time slicing.</p>
]]></content:encoded>
			<wfw:commentRss>http://vpivot.com/2010/02/10/inaccuracy-of-in-guest-performance-counters/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

