[][src]Module clobber::tcp

TCP handling

This file contains the TCP handling for clobber. The loop here is that we connect, write, and then read. If the client is in repeat mode then it will repeatedly write/read while the connection is open.

Performance Notes

Perform allocations at startup

The pool of connections is created up front, and then connections begin sending requests to match the defined rate. (Or in the case of no defined, they start immediately.) In general we try to to limit significant allocations to startup rather than doing them on the fly. More specifically, you shouldn't see any of these behaviors inside the tight while loop inside the connection() method.

Limit open ports and files

Two of the key limiting factors for high TCP client throughput are running out of ports, or opening more files than the underlying OS will allow. clobber tries to minimize issues here by giving users control over the max connections. (It's also a good idea to check out your specific ulimit -n settings and raise the max number of open files.)

Avoid cross-thread communication

This library uses no cross-thread communication via std::sync or crossbeam. All futures are executed on a LocalPool, and the number of OS threads used is user configurable. This has a number of design impacts. For example, it becomes more difficult to aggregate what each connection is doing. This is simple if you just pass the results to a channel, but this has a non-trivial impact on performance.

*Note: This is currently violated by the way we accomplish rate limiting, which relies on a global thread that manages timers. This ends up putting disproportionate load on that thread at some point. But if you're relying on rate limiting you're trying to slow it down, so we're putting this in the 'feature' column. (If anyone would like to contribute a thread-local futures timer it'd be a great contribution to the Rust community!)

Functions

clobber

The overall test runner