]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: raw-sock: don't speculate after a short read if polling is enabled
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Jan 2014 23:54:27 +0000 (00:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 25 Jan 2014 23:42:32 +0000 (00:42 +0100)
commit6c11bd2f89eb043fd493d77b784198e90e0a01b2
treef6ac0ce701723f5e11c695ffcec4e418f9bd4d6c
parentbaf5b9b445683f2221f41c27dc3ed77ef5d31e41
OPTIM: raw-sock: don't speculate after a short read if polling is enabled

This is the reimplementation of the "done" action : when we experience
a short read, we're almost certain that we've exhausted the system's
buffers and that we'll meet an EAGAIN if we attempt to read again. If
the FD is not yet polled, the stream interface already takes care of
stopping the speculative read. When the FD is already being polled, we
have two options :
  - either we're running from a level-triggered poller, in which case
    we'd rather report that we've reached the end so that we don't
    speculate over the poller and let it report next time data are
    available ;

  - or we're running from an edge-triggered poller in which case we
    have no choice and have to see the EAGAIN to re-enable events.

At the moment we don't have any edge-triggered poller, so it's desirable
to avoid speculative I/O that we know will fail.

Note that this must not be ported to SSL since SSL hides the real
readiness of the file descriptor.

Thanks to this change, we observe no EAGAIN anymore during keep-alive
transfers, and failed recvfrom() are reduced by half in http-server-close
mode (the client-facing side is always being polled and the second recv
can be avoided). Doing so results in about 5% performance increase in
keep-alive mode. Similarly, we used to have up to about 1.6% of EAGAIN
on accept() (1/maxaccept), and these have completely disappeared under
high loads.
include/proto/fd.h
src/listener.c
src/raw_sock.c