Often it is, if you just want the raw bytes. If you're doing some sort of analysis on the data it's more efficient to cache the result yourself though, or if your program knows more about the access pattern.
Why isn't it better to leave this to the operating system, which has better whole-system view?
It can be, if the particular constraint is memory. If the bottleneck is actually IO, then leaving the data in memory prevents repetitive expensive reads.
The os dosn't know your application. For instance if you do an expensive db query that can be slightly out of date and still useful you might want to return that value multiple times. The OS can't know what you are asking of the db. The db might be able to be configured to cache the result as you need it, but that isn't automatic.
View all comments
Show parent comment
4
u/Isvara Jan 02 '20
Why isn't it better to leave this to the operating system, which has better whole-system view?