I have done many obscure system optimizations in the past, but I got rid of most of them after
powertop told me I should set my USB ports to autosuspend, which forced them to an eternal sleep, and also after I realized the benefits of a higher swappiness.
But today, while looking at
/etc/fstab, I noticed I had set the option
commit=60 for / and /home. I remember that this was an optimization for laptops, to reduce the amount of writes to the disk, thus saving battery. But then I became concerned that this might cause data loss (sometimes my battery gets disconnected, and then on boot
fsck tells me about a couple of orphan inodes).
While searching for an explanation for this option, I came to the following explanations (the second seems to contradict my previous understanding):
$ man mount | awk '/commit=/,/^$/' commit=nrsec Sync all data and metadata every nrsec seconds. The default value is 5 seconds. Zero means default.
commit=60 stops the "immediate" (default of 5 seconds) prioritization of writes of over reads, caching the writes for a few more seconds later. This is good in the situation of heavy reads and writes mixed together, where the user wants the reads to take priority, so that the processor can be kept busy rather than pause while waiting for the writes to finish before it can continue reading.
A real-world example I have seen is waiting several seconds for the Gnome pull-down menu to appear, for seemingly no reason. The reason was that the disk was busy writing, so the CPU had to wait for the writing to finish before it could get all the data from the disk to be able to show the menu.
What does commit really do? Are there really advantages of increasing it (like responsiveness and power savings)? May it actually cause data loss?