object download prio, not set anywhere yet, but the code is there now

This commit is contained in:
Green Sky 2024-07-10 11:13:57 +02:00
parent ef91ec14fc
commit 822b979286
No known key found for this signature in database
3 changed files with 32 additions and 4 deletions

View File

@ -146,8 +146,22 @@ void ChunkPicker::updateParticipation(
} }
if (!o.get<Components::FT1ChunkSHA1Cache>().have_all) { if (!o.get<Components::FT1ChunkSHA1Cache>().have_all) {
// TODO: set priority using Priority = Components::DownloadPriority::Priority;
participating_unfinished.emplace(o, ParticipationEntry{}); Priority prio = Priority::NORMAL;
if (o.all_of<Components::DownloadPriority>()) {
prio = o.get<Components::DownloadPriority>().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); checked.emplace(o);

View File

@ -38,10 +38,11 @@ struct ChunkPicker {
// TODO: handle with hash utils? // TODO: handle with hash utils?
struct ParticipationEntry { struct ParticipationEntry {
ParticipationEntry(void) {} ParticipationEntry(void) {}
ParticipationEntry(uint16_t s) : should_skip(s) {}
// skips in round robin -> lower should_skip => higher priority // skips in round robin -> lower should_skip => higher priority
// TODO: replace with enum value // TODO: replace with enum value
uint16_t should_skip {2}; // 0 high, 8 low (double each time? 0,1,2,4,8) 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<Object, ParticipationEntry> participating_unfinished; entt::dense_map<Object, ParticipationEntry> participating_unfinished;
Object participating_in_last {entt::null}; Object participating_in_last {entt::null};

View File

@ -73,11 +73,24 @@ namespace Components {
float timer {0.f}; 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 { struct ReadHeadHint {
// points to the first byte we want // points to the first byte we want
// this is just a hint, that can be set from outside // this is just a hint, that can be set from outside
// to guide the sequential "piece picker" strategy // 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}; uint64_t offset_into_file {0u};
}; };