Scott Drummonds on Virtualization

Your Performance Enemy: Host Swapping

1 Comment »

Three times in the past week I have engaged in challenging discussions on host memory swapping and its impact to performance.  If you read my article on host swapping and the whitepaper it summarized, you know the deleterious effect on performance caused by host swapping.  When reading the paper, one of our most astute customers saw a sentence that gave him pause:

ESX attempts to mitigate the impact of interacting with guest operating system memory management by randomly selecting the swapped guest physical pages.

This customer has read some of our other documentation and knows that the vSphere client and esxtop report active and touched memory, each representing a kind of working set.  “So,” the customer asks me, “if ESX is keeping working sets, why would choose swap pages randomly instead of selecting inactive pages outside of the working set?”  If ESX could choose only inactive pages then the penalty due to host swapping would drop greatly.

As it turns out, ESX does not track working sets.  For ESX to know which pages are actively being read it would have to trap every memory access, which would greatly hurt performance.  Instead, we track a small sample of the host’s memory–exactly 100 pages–to extrapolate the size of active memory.  Because sample-based calculations are accurate with the square of the sample size, a 100 page sample delivers a very high accuracy of active memory.  But, because it is only a sample, the activity on the great majority of pages is a mystery.

This means that ESX has absolutely no information on the read and write behavior of most memory on the system.  Guest operating systems fare no better in tracking working sets.  But because they can categorize pages based on usage–application heap, buffers for IO, kernel memory, etc.–guest OSes can make better decisions about which pages should be swapped and which should not.  For this reason the balloon driver can induce non-harmful guest paging which is superior to host swapping.

One Response

[…] Tags: memory, swap, vmkernel — Scott @ 6:15 pm Recently I have been thinking, talking, and writing about ESX host memory swapping a lot.  ESX swaps memory under the same conditions that traditional […]