VSWAPPER: a Memory Swapper for Virtualized Environments
Total Page:16
File Type:pdf, Size:1020Kb
VSWAPPER: A Memory Swapper for Virtualized Environments Nadav Amit Dan Tsafrir Assaf Schuster Technion – Israel Institute of Technology {namit,dan,assaf}@cs.technion.ac.il Abstract 1. Introduction The number of guest virtual machines that can be consoli- The main enabling technology for cloud computing is ma- dated on one physical host is typically limited by the mem- chine virtualization, which abstracts the rigid physical in- ory size, motivating memory overcommitment. Guests are frastructure and turns it into soft componentseasily managed given a choice to either install a “balloon” driver to coordi- and used. Clouds and virtualization are driven by strong eco- nate the overcommitment activity, or to experience degraded nomic incentives, notably the ability to consolidate multiple performance due to uncooperative swapping. Ballooning, guest servers on one physical host. The number of guests however, is not a complete solution, as hosts must still fall that one host can support is typically limited by the physi- back on uncooperative swapping in various circumstances. cal memory size [4, 23, 25, 85]. So hosts overcommit their Additionally, ballooning takes time to accommodate change, memory to increase their capacity. and so guests might experience degraded performance under Memory overcommitment of guest virtual machines is changing conditions. commonly done through a special “balloon” driver installed Our goal is to improve the performance of hosts when in the guest [82]. Balloons allocate pinned memory pages at they fall back on uncooperative swapping and/or operate the host’s request, thereby ensuring guests will not use them under changing load conditions. We find that the associ- so that they can be utilized for some other purpose. When a ated poor performance is caused by various types of su- balloon is “inflated”, it prompts the guest operating system perfluous swap operations, ruined swap file sequentiality, to do memory reclamation on its own, which often results in and uninformed prefetch decisions upon page faults. We ad- the guest swapping out some of its less used pages to disk. dress these problems by implementing VSWAPPER, a guest- Ballooning is a common-case optimization for memory agnostic memory swapper suited for virtual environments reclamation and overcommitment, but, inherently, it is not that allows efficient, uncooperative overcommitment. With a complete solution [26, 66, 82, 86]. Hosts cannot rely on inactive ballooning, VSWAPPER yields up to an orderof mag- guest cooperation, because: (1) clients may have disabled or nitude performance improvement. Combined with balloon- opted not to install the balloon [8, 51, 72]; (2) clients may ing, VSWAPPER can achieve up to double the performance have failed to install the balloon due to technical difficulties under changing load conditions. [75, 76, 77, 78, 79, 80, 81]; (3) balloons could reach their Categories and Subject Descriptors D.4.2 [Operating Sys- upper bound, set by the hypervisor (and optionally adjusted tems]: Storage Management—Virtual memory, Main mem- by clients) to enhance stability and to accommodate various ory, Allocation/deallocation strategies, Storage hierarchies guest limitations [12, 17, 57, 67, 73, 82]; (4) balloons might be unable to reclaim memory fast enough to accommodate General Terms Design, Experimentation, Measurement, the demand that the host must satisfy, notably since guest Performance memory swapping involves slow disk activity [29, 44, 82]; Keywords Virtualization; memory overcommitment;mem- and (5) balloons could be temporarily unavailable due to ory balloon; swapping; paging; page faults; emulation; vir- inner guest activity such as booting [82] or running high tual machines; hypervisor priority processes that starve guest kernel services. In all these cases, the host must resort to uncooperative swapping, Permission to make digital or hard copies of all or part of this work for personal or which is notorious for its poor performance (and which has classroom use is granted without fee provided that copies are not made or distributed motivated ballooning in the first place). for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the While operational, ballooning is a highly effective opti- author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or mization. But estimating the memory working set size of republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. guests is a hard problem, especially under changing condi- ASPLOS ’14, March 1–4, 2014, Salt Lake City, UT, USA. tions [25, 33, 43], and the act of transferring memory pages Copyright is held by the owner/author(s). Publication rights licensed to ACM. ACM 978-1-4503-2305-5/14/03. $15.00. from one guest to another is slow when the memory is over- http://dx.doi.org/10.1145/2541940.2541969 committed [13, 29, 34, 44]. Consequently, upon change, it takes time for the balloon manager to appropriately adjust in the guest’s virtual disk for future reference and discards the balloon sizes and to achieve good results. Hosts might them, thereby eliminating the root cause of silent writes, therefore rely on uncooperative swapping during this period, stale reads, decayed sequentiality, and false page anonymity. and so guests might experience degraded performance until The second component is the False Reads Preventer, which the balloon sizes stabilize. eliminates false reads by emulating faulting write instruc- We note in passing that the use of ballooning constitutes tions directed at swapped out pages. Instead of immediately a tradeoff that embodies both a benefit and a price. The ben- faulting-in the latter, the Preventer saves the written data in efit is the improved performance achieved through curbing a memory buffer for a short while, hoping the entire buffer the uncooperative swapping activity. Conversely, the price would fill up soon, which would then obviate the need to for clients is that they need to modify their guest operating read. We describe VSWAPPER in detail in Section 4. systems by installing host-specific software, which has vari- We evaluate VSWAPPER in Section 5 and find that when ous undesirable consequences such as burdening the clients, memory is tight VSWAPPER is typically significantly bet- being nonportable across different hypervisors, and entail- ter than baseline swapping and is oftentimes competitive ing a small risk of causing undesirable interactions between to ballooning. At its worst, VSWAPPER is respectively 1.1x new and existing software [37]. The price for vendors is that and 2.1x slower than baseline and ballooning. At its best, they need to put in the effort to support different drivers for VSWAPPER is respectively 10x and 2x faster than baseline every guest operating system kernel and version. (We spec- and ballooning, under changing load conditions. In all cases, ulate that, due to this effort, for example, there is no balloon combining VSWAPPER and ballooning yields performance driver available for OS X under KVM and VirtualBox, and comparable to the optimum. the latter supports ballooning for only 64-bit guests [15].) Finally, we discuss the related work in Section 6, outline Therefore, arguably, reducing the overheads of uncoopera- possible future work in Section 7, and conclude in Section 8. tive swapping could sway the decision of whether to employ ballooning or not. 2. Motivation Our goal in this paper is twofold. To provide a superior 2.1 The Benefit of Ballooning alternative to baseline uncooperative host swapping, to be used by hosts as a performant fall back for when balloons Current architectural support for machine virtualization al- cannot be used. And to enhance guests’ performance while lows the host operating system (OS) to manage the mem- ballooning is utilized under changing load conditions. We ory of its guest virtual machines (VMs) as if they were pro- motivate this goal in detail in Section 2. cesses, and it additionally allows the guest OSes to do their We investigate why uncooperative swapping degrades the own memory management for their internal processes, with- performance in practice and find that it is largely because of: out host involvement. (1) “silent swap writes” that copy unchanged blocks of data Hardware provides this capability by supporting a two- from the guest disk image to the host swap area; (2) “stale level address translation mechanism (Figure 1). The upper swap reads” triggered when guests perform explicit disk level is controlled by the guest and is comprised of page reads whose destination buffers are pages swapped out by tables translating “guest virtual addresses” to “guest physical the host; (3) “false swap reads” triggered when guests over- addresses”. The lower level is controlled by the host and write whole pages previously swapped out by the host while is comprised of tables translating guest physical addresses disregarding their old content (e.g., when copying-on-write); to “host physical addresses”. A guest physical address is (4) “decayed swap sequentiality” that causes unchanged of course not real in any sense. The host can (1) map it guest file blocks to gradually lose their contiguity while be- to some real memory page or (2) mark it as non-present, ing kept in the host swap area and thereby hindering swap which ensures the host will get a page fault if/when the guest prefetching; and (5) “false page anonymity” that occurs attempts to access the non-presentpage. Consequently,when when mislabeling guest pages backed by files as anonymous memory is tight, the host can temporarily store page content and thereby confusing the page reclamation algorithm. We on disk and read it back into memoryonly when handlingthe characterize and exemplify these problems in Section 3. corresponding page faults [60]. We denote the latter activity To address the problems, we design VSWAPPER, a guest- as uncooperative swapping, because the host can conduct it agnostic memory swapper to be used by hypervisors.