Avoid needless wasted space in cells
In #7707 (moved), cypherpunks notes that when packaging cells, we can do some really dumb things when bandwidth is low, such reading incoming bytes in a super-slow trickle, and packaging them into cells aggressively.
There are two comparatively easy things I want to do to prevent this:
- We should use FIONREAD to determine the number of cells waiting on an incoming edge socket. If we determine that more reading in the future will let us fit more bytes in a cell, we shouldn't package bytes in a cell yet.
- We could avoid packaging incoming bytes from a stream for so long as that circuit has any queued cells that originated here, in case more incoming bytes arrive before we'd transmit the current cell.
This feels like a backport candidate to 0.2.3.