< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate] TCP process optimizations


I just committed a few minor optimizations for the TCP Transport, process
loop.

1. Added numReady to FdSet class - basically just caches the select result.
2. In TcpBaseTransport::process - only do processSomeReads,
processSomeWrites and processListen if fdSet.numReady > 0.

Some buildFdSet/Select/process loops in applications, will end up using a
timed select call.  When select times out - you get back a FdSet with no
ready FD's.  In this case we can save the work of iterating through all of
the TCP connections to see which ones are ready to read from, since we know
that none have signaled. 

In windows the fd_set, structure contains an fd_count, so we can further
optimize the processSomeReads function to not bother going through the
connections if fd_count is 0.  This will need #IFDEFs around it though,
since *nix systems don't have this.

These minor optimizations should save a few CPU cycles for apps that use a
timed select.

Scott