mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
integrating the existing state of TON Storage / TON Payments / CPS Fift development branches
This commit is contained in:
parent
040df63c98
commit
4e2624459b
153 changed files with 10760 additions and 1695 deletions
62
rldp2/Bbr.cpp
Normal file
62
rldp2/Bbr.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
#include "Bbr.h"
|
||||
|
||||
#include "BdwStats.h"
|
||||
#include "RttStats.h"
|
||||
|
||||
#include "td/utils/Random.h"
|
||||
|
||||
namespace ton {
|
||||
namespace rldp2 {
|
||||
void Bbr::step(const RttStats &rtt_stats, const BdwStats &bdw_stats, td::uint64 in_flight, td::Timestamp now) {
|
||||
rtt_min_ = rtt_stats.windowed_min_rtt;
|
||||
bdw_max_ = bdw_stats.windowed_max_bdw;
|
||||
if (bdw_max_ > bdw_peak_ * 1.25) {
|
||||
bdw_peak_ = bdw_max_;
|
||||
bdw_peak_at_round = rtt_stats.rtt_round;
|
||||
//LOG(ERROR) << "NEW PEAK " << bdw_peak_ * 768;
|
||||
}
|
||||
|
||||
if (state_ == State::Start && bdw_peak_at_round + 3 < rtt_stats.rtt_round) {
|
||||
//LOG(ERROR) << "START -> DRAIN";
|
||||
state_ = State::Drain;
|
||||
}
|
||||
|
||||
if (state_ == State::Drain && (double)in_flight < bdw_max_ * rtt_min_) {
|
||||
//LOG(ERROR) << "DRAIN -> BPROBE BDW";
|
||||
state_ = State::ProbeBdw;
|
||||
probe_bdw_cycle_ = td::Random::fast(1, 5);
|
||||
probe_bdw_cycle_at_ = now;
|
||||
}
|
||||
|
||||
if (state_ == State::ProbeBdw && td::Timestamp::in(rtt_stats.windowed_min_rtt, probe_bdw_cycle_at_).is_in_past(now)) {
|
||||
probe_bdw_cycle_at_ = now;
|
||||
probe_bdw_cycle_ = (probe_bdw_cycle_ + 1) % 6;
|
||||
//LOG(ERROR) << "NEW PROBE BDW CYCLE";
|
||||
}
|
||||
|
||||
//TODO: ProbeRtt state. Don't want to implenent now without proper tests
|
||||
}
|
||||
|
||||
double Bbr::get_rate() const {
|
||||
if (state_ == State::Start) {
|
||||
return bdw_max_ * 2.8;
|
||||
}
|
||||
if (state_ == State::Drain) {
|
||||
return bdw_max_ / 2.8;
|
||||
}
|
||||
if (state_ == State::ProbeBdw) {
|
||||
constexpr double probe_bdw_gain[6] = {0.75, 1, 1, 1, 1, 1.25};
|
||||
return probe_bdw_gain[probe_bdw_cycle_] * bdw_max_;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
td::uint32 Bbr::get_window_size() const {
|
||||
if (state_ == State::Start || state_ == State::Drain) {
|
||||
return td::max(td::uint32(bdw_max_ * rtt_min_ * 2.8 + 1), 10u);
|
||||
}
|
||||
return td::max(td::uint32(bdw_max_ * rtt_min_ * 2 + 1), 10u);
|
||||
}
|
||||
|
||||
} // namespace rldp2
|
||||
} // namespace ton
|
Loading…
Add table
Add a link
Reference in a new issue