Ignore:
Timestamp:
Nov 28, 2008, 4:00:29 PM (14 years ago)
Author:
charles
Message:

(libT) make peer-io's output buffer size more flexible based on the peer's speed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r7159 r7171  
    530530**/
    531531
     532static size_t
     533getDesiredOutputBufferSize( const tr_peerIo * io )
     534{
     535    /* this is all kind of arbitrary, but what seems to work well is
     536     * being large enough to hold the next 15 seconds' worth of input,
     537     * or two and a half blocks, whichever is bigger.
     538     * It's okay to tweak this as needed */
     539    const double maxBlockSize = 16 * 1024; /* 16 KiB is from BT spec */
     540    const double currentSpeed = tr_bandwidthGetPieceSpeed( io->bandwidth, TR_UP );
     541    const double period = 20; /* arbitrary */
     542    return MAX( maxBlockSize*2.5, currentSpeed*1024*period );
     543}
     544
    532545size_t
    533546tr_peerIoGetWriteBufferSpace( const tr_peerIo * io )
    534547{
    535     const size_t desiredLen = io->session->so_sndbuf * 2; /* FIXME: bigger? */
     548    const size_t desiredLen = getDesiredOutputBufferSize( io );
    536549    const size_t currentLen = EVBUFFER_LENGTH( tr_iobuf_output( io->iobuf ) );
    537550    size_t freeSpace = 0;
Note: See TracChangeset for help on using the changeset viewer.