I would appreciate the addition of this option, which would cause files opened by rsync to be opened using the O_DIRECT flag, on Linux, at least. Let me explain my circumstance: I use rsync to migration VMware disk images from one machine to another while the VM is running. This works really well: you take a snapshot of the VM, run rsync, take another snapshot, run it again, then finally suspend the VM and run it one last time. I can then resume the VM on the new machine. This works because VMware saves disks as a series of 2GB files and creating a snapshot creates a new set of files that contain modifications from the originals. The problem is that during the rsync process the user's machine is barely usable. The reason is because rsync reads these 2GB files... many GBs of them. This causes the user's machine to repeatidly trash the page cache. This really is Linux's fault. It should realize the relative priority of the two apps and prevent rsync from trashing the cache. But it doesn't. Allowing rsync to specific O_DIRECT would circumvent the page cache completely. Preventing the cache from being trashed. Yes, it's a hack. But it'd be really useful!
Jerome Haltom wrote:> The problem is that during the rsync process the user's machine is > barely usable. The reason is because rsync reads these 2GB files... many > GBs of them. This causes the user's machine to repeatidly trash the page > cache. This really is Linux's fault. It should realize the relative > priority of the two apps and prevent rsync from trashing the cache. But > it doesn't. > > Allowing rsync to specific O_DIRECT would circumvent the page cache > completely. Preventing the cache from being trashed.On Linux, fadvise(POSIX_FADV_DONTNEED) trailing behind the read/write position is more appropriate for this, I suspect. It also has the advantage of working with all filesystem types on Linux, which O_DIRECT does not. However, there are times when O_DIRECT is useful, and I do use it in a file copying application of mine to control cache memory. -- Jamie
Apparently Analagous Threads
- Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
- DO NOT REPLY [Bug 7876] New: please implement o_direct
- [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
- Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.
- Re: [PATCH nbdkit] file: Implement cache=none and fadvise=normal|random|sequential.