How to change kernel i/o buffer size

后端 未结 2 1438
无人及你
无人及你 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.

    0 讨论(0)
  • 2021-01-05 06:12

    I think you mean the disk IO queues. For example:

    $ cat /sys/block/sda/queue/nr_requests
    128
    

    How this queue is used depends on the IO scheduler that is in use.

    $ cat /sys/block/sda/queue/scheduler
    noop anticipatory deadline [cfq]
    

    cfq is the most common choice, although on systems with advanced disk controllers and in virtual guest systems noop is also a very good choice.

    There is no config file for this information that I am aware of. On systems that I need to change the queue settings on I put the changes into /etc/rc.local although you could use a full-up init script instead and place it into an RPM or DEB for mass distribution to a lot of systems.

    0 讨论(0)
提交回复
热议问题