Reverted to the original strategy, but some values are tweaked.
Without TCP_NODELAY, 53dde0a9 does not work well.
pull/43/head
Tatsuhiro Tsujikawa 2013-01-15 23:50:12 +09:00
parent bf4ea63a66
commit 1c72b80aa5
3 changed files with 9 additions and 23 deletions

View File

@ -48,7 +48,7 @@
#define MAX_BLOCK_LENGTH (16*1024)
#define DEFAULT_MAX_OUTSTANDING_REQUEST 2
#define DEFAULT_MAX_OUTSTANDING_REQUEST 6
#define OUTSTANDING_REQUEST_STEP 6

View File

@ -98,8 +98,7 @@ DefaultBtInteractive::DefaultBtInteractive
maxOutstandingRequest_(DEFAULT_MAX_OUTSTANDING_REQUEST),
requestGroupMan_(0),
tcpPort_(0),
haveLastSent_(global::wallclock()),
baseSpeed_(0)
haveLastSent_(global::wallclock())
{}
DefaultBtInteractive::~DefaultBtInteractive() {}
@ -323,24 +322,13 @@ size_t DefaultBtInteractive::receiveMessages() {
}
}
if(!pieceStorage_->isEndGame() && !pieceStorage_->downloadFinished()) {
if(baseSpeed_ == 0) {
if(countOldOutstandingRequest &&
dispatcher_->countOutstandingRequest() == 0) {
baseSpeed_ = peer_->calculateDownloadSpeed();
maxOutstandingRequest_ *= 2;
}
} else {
int speed = peer_->calculateDownloadSpeed();
// Double the number of outstanding request if 20% download rate
// increase is observed.
if(baseSpeed_*12 <= speed*10) {
maxOutstandingRequest_ =
std::min((size_t)UB_MAX_OUTSTANDING_REQUEST,
maxOutstandingRequest_*2);
baseSpeed_ = speed;
}
}
if(!pieceStorage_->isEndGame() &&
countOldOutstandingRequest > dispatcher_->countOutstandingRequest() &&
(countOldOutstandingRequest - dispatcher_->countOutstandingRequest())*4 >=
maxOutstandingRequest_) {
maxOutstandingRequest_ =
std::min((size_t)UB_MAX_OUTSTANDING_REQUEST,
maxOutstandingRequest_*2);
}
return msgcount;
}

View File

@ -149,8 +149,6 @@ private:
std::vector<size_t> haveIndexes_;
Timer haveLastSent_;
int baseSpeed_;
static const time_t FLOODING_CHECK_INTERVAL = 5;
void addBitfieldMessageToQueue();