From 9e2911b36c2864c2bc90bb083045562d7148631c Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 2 Aug 2024 13:06:55 +0200 Subject: [PATCH] spread chosen chunks more thinly if small files should help (a little) if many small files with distribution --- solanaceae/ngc_ft1_sha1/chunk_picker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp index 3dd7ebd..2df4bbe 100644 --- a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp +++ b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp @@ -327,7 +327,8 @@ std::vector ChunkPicker::updateChunkRequests( //PickerStrategyRandom ps(chunk_candidates, total_chunks, _rng); PickerStrategyRandomSequential ps(chunk_candidates, total_chunks, _rng, start_offset); size_t out_chunk_idx {0}; - while (ps.gen(out_chunk_idx) && req_ret.size() < num_requests) { + size_t req_from_this_o {0}; + while (ps.gen(out_chunk_idx) && req_ret.size() < num_requests && req_from_this_o < std::max(total_chunks/3, 1)) { // out_chunk_idx is a potential candidate we can request form peer // - check against double requests @@ -355,6 +356,8 @@ std::vector ChunkPicker::updateChunkRequests( // TODO: move this after packet was sent successfully // (move net in? hmm) requested_chunks[out_chunk_idx] = Components::FT1ChunkSHA1Requested::Entry{0.f, c}; + + req_from_this_o++; } }