From 31253f57084c9bb4d4ffa409b7e005cb33d36dcb Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 12 Jul 2024 15:04:49 +0200 Subject: [PATCH] tweak ft max numbers and add stats comp --- solanaceae/ngc_ft1_sha1/chunk_picker.hpp | 2 +- solanaceae/ngc_ft1_sha1/components.hpp | 31 ++++++++++++++++++++++++ solanaceae/ngc_ft1_sha1/sha1_ngcft1.hpp | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/solanaceae/ngc_ft1_sha1/chunk_picker.hpp b/solanaceae/ngc_ft1_sha1/chunk_picker.hpp index ef1de51..5ca9bf3 100644 --- a/solanaceae/ngc_ft1_sha1/chunk_picker.hpp +++ b/solanaceae/ngc_ft1_sha1/chunk_picker.hpp @@ -30,7 +30,7 @@ struct ChunkPickerTimer { struct ChunkPicker { // max transfers static constexpr size_t max_tf_info_requests {1}; - static constexpr size_t max_tf_chunk_requests {3}; // TODO: dynamic, function/factor of (window(delay*speed)/chunksize) + static constexpr size_t max_tf_chunk_requests {4}; // TODO: dynamic, function/factor of (window(delay*speed)/chunksize) // TODO: cheaper init? tls rng for deep seeding? std::minstd_rand _rng{std::random_device{}()}; diff --git a/solanaceae/ngc_ft1_sha1/components.hpp b/solanaceae/ngc_ft1_sha1/components.hpp index 1922a06..d428791 100644 --- a/solanaceae/ngc_ft1_sha1/components.hpp +++ b/solanaceae/ngc_ft1_sha1/components.hpp @@ -7,11 +7,13 @@ #include #include +#include #include "./ft1_sha1_info.hpp" #include "./hash_utils.hpp" #include +#include // TODO: rename to object components @@ -94,5 +96,34 @@ namespace Components { uint64_t offset_into_file {0u}; }; + // this is per object/content + // more aplicable than "separated", so should be supported by most backends + struct TransferStats { + // in bytes per second + float rate_up {0.f}; + float rate_down {0.f}; + + // bytes + uint64_t total_up {0u}; + uint64_t total_down {0u}; + }; + + struct TransferStatsSeparated { + entt::dense_map stats; + }; + + // used to populate stats + struct TransferStatsTally { + struct Peer { + struct Entry { + float time_since {0.f}; + size_t bytes {0u}; + }; + std::deque recently_sent; + std::deque recently_received; + }; + entt::dense_map tally; + }; + } // Components diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.hpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.hpp index 4ea2061..e1c4ad4 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.hpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.hpp @@ -100,7 +100,7 @@ class SHA1_NGCFT1 : public ToxEventI, public RegistryMessageModelEventI, public bool _udp_only {false}; size_t _max_concurrent_in {4}; // info only - size_t _max_concurrent_out {3*4}; // HACK: allow ideal number for 4 peers + size_t _max_concurrent_out {4*10}; // HACK: allow "ideal" number for 10 peers public: SHA1_NGCFT1(