Guest
physical
Guest
physical
Guest
physical
figure 1. the three different memory conservation techniques employed by Difference engine: page sharing, page patching, and
compression. in this example, five physical pages are stored in less than three machine memory pages for a savings of roughly 50%.
page 1
Guest
Virtual
page 1
Guest
physical
Machine
Memory
Machine
Memory
Machine
Memory
Machine
Memory
page 2
page 1
page 2
page 1
page 2
page 1
page 2
page 2
page 2
page 2
page 2
page 2
page 1
page 1
page 1
page 3
page 3
page 3
Identical to
page 3
Similar to
page 2
VM 2
VM 1
Identical to
page 3
Similar to
page 2
Identical to
page 3
Similar to
page 2
page 3
(a) Initial
(b) Page sharing
Similar to
page 2
page 3
(c) Patching
page 3
Identical to
page 3
VM 1
VM 2
Similar to
page 2
page 3
(d) Compression
page 3
Identical to
page 3
VM 1
VM 2
Similar to
page 2
page 3
used. In addition, reference pages for sharing or patching must be found quickly without introducing performance overhead. Difference Engine uses full-page hashes
and hash-based fingerprints to identify good candidates.
Finally, we implement a demand paging mechanism that
supplements main memory by writing VM pages to disk
to support overcommitment, allowing the total memory
required for all VMs to temporarily exceed the physical
memory capacity.
3. 1. Page sharing
Difference Engine’s implementation of content-based
page sharing is similar to those in earlier systems. We walk
through memory looking for identical pages. As we scan
memory, we hash each page and index it based on its hash
value. Identical pages hash to the same value and a collision
indicates that a potential matching page has been found.
We perform a byte-by-byte comparison to ensure that the
pages are indeed identical before sharing them.
Upon identifying target pages for sharing, we reclaim
one of the pages and update the virtual memory to point
at the shared copy. Both mappings are marked read-only,
so that writes to a shared page cause a page fault that will
be trapped by the VMM. The VMM returns a private copy
of the shared page to the faulting VM and updates the virtual memory mappings appropriately. If no VM refers to a
shared page, the VMM reclaims it and returns it to the free
memory pool.
3. 2. Patching
Traditionally, the goal of page sharing has been to elimi-
nate redundant copies of identical pages. Difference Engine
considers further reducing the memory required to store
similar pages by constructing patches that represent a page
as the difference relative to a reference page. To motivate
this design decision, we provide an initial study into the
potential savings due to subpage sharing, both within and
across virtual machines. First, we define the following two
heterogeneous workloads, each involving three 512MB vir-
tual machines:
• Mixed-1: Windows XP SP1 hosting RUBiS8; Debian 3. 1
compiling the Linux kernel; Slackware 10. 2 compiling
Vim 7.0 followed by a run of the lmbench
benchmark. 15
We designed these workloads to stress the memory-saving mechanisms since opportunities for identical page
sharing are reduced. In this first experiment, for a variety
of configurations, we suspend the VMs after completing a
benchmark, and consider a static snapshot of their memory to determine the number of pages required to store the
images using various techniques. Table 1 shows the results
of our analysis for the Mixed- 1 workload.
The first column breaks down these 393,120 pages into
three categories: 149,038 zero pages (i.e., the page contains all zeros), 52,436 sharable pages (the page is not all
zeros, and there exists at least one other identical page),
and 191,646 unique pages (no other page in memory is
exactly the same). The second column shows the number
of pages required to store these three categories of pages
table 1. effectiveness of page sharing across three 512mB Vms
running Windows XP, Debian, and Slackware Linux using 4KB pages.
Pages initial after Sharing after Patching
unique 191,646 191,646
Sharable
(non-zero)
52,436 3,577
Zero
Total
reference
Patchable
149,038
393,120
1
195,224
50,727
144,497
88,422
50,727
37,695