1 | <?xml version='1.0' encoding='UTF-8'?>
|
---|
2 | <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
|
---|
3 | <topic xml:lang="en-us" id="iocaching">
|
---|
4 | <title>Host Input/Output Caching</title>
|
---|
5 |
|
---|
6 | <body>
|
---|
7 | <p>
|
---|
8 | <ph conkeyref="vbox-conkeyref-phrases/product-name"/> can optionally disable the I/O caching that the
|
---|
9 | host OS would otherwise perform on disk image files.
|
---|
10 | </p>
|
---|
11 | <p>
|
---|
12 | Traditionally, <ph conkeyref="vbox-conkeyref-phrases/product-name"/> has opened disk image files as
|
---|
13 | normal files, which results in them being cached by the host OS
|
---|
14 | like any other file. The main advantage of this is speed: when the
|
---|
15 | guest OS writes to disk and the host OS cache uses delayed
|
---|
16 | writing, the write operation can be reported as completed to the
|
---|
17 | guest OS quickly while the host OS can perform the operation
|
---|
18 | asynchronously. Also, when you start a VM a second time and have
|
---|
19 | enough memory available for the OS to use for caching, large parts
|
---|
20 | of the virtual disk may be in system memory, and the VM can access
|
---|
21 | the data much faster.
|
---|
22 | </p>
|
---|
23 | <p>
|
---|
24 | Note that this applies only to image files. Buffering does not
|
---|
25 | occur for virtual disks residing on remote iSCSI storage, which is
|
---|
26 | the more common scenario in enterprise-class setups. See
|
---|
27 | <xref href="storage-iscsi.dita#storage-iscsi"/>.
|
---|
28 | </p>
|
---|
29 | <p>
|
---|
30 | While buffering is a useful default setting for virtualizing a few
|
---|
31 | machines on a desktop computer, there are some disadvantages to
|
---|
32 | this approach:
|
---|
33 | </p>
|
---|
34 | <ul>
|
---|
35 | <li>
|
---|
36 | <p>
|
---|
37 | Delayed writing through the host OS cache is less secure. When
|
---|
38 | the guest OS writes data, it considers the data written even
|
---|
39 | though it has not yet arrived on a physical disk. If for some
|
---|
40 | reason the write does not happen, such as power failure or
|
---|
41 | host crash, the likelihood of data loss increases.
|
---|
42 | </p>
|
---|
43 | </li>
|
---|
44 | <li>
|
---|
45 | <p>
|
---|
46 | Disk image files tend to be very large. Caching them can
|
---|
47 | therefore quickly use up the entire host OS cache. Depending
|
---|
48 | on the efficiency of the host OS caching, this may slow down
|
---|
49 | the host immensely, especially if several VMs run at the same
|
---|
50 | time. For example, on Linux hosts, host caching may result in
|
---|
51 | Linux delaying all writes until the host cache is nearly full
|
---|
52 | and then writing out all these changes at once, possibly
|
---|
53 | stalling VM execution for minutes. This can result in I/O
|
---|
54 | errors in the guest as I/O requests time out there.
|
---|
55 | </p>
|
---|
56 | </li>
|
---|
57 | <li>
|
---|
58 | <p>
|
---|
59 | Physical memory is often wasted as guest OSes typically have
|
---|
60 | their own I/O caches, which may result in the data being
|
---|
61 | cached twice, in both the guest and the host caches, for
|
---|
62 | little effect.
|
---|
63 | </p>
|
---|
64 | </li>
|
---|
65 | </ul>
|
---|
66 | <p>
|
---|
67 | If you decide to disable host I/O caching for the above reasons,
|
---|
68 | <ph conkeyref="vbox-conkeyref-phrases/product-name"/> uses its own small cache to buffer writes, but no
|
---|
69 | read caching since this is typically already performed by the
|
---|
70 | guest OS. In addition, <ph conkeyref="vbox-conkeyref-phrases/product-name"/> fully supports asynchronous
|
---|
71 | I/O for its virtual SATA, SCSI, and SAS controllers through
|
---|
72 | multiple I/O threads.
|
---|
73 | </p>
|
---|
74 | <p>
|
---|
75 | Since asynchronous I/O is not supported by IDE controllers, for
|
---|
76 | performance reasons, you may want to leave host caching enabled
|
---|
77 | for your VM's virtual IDE controllers.
|
---|
78 | </p>
|
---|
79 | <p>
|
---|
80 | For this reason, <ph conkeyref="vbox-conkeyref-phrases/product-name"/> enables you to configure whether
|
---|
81 | the host I/O cache is used for each I/O controller separately.
|
---|
82 | Either select the <b outputclass="bold">Use Host I/O
|
---|
83 | Cache</b> check box in the
|
---|
84 | <b outputclass="bold">Storage</b> settings for a given
|
---|
85 | virtual storage controller, or use the following
|
---|
86 | <userinput>VBoxManage</userinput> command to disable the host I/O
|
---|
87 | cache for a virtual storage controller:
|
---|
88 | </p>
|
---|
89 | <pre xml:space="preserve">VBoxManage storagectl "VM name" --name <controllername> --hostiocache off</pre>
|
---|
90 | <p>
|
---|
91 | See <xref href="vboxmanage-storagectl.dita"/>.
|
---|
92 | </p>
|
---|
93 | <p>
|
---|
94 | For the above reasons, <ph conkeyref="vbox-conkeyref-phrases/product-name"/> uses SATA controllers by
|
---|
95 | default for new virtual machines.
|
---|
96 | </p>
|
---|
97 | </body>
|
---|
98 |
|
---|
99 | </topic>
|
---|