mirror of https://github.com/aria2/aria2
2010-08-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Enter end game mode as soon as all pieces are assigned to peer to avoid substantial slow down at the very last stage of download. * src/DefaultBtInteractive.cc * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/PieceStorage.h * src/UnknownLengthPieceStorage.h * test/MockPieceStorage.hpull/1/head
parent
e396d2e2c4
commit
835de071f2
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2010-08-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Enter end game mode as soon as all pieces are assigned to peer to
|
||||||
|
avoid substantial slow down at the very last stage of download.
|
||||||
|
* src/DefaultBtInteractive.cc
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
* src/DefaultPieceStorage.h
|
||||||
|
* src/PieceStorage.h
|
||||||
|
* src/UnknownLengthPieceStorage.h
|
||||||
|
* test/MockPieceStorage.h
|
||||||
|
|
||||||
2010-08-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-08-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Updated IPv6 DHT usage.
|
Updated IPv6 DHT usage.
|
||||||
|
|
|
@ -323,7 +323,8 @@ size_t DefaultBtInteractive::receiveMessages() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(countOldOutstandingRequest >= maxOutstandingRequest_ &&
|
if(!pieceStorage_->isEndGame() &&
|
||||||
|
countOldOutstandingRequest >= maxOutstandingRequest_ &&
|
||||||
dispatcher_->countOutstandingRequest() == 0){
|
dispatcher_->countOutstandingRequest() == 0){
|
||||||
maxOutstandingRequest_ =
|
maxOutstandingRequest_ =
|
||||||
std::min((size_t)UB_MAX_OUTSTANDING_REQUEST,
|
std::min((size_t)UB_MAX_OUTSTANDING_REQUEST,
|
||||||
|
@ -394,6 +395,12 @@ void DefaultBtInteractive::fillPiece(size_t maxMissingBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtInteractive::addRequests() {
|
void DefaultBtInteractive::addRequests() {
|
||||||
|
if(!pieceStorage_->isEndGame() && !pieceStorage_->hasMissingUnusedPiece()) {
|
||||||
|
pieceStorage_->enterEndGame();
|
||||||
|
}
|
||||||
|
if(pieceStorage_->isEndGame()) {
|
||||||
|
maxOutstandingRequest_ = 2;
|
||||||
|
}
|
||||||
fillPiece(maxOutstandingRequest_);
|
fillPiece(maxOutstandingRequest_);
|
||||||
size_t reqNumToCreate =
|
size_t reqNumToCreate =
|
||||||
maxOutstandingRequest_ <= dispatcher_->countOutstandingRequest() ?
|
maxOutstandingRequest_ <= dispatcher_->countOutstandingRequest() ?
|
||||||
|
@ -402,6 +409,7 @@ void DefaultBtInteractive::addRequests() {
|
||||||
std::vector<SharedHandle<BtMessage> > requests;
|
std::vector<SharedHandle<BtMessage> > requests;
|
||||||
requests.reserve(reqNumToCreate);
|
requests.reserve(reqNumToCreate);
|
||||||
if(pieceStorage_->isEndGame()) {
|
if(pieceStorage_->isEndGame()) {
|
||||||
|
logger_->debug("ENDGAME");
|
||||||
btRequestFactory_->createRequestMessagesOnEndGame(requests,reqNumToCreate);
|
btRequestFactory_->createRequestMessagesOnEndGame(requests,reqNumToCreate);
|
||||||
} else {
|
} else {
|
||||||
btRequestFactory_->createRequestMessages(requests, reqNumToCreate);
|
btRequestFactory_->createRequestMessages(requests, reqNumToCreate);
|
||||||
|
|
|
@ -71,6 +71,7 @@ DefaultPieceStorage::DefaultPieceStorage
|
||||||
bitfieldMan_(new BitfieldMan(downloadContext->getPieceLength(),
|
bitfieldMan_(new BitfieldMan(downloadContext->getPieceLength(),
|
||||||
downloadContext->getTotalLength())),
|
downloadContext->getTotalLength())),
|
||||||
diskWriterFactory_(new DefaultDiskWriterFactory()),
|
diskWriterFactory_(new DefaultDiskWriterFactory()),
|
||||||
|
endGame_(false),
|
||||||
endGamePieceNum_(END_GAME_PIECE_NUM),
|
endGamePieceNum_(END_GAME_PIECE_NUM),
|
||||||
logger_(LogFactory::getInstance()),
|
logger_(LogFactory::getInstance()),
|
||||||
option_(option),
|
option_(option),
|
||||||
|
@ -82,11 +83,6 @@ DefaultPieceStorage::~DefaultPieceStorage() {
|
||||||
delete bitfieldMan_;
|
delete bitfieldMan_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefaultPieceStorage::isEndGame()
|
|
||||||
{
|
|
||||||
return bitfieldMan_->countMissingBlock() <= endGamePieceNum_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DefaultPieceStorage::getMissingPieceIndex(size_t& index,
|
bool DefaultPieceStorage::getMissingPieceIndex(size_t& index,
|
||||||
const unsigned char* bitfield,
|
const unsigned char* bitfield,
|
||||||
size_t length)
|
size_t length)
|
||||||
|
|
|
@ -78,6 +78,7 @@ private:
|
||||||
SharedHandle<DiskWriterFactory> diskWriterFactory_;
|
SharedHandle<DiskWriterFactory> diskWriterFactory_;
|
||||||
std::deque<SharedHandle<Piece> > usedPieces_;
|
std::deque<SharedHandle<Piece> > usedPieces_;
|
||||||
|
|
||||||
|
bool endGame_;
|
||||||
size_t endGamePieceNum_;
|
size_t endGamePieceNum_;
|
||||||
Logger* logger_;
|
Logger* logger_;
|
||||||
const Option* option_;
|
const Option* option_;
|
||||||
|
@ -187,8 +188,16 @@ public:
|
||||||
|
|
||||||
virtual bool isSelectiveDownloadingMode();
|
virtual bool isSelectiveDownloadingMode();
|
||||||
|
|
||||||
virtual bool isEndGame();
|
virtual bool isEndGame()
|
||||||
|
{
|
||||||
|
return endGame_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void enterEndGame()
|
||||||
|
{
|
||||||
|
endGame_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual SharedHandle<DiskAdaptor> getDiskAdaptor();
|
virtual SharedHandle<DiskAdaptor> getDiskAdaptor();
|
||||||
|
|
||||||
virtual size_t getPieceLength(size_t index);
|
virtual size_t getPieceLength(size_t index);
|
||||||
|
|
|
@ -189,6 +189,9 @@ public:
|
||||||
|
|
||||||
virtual bool isEndGame() = 0;
|
virtual bool isEndGame() = 0;
|
||||||
|
|
||||||
|
virtual void enterEndGame() = 0;
|
||||||
|
|
||||||
|
// TODO We can remove this.
|
||||||
virtual void setEndGamePieceNum(size_t num) = 0;
|
virtual void setEndGamePieceNum(size_t num) = 0;
|
||||||
|
|
||||||
virtual SharedHandle<DiskAdaptor> getDiskAdaptor() = 0;
|
virtual SharedHandle<DiskAdaptor> getDiskAdaptor() = 0;
|
||||||
|
|
|
@ -211,6 +211,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void enterEndGame() {}
|
||||||
|
|
||||||
virtual void setEndGamePieceNum(size_t num) {}
|
virtual void setEndGamePieceNum(size_t num) {}
|
||||||
|
|
||||||
virtual SharedHandle<DiskAdaptor> getDiskAdaptor();
|
virtual SharedHandle<DiskAdaptor> getDiskAdaptor();
|
||||||
|
|
|
@ -190,8 +190,8 @@ public:
|
||||||
|
|
||||||
virtual void setEndGamePieceNum(size_t num) {}
|
virtual void setEndGamePieceNum(size_t num) {}
|
||||||
|
|
||||||
void setEndGame(bool flag) {
|
virtual void enterEndGame() {
|
||||||
this->endGame = flag;
|
this->endGame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SharedHandle<DiskAdaptor> getDiskAdaptor() {
|
virtual SharedHandle<DiskAdaptor> getDiskAdaptor() {
|
||||||
|
|
Loading…
Reference in New Issue