upvote
The dirty ratio also behaves differently than I assumed at first. 20% does not mean 20% of all memory, it means 20% of "dirtyable" memory. Also, 1GB dirty threshold does not mean that writes only get slowed down at 1GB. There is a "freerun" threshold at the midpoint between the background dirty limit and the dirty limit, and the kernel starts progressively throttling writers at that midpoint.
reply
depends, if you have servers that buffer large blobs in tempfiles you don't really want those flushed to storage unless there's a real memory shortage.
reply
But is that a default usecase?
reply
well YES, even on desktop

Many, many apps do "download to tmpfile then move to final location when finished", from browsers thru Steam to package managers.

reply
That's a metadata action and has nothing to do with rewriting the blocks of the file.
reply
that would be true if /tmp and the destination happen to be on the same filesystem, but I don't think that's a safe assumption. Especially if you are using tmpfs which stores /tmp in ram or swap.
reply
No, on a multi-tenant machine I really, really want that tempfile thing to be throttled on dirty page creation. If that process thinks it can run in constant space without externalizing the page cache then it knows what to do: write its temporary objects to anonymous memory, not files.
reply
And then you need to worry about swapping.
reply
The volume of the writeout in itself would not be a problem if it weren't that the dirty page table is locked until writeout completes. That means that new page allocations are stalled while writeout is in progress. And you're right, the default dirty page ratio is way too high, especially in the much-ram-meets-spinning-rust scenario. I have had rsync backups stall for over a minute while the archive server digests its dirty page buffer, only to have the server then stop writing for long enough to allow the disks to go back to standby mode.

It would take major engineering effort in the VFS layer to avoid locking the page table during writeout, but that's what a proper solution would look like in my eyes.

reply
I set vm.dirty_bytes to 256MiB.
reply