On Thu, 22 Jun 2023 22:12:27 -0400
Jon Maloy <jmaloy(a)redhat.com> wrote:
When reading received messages with MSG_PEEK, we
sometines have to read
the leading bytes of the stream several times, only to reach the bytes
we really want. This is clearly non-optimal.
What we would want is something similar to pread/preadv(), but working
even for tcp sockets. At the same time, we obviously don't want to add
any new arguments to the recv/recvmsg() calls.
In this commit, we allow the user to set iovec.iov_base in the first
vector entry to NULL. This tells the socket to skip the first entry,
hence making the iov_len field of that entry indicate the offset value.
This way, there is no need to add any new arguments.
Ah-ha! I'm glad you
found an acceptable way to pass a NULL pointer
there. :)
This change is simple and non-intrusive, and
should be safe addition to
the socket API. We have measured it to give a throughput improvement of
...it
would be nice to also do a bit of profiling with perf(1) --
that's where I originally noticed we were wasting cycles on filling up
tcp_buf_discard. Plus, sure, there's also some value in dropping a
useless 16 MiB buffer.
If you need examples/inspiration: the pasta (automated) demo shows
that, skip at 9:20 in:
https://passt.top/passt/about/#pasta_2 (the one
on the left)
and that's simply done like this:
https://passt.top/passt/tree/test/demo/pasta#n163 This looks like a script
language, but I don't recognize it. How do I run
it?