When I used to copy a data over a thumb-drive, even if the writing speed can't exceed 2 MiB/s to the thumb-drive, Linux first copies 600 MB data to it in one second - it just writes to the RAM as cache, then it slowly flushes out the data for like 300 seconds. Caching doesn't actually increase the copy speed in such case.
To avoid that behaviour I set
That makes sure what I write is written in real time, no caching.
Problems faced so far
- Writing to the SSD is now 20 - 30 MiB/s (when copied a 2 GB data from ramdisk to $HOME)! It used to be 300 MiB/s before the change.
But that's not a major issue for me, because I can now at least confirm what I copied is written and there's nothing leftover in memory, so that I can work on that file just right after copying without any fear of corrupting the data!
Here I Just wanted to know is there any long term side effects of disabling dirty_ratio? I use SSD, HDD, and thumb-drives on my system.
The IO schedulers (set using udev rule) are just MQ-Deadline for all non-rotational disks, and BFQ for rotational disks.
Linux version 5.8.12-xanmod1-1 (makepkg@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Wed, 30 Sep 2020 14:19:49 +0000
I created a new file to the ramdisk:
$ >/tmp/x ; xfs_io -c 'pwrite -S 0xa 0 1G' /tmp/x wrote 1073741824/1073741824 bytes at offset 0 1 GiB, 262144 ops; 0.2277 sec (4.392 GiB/sec and 1151213.5997 ops/sec)
The file only contains
0xa, which just converts to 10 or "\n" in ASCII.
I then mounted, and copied it to my HDD:
- When dirty_ratio is 20 (default):
$ sudo mount /dev/sdb3 /mnt/ ; time sudo cp /tmp/x /mnt/ ; time sudo umount /mnt/ real 0m5.879s user 0m0.013s sys 0m0.392s real 0m3.566s user 0m0.002s sys 0m0.060s
- When dirty_ratio is 0:
$ sudo mount /dev/sdb3 /mnt/ ; time sudo cp /tmp/x /mnt/ ; time sudo umount /mnt/ real 0m29.983s user 0m0.006s sys 0m0.600s real 0m0.163s user 0m0.000s sys 0m0.052s
- When dirty_ratio is 100 (just for the benchmark):
$ sudo mount /dev/sdb3 /mnt/ ; time sudo cp /tmp/x /mnt/ ; time sudo umount /mnt/ real 0m0.408s user 0m0.006s sys 0m0.370s real 0m9.050s user 0m0.004s sys 0m0.077s
The benchmark denotes it's actually terribly slower to set vm.dirty_ratio to 0...