Comment Re:Is it really only a matter of scheduling? (Score 1) 472
Shouldn't the size heuristics be in kernel space? Why should cp be analysing the RAM on the system? Take a look at the obscene hacky amount of heuristics userspace ends up with here, for example: http://insights.oetiker.ch/linux/fadvise/
IMHO, POSIX_FADV_SEQUENTIAL should be sufficient, but it doesn't seem to do anything useful (wrt. the page cache). I'm using POSIX_FADV_DONTNEED continuously on just-read pieces of file for an md5sum-type program (moderate CPU on a one-off sequential read), and this seems to work, but I'll also need to do the Oetiker mincore hack as referenced above in order to avoid evicting files out of the page cache if they were in there before.
This is a massive hack though; why shouldn't POSIX_FADV_SEQUENTIAL suffice? IMHO the kernel should do the following heuristic on POSIX_FADV_SEQUENTIAL: for large files don't cause cache misses to populate the cache. And cp could then do a single posix_fadvise and be done with it.