]> git.ipfire.org Git - thirdparty/squid.git/commit - src/comm.cc
Performance fix: Check half-closed descriptors at most once per second.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 25 Sep 2008 17:27:58 +0000 (11:27 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 25 Sep 2008 17:27:58 +0000 (11:27 -0600)
commit7425712611aaf8ce97414a20de145d9ffbdbe9de
treeee8fd071ef35f43bd1142b4fec7f64124f80bb56
parent877ce94479c54199c17a591a78b49c3b175d628d
Performance fix: Check half-closed descriptors at most once per second.

A few revisions back, comm checked half-closed descriptors once per second,
but the code was buggy. I replaced it with a simpler code that checked each
half-closed descriptor whenever the OS would mark it as ready for reading.
That was a bad idea: The checks wasted a lot of CPU cycles because half-closed
descriptors are usually ready for reading all the time.

This revision resurrects 1 check/sec limit, but hopefully with fewer bugs. In
my limited tests CPU usage seems to be back to normal.

All half-closed descriptors are now stored in TheHalfClosed set. When it is
time to check the corresponding connections, Comm schedules a read for
each descriptor that is not already reading. Conflicts with regular/user
reads are resolved as before -- we silently cancel the internal half-closed
read.

TODO: It is possible that we do not need to read at all and should call
getsockopt() instead to test the connection.
src/comm.cc
src/fde.h