Overhead

How much (approximately) the excessive cost of an I / O failure in Linux from program C , I mean, how bad it works, for example. many small read / write operations compared to read / write on large buffers (on regular files or network sockets)? The application is highly multithreaded.

+6
source share
2 answers

Most modern Syscalls machines require at least 1-2 microseconds, and more complex tasks take a lot more time if they do something complicated that can block or sleep. Expect at least 20 microseconds and up to the order of milliseconds for I / O. Contrast this with a tiny function call or a macro that reads a byte from a user space buffer, which is likely to complete within nanoseconds (maybe 200 ns on a bad day).

+14
source

You can measure it yourself. Just open /dev/zero and read and write while measuring time. Also change the number of bytes that you put in each call - for example. 1 byte, 2 bytes, 128 bytes, 4096 bytes. Also make sure to use syscalls read(2) and write(2) and not anything using internal buffers.

+3
source

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


All Articles