This commit is contained in:
Green Sky 2024-07-12 14:42:13 +02:00
parent 6e681aa3fd
commit eff25cb10b
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -111,6 +111,16 @@ struct PickerStrategyRandomSequential {
} }
}; };
// TODO: return bytes instead, so it can be done chunk size independent
static constexpr size_t flowWindowToRequestCount(size_t flow_window) {
// based on 500KiB/s with ~0.05s delay looks fine
// increase to 4 at wnd >= 25*1024
if (flow_window >= 25*1024) {
return 4u;
}
return 3u;
}
void ChunkPicker::updateParticipation( void ChunkPicker::updateParticipation(
Contact3Handle c, Contact3Handle c,
ObjectRegistry& objreg ObjectRegistry& objreg
@ -188,6 +198,7 @@ std::vector<ChunkPicker::ContentChunkR> ChunkPicker::updateChunkRequests(
ObjectRegistry& objreg, ObjectRegistry& objreg,
ReceivingTransfers& rt, ReceivingTransfers& rt,
const size_t open_requests const size_t open_requests
//const size_t flow_window
//NGCFT1& nft //NGCFT1& nft
) { ) {
if (!static_cast<bool>(c)) { if (!static_cast<bool>(c)) {
@ -212,8 +223,12 @@ std::vector<ChunkPicker::ContentChunkR> ChunkPicker::updateChunkRequests(
const size_t num_ongoing_transfers = rt.sizePeer(group_number, peer_number); const size_t num_ongoing_transfers = rt.sizePeer(group_number, peer_number);
// TODO: account for open requests // TODO: account for open requests
const int64_t num_total = num_ongoing_transfers + open_requests; const int64_t num_total = num_ongoing_transfers + open_requests;
// TODO: base max on rate(chunks per sec), gonna be ass with variable chunk size // TODO: base max on rate(chunks per sec), gonna be ass with variable chunk size
const size_t num_requests = std::max<int64_t>(0, int64_t(max_tf_chunk_requests)-num_total); //const size_t num_max = std::max(max_tf_chunk_requests, flowWindowToRequestCount(flow_window));
const size_t num_max = max_tf_chunk_requests;
const size_t num_requests = std::max<int64_t>(0, int64_t(num_max)-num_total);
std::cerr << "CP: want " << num_requests << "(rt:" << num_ongoing_transfers << " or:" << open_requests << ") from " << group_number << ":" << peer_number << "\n"; std::cerr << "CP: want " << num_requests << "(rt:" << num_ongoing_transfers << " or:" << open_requests << ") from " << group_number << ":" << peer_number << "\n";
// while n < X // while n < X

View File

@ -70,6 +70,7 @@ struct ChunkPicker {
ObjectRegistry& objreg, ObjectRegistry& objreg,
ReceivingTransfers& rt, ReceivingTransfers& rt,
const size_t open_requests const size_t open_requests
//const size_t flow_window
//NGCFT1& nft //NGCFT1& nft
); );
}; };