不要指望交换算法能让你满意了,若让你满意了,别人就不满意了。你若想让自己满意,就必须使算法的天平向你倾斜。
我看了understanding the linux kernel,总算明白了这个道理:
”As a matter of fact,the hardest job of a developer working on the virtual memory subsystem consists of finding an algorithm that ensures acceptable performances both to desktop machines and to high-level machines like large database servers.
Unfortunately,finding a good page frame reclaiming algorithm is a rather empirical job,with very little support for theory.The situation is somewhat similar to evaluation the parameters that achieve good system performance,without asking too many questions about why it works well.Often,it's just a matter of "let's try this approach and see what happens..."An unpleasant side effect of this empirical approach is the code changes quickly,even in the evennumbered versions of Linux,which are supposed to be stable.
“
所以,应该用”let's try this approach and see what happens..."心态去
读这一部分的算法,理解作者的用意便可。你要是不服气,改改它,让它适合你的胃口。
比如:你上面不断的写文件,显然不要缓冲,只要写回文件到硬盘才是最佳的算法。