mirror of https://github.com/aria2/aria2
Download rate based strategy to increase outstanding request
This strategy performs better than old one in high latency environment.pull/43/head
parent
2e216a9403
commit
53dde0a9ae
|
@ -48,12 +48,12 @@
|
||||||
|
|
||||||
#define MAX_BLOCK_LENGTH (16*1024)
|
#define MAX_BLOCK_LENGTH (16*1024)
|
||||||
|
|
||||||
#define DEFAULT_MAX_OUTSTANDING_REQUEST 6
|
#define DEFAULT_MAX_OUTSTANDING_REQUEST 2
|
||||||
|
|
||||||
#define OUTSTANDING_REQUEST_STEP 6
|
#define OUTSTANDING_REQUEST_STEP 6
|
||||||
|
|
||||||
// Upper Bound of the number of outstanding request
|
// Upper Bound of the number of outstanding request
|
||||||
#define UB_MAX_OUTSTANDING_REQUEST 256
|
#define UB_MAX_OUTSTANDING_REQUEST 512
|
||||||
|
|
||||||
#define METADATA_PIECE_SIZE (16*1024)
|
#define METADATA_PIECE_SIZE (16*1024)
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ DefaultBtInteractive::DefaultBtInteractive
|
||||||
maxOutstandingRequest_(DEFAULT_MAX_OUTSTANDING_REQUEST),
|
maxOutstandingRequest_(DEFAULT_MAX_OUTSTANDING_REQUEST),
|
||||||
requestGroupMan_(0),
|
requestGroupMan_(0),
|
||||||
tcpPort_(0),
|
tcpPort_(0),
|
||||||
haveLastSent_(global::wallclock())
|
haveLastSent_(global::wallclock()),
|
||||||
|
baseSpeed_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DefaultBtInteractive::~DefaultBtInteractive() {}
|
DefaultBtInteractive::~DefaultBtInteractive() {}
|
||||||
|
@ -321,13 +322,25 @@ size_t DefaultBtInteractive::receiveMessages() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!pieceStorage_->isEndGame() &&
|
|
||||||
countOldOutstandingRequest > dispatcher_->countOutstandingRequest() &&
|
if(!pieceStorage_->isEndGame() && !pieceStorage_->downloadFinished()) {
|
||||||
(countOldOutstandingRequest - dispatcher_->countOutstandingRequest())*2 >=
|
if(baseSpeed_ == 0) {
|
||||||
maxOutstandingRequest_) {
|
if(countOldOutstandingRequest &&
|
||||||
maxOutstandingRequest_ =
|
dispatcher_->countOutstandingRequest() == 0) {
|
||||||
std::min((size_t)UB_MAX_OUTSTANDING_REQUEST,
|
baseSpeed_ = peer_->calculateDownloadSpeed();
|
||||||
maxOutstandingRequest_+OUTSTANDING_REQUEST_STEP);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return msgcount;
|
return msgcount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,8 @@ private:
|
||||||
std::vector<size_t> haveIndexes_;
|
std::vector<size_t> haveIndexes_;
|
||||||
Timer haveLastSent_;
|
Timer haveLastSent_;
|
||||||
|
|
||||||
|
int baseSpeed_;
|
||||||
|
|
||||||
static const time_t FLOODING_CHECK_INTERVAL = 5;
|
static const time_t FLOODING_CHECK_INTERVAL = 5;
|
||||||
|
|
||||||
void addBitfieldMessageToQueue();
|
void addBitfieldMessageToQueue();
|
||||||
|
|
Loading…
Reference in New Issue