Add a performance tuning API for intelligently initializing, inspecting, and tuning send/recv buffer sizes
[email protected] Fri, 13 Nov 2009 17:38:30 -0000
| Newsgroups | gmane.comp.python.twisted.bugs |
|---|---|
| Message-ID | <[email protected]> |
New submission from glyph <[email protected]>: 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: 1. 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.) 1. at the reactor level, to set the defaults for every connection (which is what you want to do 90% of the time) 2. 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) 3. as a method on the transport itself. 2. The current APIs are undocumented (as they are left over from pre-documentation-standard days. 3. 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. 4. 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. ---------- Type : enhancement Component: core Keywords : Priority : normal Nosy : ---------- http://twistedmatrix.com/trac/ticket/4089