如何更改内核I / O缓冲区大小 [英] How to change kernel i/o buffer size
问题描述
我运行一些实验与I / O密集型应用程序,我试图了解不同内核的影响I / O缓冲的大小,不同的电梯算法,等等。
I am running some experiments with I/O intensive applications and am trying to understand the effects of varying the kernel i/o buffer size, different elevator algorithms, and so on.
我怎么能知道在内核中的I / O缓冲的当前大小?确实内核使用一个以上的缓冲液作为需要时?我怎样才能改变这个缓冲区的大小?是否有一个配置文件的地方存储此信息?
How can I know the current size of the i/o buffer in the kernel? Does the kernel use more than one buffer as need arises? How can I change the size of this buffer? Is there a config file somewhere that stores this info?
(很明显,我不是在谈论处理器或磁盘缓存,我说的是通过内部的缓冲区中读取/不时冲洗出来到磁盘之前写入内核使用的缓冲区)。
(To be clear, I am not talking about processor or disk caches, I am talking about the buffer used by the kernel internally that buffers reads/writes before flushing them out to disk from time to time).
先谢谢了。
推荐答案
内核不缓存读取和写入你的思考方式......它保持一个页面缓存保存在磁盘页。你没有得到操纵它的大小(当然,不是直接的,反正);内核将始终使用的所有的的页面缓存的可用内存。
The kernel does not buffer reads and writes the way you think... It maintains a "page cache" that holds pages from the disk. You do not get to manipulate its size (well, not directly, anyway); the kernel will always use all available free memory for the page cache.
您需要解释你真正要做的。如果要对多少数据从磁盘内核pre-取一些控制,尝试预读的Linux的搜索。 (提示: blockdev看看-setra XXX
)
You need to explain what you are really trying to do. If you want some control over how much data the kernel pre-fetches from disk, try a search for "linux readahead". (Hint: blockdev --setra XXX
)
如果你想在内核多久他们刷新到磁盘之前举行脏页一些控制,尝试Linux的dirty_ratio的搜索。
If you want some control over how long the kernel will hold dirty pages before flushing them to disk, try a search for "linux dirty_ratio".
一个特定的应用程序也可以使用完全绕过页面缓存 O_DIRECT
,并且它可以使用实行某种控制权 FSYNC
, sync_file_range
, posix_fadvise
和 posix_madvise
。 ( O_DIRECT
和 sync_file_range
是Linux的专用;其余的是POSIX)
A specific application can also bypass the page cache completely by using O_DIRECT
, and it can exercise some control over it using fsync
, sync_file_range
, posix_fadvise
, and posix_madvise
. (O_DIRECT
and sync_file_range
are Linux-specific; the rest are POSIX.)
您可以问一个更好的问题,如果你先教育自己有关Linux VM子系统,尤其是页面缓存。
You will be able to ask a better question if you first educate yourself about the Linux VM subsystem, especially the page cache.
这篇关于如何更改内核I / O缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!