tweak ft max numbers and add stats comp

This commit is contained in:
Green Sky 2024-07-12 15:04:49 +02:00
parent eff25cb10b
commit 31253f5708
No known key found for this signature in database
3 changed files with 33 additions and 2 deletions

View File

@ -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{}()};

View File

@ -7,11 +7,13 @@
#include <solanaceae/util/bitset.hpp>
#include <entt/container/dense_set.hpp>
#include <entt/container/dense_map.hpp>
#include "./ft1_sha1_info.hpp"
#include "./hash_utils.hpp"
#include <vector>
#include <deque>
// 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<Contact3, TransferStats> stats;
};
// used to populate stats
struct TransferStatsTally {
struct Peer {
struct Entry {
float time_since {0.f};
size_t bytes {0u};
};
std::deque<Entry> recently_sent;
std::deque<Entry> recently_received;
};
entt::dense_map<Contact3, Peer> tally;
};
} // Components

View File

@ -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(