Hi everyone
I was reading through the wiki
https://pve.proxmox.com/wiki/Performance_Tweaks#Disk_Cache
have some questions and maybe even suggestions for improvement. Sometimes it also contradicts the points from the article it references to.
I'm no expert by any means and not a native speaker, so please don't take these suggestions as an insult. I could be very wrong on some basic understandings
Because it is a complex topic, I like to number the different points.
1. Maybe start with an exclaimer that for a secure writeback you need the barrier-passing feature. That feature is enabled by default on ext4
2. Do NTFS or ZFS guests also support write barriers by default?
3. The wiki says this only applies to RAW, but I was unable to find good documentation how these caching modes behave for qcow2. Anyone has some inputs?
4. The table is a little bit confusing to newcomers. I think simpler to understand by splitting up the Host Page Cache into read and write and what data can be lost in a power failure. Also I would replace "power loss" with "unexpected shutdown" because that covers more incidents than can happen.
5. Rename the mode "none" to "no cache" or "Default (no cache)", because that is how the GUI shows it
6. The description for cache=none says: "Because the actual storage device may report a write as completed when placed in its write queue only". For what device is that true? Are we talking about the drive firmware lying? I had this discussion in a TrueNAS forum, where I asked how we can trust HDDs to not have writes in a queue and the general consent was that there is no drive lying about having writes written while they are still in cache no matter if SSD or HDD. Otherwise the outrage would be even bigger than the SMR fiasko from WD. That is why I would ditch the "in case of power failure you can lose data"
7. "cache=none seems to be the best performance", can that really be true? Compared to other modes, it is just not using cache and directly talking to the disk, how can that be the best performance?
8. Reorder the modes to match the order of the GUI
9. According to the notes, directsync is the safest option. But why? Write through behaves the same but with a read cache, how is that less secure?
Here is how I as a beginner would write that wiki entry:
default (No Cache) is the default since Proxmox 2.X.
Direct Sync
Write through
Write Back
Write Back (unsafe)
I was reading through the wiki
https://pve.proxmox.com/wiki/Performance_Tweaks#Disk_Cache
have some questions and maybe even suggestions for improvement. Sometimes it also contradicts the points from the article it references to.
I'm no expert by any means and not a native speaker, so please don't take these suggestions as an insult. I could be very wrong on some basic understandings
Because it is a complex topic, I like to number the different points.
1. Maybe start with an exclaimer that for a secure writeback you need the barrier-passing feature. That feature is enabled by default on ext4
2. Do NTFS or ZFS guests also support write barriers by default?
3. The wiki says this only applies to RAW, but I was unable to find good documentation how these caching modes behave for qcow2. Anyone has some inputs?
4. The table is a little bit confusing to newcomers. I think simpler to understand by splitting up the Host Page Cache into read and write and what data can be lost in a power failure. Also I would replace "power loss" with "unexpected shutdown" because that covers more incidents than can happen.
5. Rename the mode "none" to "no cache" or "Default (no cache)", because that is how the GUI shows it
6. The description for cache=none says: "Because the actual storage device may report a write as completed when placed in its write queue only". For what device is that true? Are we talking about the drive firmware lying? I had this discussion in a TrueNAS forum, where I asked how we can trust HDDs to not have writes in a queue and the general consent was that there is no drive lying about having writes written while they are still in cache no matter if SSD or HDD. Otherwise the outrage would be even bigger than the SMR fiasko from WD. That is why I would ditch the "in case of power failure you can lose data"
7. "cache=none seems to be the best performance", can that really be true? Compared to other modes, it is just not using cache and directly talking to the disk, how can that be the best performance?
8. Reorder the modes to match the order of the GUI
9. According to the notes, directsync is the safest option. But why? Write through behaves the same but with a read cache, how is that less secure?
Here is how I as a beginner would write that wiki entry:
Mode | Proxmox Page cache read | Proxmox Page cache write | Disk Write | data loss from unexpected shutdowns? | Notes |
---|---|---|---|---|---|
default (No Cache) | disabled | disabled | normal behavior | Only async writes | Normal read performance Normal write performance Safe with enabled host barrier support |
Direct Sync | disabled | disabled | forces sync | No | Normal read performance Slow write performance, because even async writes are written as sync writes. Safe even without host barrier support. |
Write through | enabled | disabled | forces sync | No | Good read performance, because of cache Slow write performance, because even async writes are written as sync writes Safe even without host barrier support |
Write back | enabled | enabled | normal behavior | Only async writes | Good read performance Normal write performance Safe with enabled barrier support |
Write back (unsafe) | enabled | enabled | ignores flush | Yes | Good read performance Good write performance for sync writes Very unsafe! Not recommended! |
default (No Cache) is the default since Proxmox 2.X.
- host page cache is not used
- In case of a power failure, you could loose async writes
- You need to use the barrier option in your Linux guest to avoid FS corruption in case of power failure.
This mode causes qemu-kvm to interact with the disk image file or block device with O_DIRECT semantics, so the host page cache is bypassed and I/O happens directly between the qemu-kvm userspace buffers and the storage device. The guest is expected to send down flush commands as needed to manage data integrity. Equivalent to direct access to your hosts' disk, performance wise.
Direct Sync
- host page cache is not used
- guest disk cache mode is writethrough
- similar to Write through, an fsync is made for each write.
This mode causes qemu-kvm to interact with the disk image file or block device with both O_DSYNC and O_DIRECT semantics, where writes are reported as completed only when the data has been committed to the storage device, and when it is also desirable to bypass the host page cache. Like cache=writethrough, it is helpful to guests that do not send flushes when needed. It was the last cache mode added, completing the possible combinations of caching and direct access semantics.
Write through
- host page cache is used as read cache
- guest disk cache mode is writethrough
- similar to Direct Sync, an fsync is made for each write.
This mode causes qemu-kvm to interact with the disk image file or block device with O_DSYNC semantics, where writes are reported as completed only when the data has been committed to the storage device. The host page cache is used in what can be termed a writethrough caching mode. Guest virtual storage adapter is informed that there is no writeback cache, so the guest would not need to send down flush commands to manage data integrity. The storage behaves as if there is a writethrough cache.
Write Back
- host page cache is used as read & write cache
- guest disk cache mode is writeback
- In case of a power failure, you could loose async writes
- You need to use the barrier option in your Linux guest to avoid FS corruption in case of power failure.
This mode causes qemu-kvm to interact with the disk image file or block device with neither O_DSYNC nor O_DIRECT semantics, so the host page cache is used and writes are reported to the guest as completed when placed in the host page cache, and the normal page cache management will handle commitment to the storage device. Additionally, the guest's virtual storage adapter is informed of the writeback cache, so the guest would be expected to send down flush commands as needed to manage data integrity.
Write Back (unsafe)
- as Write Back, but ignores flush commands from the guest!
- Warning: No data integrity even if the guest is sending flush commands. Not recommended for production use.
Last edited: