Ticket #4089 enhancement new
Add a performance tuning API for intelligently initializing, inspecting, and tuning send/recv buffer sizes
|Reported by:||glyph||Owned by:|
Twisted currently has two public-but-not-really attributes, twisted.internet.abstract.FileDescriptor.SEND_LIMIT (set by default to 131072) and twisted.internet.abstract.FileDescriptor.bufferSize (set by default to 65536). There are a couple of problems with the way this is done:
- the attributes, despite having public names, are not present on an interface such as ITransport, so they are not really exposed for tuning. I suggest that we add a tuning API at 3 layers. These tuning APIs should set SO_SNDBUF and SO_RCVBUF socket options such that they will match these values, and the kernel will work to get us data of the appropriate size. (Maybe there is a case where someone would want these values to be different from the kernel's idea? If so that should also be available in each of these APIs.)
- at the reactor level, to set the defaults for every connection (which is what you want to do 90% of the time)
- as an argument to listenTCP and connectTCP, to set defaults for all connections coming from that accept() or connect() call (although maybe this should be on IConnector and IListeningPort instead, since adding a method to those objects is easier than modifying a signature)
- as a method on the transport itself.
- The current APIs are undocumented (as they are left over from pre-documentation-standard days.
- The current initial values are completely arbitrary. We do need some numbers here (in particular, we have to pass some number to recv(), especially) but reasonable values can be derived from getsockopt via the SO_SNDBUF and SO_RCVBUF defaults.
- The current naming is inconsistent and confusing. One is named as if it's a constant (it isn't, really) and one is named as an instance variable; the 'send' one indicates its role in its name, but the 'recv' one sounds more general.