Skip to main content
added 235 characters in body
Source Link

In the Completion model, the OS is asking you to allocate memory before data actually flows in and it's obvious what's happening.

But what happens if more data comes in than you allocated space for? The kernel still has to allocate its own buffer so as not to drop the data. (For example, this is why the 1-byte read trick mentioned in usr's answer works.)

The tradeoff is that while the Completion Model consumes more memory, it can also (sometimes) do fewer copy operations, because keeping the buffer around means the hardware can DMA directly out of or into it. I also suspect (but am less sure) that the Completion Model tends to do the actual copy operation (when it exists) on another thread, at least for Windows' IOCP, while the Readiness Model does it as part of the non-blocking read() or write() call.

In the Completion model, the OS is asking you to allocate memory before data actually flows in and it's obvious what's happening.

But what happens if more data comes in than you allocated space for? The kernel still has to allocate its own buffer so as not to drop the data. (For example, this is why the 1-byte read trick mentioned in usr's answer works.)

The tradeoff is that while the Completion Model consumes more memory, it can also (sometimes) do fewer copy operations, because keeping the buffer around means the hardware can DMA directly out of or into it.

In the Completion model, the OS is asking you to allocate memory before data actually flows in and it's obvious what's happening.

But what happens if more data comes in than you allocated space for? The kernel still has to allocate its own buffer so as not to drop the data. (For example, this is why the 1-byte read trick mentioned in usr's answer works.)

The tradeoff is that while the Completion Model consumes more memory, it can also (sometimes) do fewer copy operations, because keeping the buffer around means the hardware can DMA directly out of or into it. I also suspect (but am less sure) that the Completion Model tends to do the actual copy operation (when it exists) on another thread, at least for Windows' IOCP, while the Readiness Model does it as part of the non-blocking read() or write() call.

Source Link

In the Completion model, the OS is asking you to allocate memory before data actually flows in and it's obvious what's happening.

But what happens if more data comes in than you allocated space for? The kernel still has to allocate its own buffer so as not to drop the data. (For example, this is why the 1-byte read trick mentioned in usr's answer works.)

The tradeoff is that while the Completion Model consumes more memory, it can also (sometimes) do fewer copy operations, because keeping the buffer around means the hardware can DMA directly out of or into it.