How to change kernel i/o buffer size

后端 未结 2 1440
无人及你
无人及你 2021-01-05 05:30

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, a

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 05:59

    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.

    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)

    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".

    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.)

    You will be able to ask a better question if you first educate yourself about the Linux VM subsystem, especially the page cache.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题