sociomantic-tsunami / ocean

General purpose, platform-dependent, high-performance library for D
Other
61 stars 56 forks source link

Consider using zero-copy sockets #371

Open leandro-lucarella-sociomantic opened 7 years ago

leandro-lucarella-sociomantic commented 7 years ago

The new 4.14 Linux kernel has a new zero-copy option for sockets:

1.5. Zero-copy from user memory to sockets

Copying large buffers between user process and kernel can be expensive. Linux supports various interfaces that eschew copying, such as sendpage(2) and splice(2). The MSG_ZEROCOPY socket flag extends the underlying copy avoidance mechanism to common socket send calls. Copy avoidance is not a free lunch. As implemented, with page pinning, it replaces per byte copy cost with page accounting and completion notification overhead. As a result, MSG_ZEROCOPY is generally only effective at writes over around 10 KB.

https://lwn.net/Articles/726917/

I guess ocean could make use of this in the future...

gavin-norman-sociomantic commented 7 years ago

Nice!

As a result, MSG_ZEROCOPY is generally only effective at writes over around 10 KB.

That's interesting. Certain situations in swarm could benefit from that. Sending prepared batches of records, for example.