How to change kernel I / O buffer size

I am experimenting with intensive I / O applications and trying to understand the effects of changing the size of the kernel I / O buffer, various elevator algorithms, etc.

How to find out the current size of the I / O buffer in the kernel? Is the kernel using more than one buffer as needed? How to resize this buffer? Is there a configuration file somewhere where this information is stored?

(To be clear, I'm not talking about processor or disk caches, I'm talking about a buffer used by the kernel inside, which buffers read / write before unloading them to disk from time to time).

Thanks in advance.

+6
source share
2 answers

The kernel does not buffer reading and writing, what do you think ... It supports the "page cache", which contains pages from disk. You cannot 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 actually trying to do. If you need some control over the amount of data that the kernel preliminarily retrieves from disk, try searching for "linux readahead". (Hint: blockdev --setra XXX )

If you need some control over how long the kernel will contain dirty pages before releasing them to disk, try searching for "linux dirty_ratio".

A particular application can also completely bypass the page cache using O_DIRECT , and can exercise some control over it with fsync , sync_file_range , posix_fadvise and posix_madvise . ( O_DIRECT and sync_file_range are Linux dependent, the rest are POSIX.)

You can ask a more correct question if you first learn about the Linux VM subsystem, especially the page cache.

+9
source

I think you mean IO disk queues. For instance:

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

How this queue is used depends on the I / O scheduler that is used.

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

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

There is no configuration file for this information that I know of. On systems where I need to change the queue settings, I made changes to /etc/rc.local, although instead you could use the full init script and put it in an RPM or DEB for mass distribution to many systems.

+3
source

Source: https://habr.com/ru/post/894932/


All Articles