开发者

Limit buffer cache

开发者 https://www.devze.com 2023-02-17 12:34 出处:网络
I am wondering if there\'s any way to set an upper 开发者_如何学运维limit on the buffer cache usable address space? I think that there\'s no limit and once the memory usage gets to a certain point, ot

I am wondering if there's any way to set an upper 开发者_如何学运维limit on the buffer cache usable address space? I think that there's no limit and once the memory usage gets to a certain point, other processes will be swapped out to enable the buffer cache to expand?

Having said that, I guess if it came to that point, reads/writes could simply fail right?


Read-write wont fail just because BufferCache is taking lots of memory. Only unused RAM is used as Buffer for caching disk, but if some process need memory it gets higher priority. This done by Kernel automatically, buffer cache is just a optimal use of resources, it wont harm the normal working of system.


The general problem is not that read/write will fail, but your applications will freeze-up and eventually fail. Here is a very simple experiment. Take a directory of very large files and copy it to a very slow device. What you will find 100% of the available memory will be consumed by the write cache. This cache is only cleared by actually writing to the slow device. The problem is what happen when an application needs memory or needs to swap back in something that has been swapped to disk? Since the cache is being empty too slowly, the only real option is to swap something else to disk to make more memory available. So now the whole system is thrashing. If you are out of swap space, then you have serious problems. Either way though, your desktop is fairly slugish and maybe even completely locked until your copying finishes.

While I don't know of anyway to fix this problem, adjust vm.vfs_cache_pressure towards 0 to and vm.swappiness towards 0 to help reduce this problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号