Search code examples
goiosystem-callsunix-socket

Go support for Scatter-Gather IO operations


I want to develop a high-performance client-server communication protocol over Unix Domain Sockets in Go. Specifically, I was thinking of employing Vector-IO operations (writev/readv system calls) in order to avoid the overhead of structured data serialization. However, I think Go doesn't fully support the use of scatter-gather io operations. I have found some attempts in providing Go support for writev operations but not readv. Is there a way to implement this in Go and/or what would the alternative be performance-wise?


Solution

  • Use net.Buffers for optimized batch write using writev or similar.

    For read, slurp the data up into a single buffer and slice the buffer as needed.