VMware recently released a new whitepaper on memory management in VMware ESX and transparent page sharing (TPS) in particular.
ESX uses several techniques to utilize the physical memory such that a maximum number of virtual machines can run on a host without a significant decrease of performance. By attemping to get the best consolidation rate, the better the economics of the server and datacenter are.
Transparent page sharing is a technique in which identical blocks of virtual memory used in virtual machines guest operating systems are only stored once in the physical memory of the host. Just like de-duplication on storage systems and similar to for example the single instance store of Microsoft Exchange Server. The same attachment sent to multiple receivers is only stored once in the Exchange database. Mailboxes have pointers to the location in the database.
ESX will use idle CPU capacity to calculate hash of memory blocks to determine if memory blocks are identical. This will cost up to an estimated 5% of CPU capacity.
The decrease of physical memory consumption when Transparent Page Sharing is active depends on a lot of things. The reduction largely depends on the number of virtual machines, how different the guest operating systems used are and the type of application. And very important, the type of processor.
Nehalem and newer CPU uses large pages by default. ESX Transparent Page Sharing does not kick in when large pages are used by default. Only when there is memory contention TPS will become active to use the available physical memory as efficient as possible.
TPS can be enabled even when large pages are used, but this has an effect on performance.
The VMware whitepaper goes into deep technical detail on the inner workings of Transparent Page Sharing. It discusses TPS with small pages and large pages.
Download the whitepaper here.
vExpert Jason Boche wrote an interesting blog about TPS.