From 822b979286569e46ea57ac3d0ca383a39b6cede8 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 10 Jul 2024 11:13:57 +0200 Subject: [PATCH] object download prio, not set anywhere yet, but the code is there now --- solanaceae/ngc_ft1_sha1/chunk_picker.cpp | 18 ++++++++++++++++-- solanaceae/ngc_ft1_sha1/chunk_picker.hpp | 3 ++- solanaceae/ngc_ft1_sha1/components.hpp | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp index ee92831..96e1e5d 100644 --- a/solanaceae/ngc_ft1_sha1/chunk_picker.cpp +++ b/solanaceae/ngc_ft1_sha1/chunk_picker.cpp @@ -146,8 +146,22 @@ void ChunkPicker::updateParticipation( } if (!o.get().have_all) { - // TODO: set priority - participating_unfinished.emplace(o, ParticipationEntry{}); + using Priority = Components::DownloadPriority::Priority; + Priority prio = Priority::NORMAL; + + if (o.all_of()) { + prio = o.get().p; + } + + uint16_t pskips = + prio == Priority::HIGHER ? 0u : + prio == Priority::HIGH ? 1u : + prio == Priority::NORMAL ? 2u : + prio == Priority::LOW ? 4u : + 8u + ; + + participating_unfinished.emplace(o, ParticipationEntry{pskips}); } } checked.emplace(o); diff --git a/solanaceae/ngc_ft1_sha1/chunk_picker.hpp b/solanaceae/ngc_ft1_sha1/chunk_picker.hpp index 1557d06..c542d46 100644 --- a/solanaceae/ngc_ft1_sha1/chunk_picker.hpp +++ b/solanaceae/ngc_ft1_sha1/chunk_picker.hpp @@ -38,10 +38,11 @@ struct ChunkPicker { // TODO: handle with hash utils? struct ParticipationEntry { ParticipationEntry(void) {} + ParticipationEntry(uint16_t s) : should_skip(s) {} // skips in round robin -> lower should_skip => higher priority // TODO: replace with enum value uint16_t should_skip {2}; // 0 high, 8 low (double each time? 0,1,2,4,8) - uint16_t skips {2}; + uint16_t skips {0}; }; entt::dense_map participating_unfinished; Object participating_in_last {entt::null}; diff --git a/solanaceae/ngc_ft1_sha1/components.hpp b/solanaceae/ngc_ft1_sha1/components.hpp index 7f95622..1922a06 100644 --- a/solanaceae/ngc_ft1_sha1/components.hpp +++ b/solanaceae/ngc_ft1_sha1/components.hpp @@ -73,11 +73,24 @@ namespace Components { float timer {0.f}; }; + struct DownloadPriority { + // download/retreival priority in comparison to other objects + // not all backends implement this + // priority can be weak, meaning low priority dls will still get transfer activity, just less often + enum class Priority { + HIGHER, + HIGH, + NORMAL, + LOW, + LOWER, + } p = Priority::NORMAL; + }; + struct ReadHeadHint { // points to the first byte we want // this is just a hint, that can be set from outside // to guide the sequential "piece picker" strategy - // the strategy *should* set this to the first byte we dont yet have + // ? the strategy *should* set this to the first byte we dont yet have uint64_t offset_into_file {0u}; };