From 11dee5870c5031924b09e1cb8b9412f8cc5169df Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 7 Jul 2024 15:37:49 +0200 Subject: [PATCH] fix round robin and reduce num empty spins to improve perf --- solanaceae/ngc_ft1_sha1/chunk_picker.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp index 644eaf8..2506a49 100644 --- a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp +++ b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp @@ -73,8 +73,8 @@ std::vector ChunkPicker::updateChunkRequests( assert(objreg.valid(participating_in_last)); auto it = participating_unfinished.find(participating_in_last); - // hard limit robin rounds to array size time 100 - for (size_t i = 0; req_ret.size() < num_requests && i < participating_unfinished.size()*100; i++) { + // hard limit robin rounds to array size time 20 + for (size_t i = 0; req_ret.size() < num_requests && i < participating_unfinished.size()*20; i++) { if (it == participating_unfinished.end()) { it = participating_unfinished.begin(); } @@ -172,6 +172,12 @@ std::vector ChunkPicker::updateChunkRequests( } } + if (it == participating_unfinished.end() || ++it == participating_unfinished.end()) { + participating_in_last = entt::null; + } else { + participating_in_last = it->first; + } + if (req_ret.size() < num_requests) { std::cerr << "CP: could not fulfil, " << group_number << ":" << peer_number << " only has " << req_ret.size() << " candidates\n"; }