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