Skip to content

Commit a57502d

Browse files
frankistcodebot
authored andcommitted
sched: fix comments
1 parent 3e96b94 commit a57502d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/scheduler/policy/scheduler_time_pf.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
using namespace srsran;
1414

15+
// [Implementation-defined] Limit for the coefficient of the proportional fair metric to avoid issues with double
16+
// imprecision.
17+
constexpr unsigned MAX_PF_COEFF = 10;
18+
1519
scheduler_time_pf::scheduler_time_pf(const scheduler_ue_expert_config& expert_cfg_) :
1620
fairness_coeff(std::get<time_pf_scheduler_expert_config>(expert_cfg_.strategy_cfg).pf_sched_fairness_coeff)
1721
{
@@ -371,14 +375,16 @@ void scheduler_time_pf::ue_ctxt::compute_dl_prio(const slice_ue& u,
371375
const double current_total_avg_rate = total_dl_avg_rate();
372376
double pf_weight = 0;
373377
if (current_total_avg_rate != 0) {
374-
if (parent->fairness_coeff >= 10) {
375-
// avoid overflow
378+
if (parent->fairness_coeff >= MAX_PF_COEFF) {
379+
// For very high coefficients, the pow(.) will be very high, leading to pf_weight of 0 due to lack of precision.
380+
// In such scenarios, we change the way to compute the PF weight. Instead, we completely disregard the estimated
381+
// rate, as its impact is minimal.
376382
pf_weight = 1 / current_total_avg_rate;
377383
} else {
378384
pf_weight = estimated_rate / pow(current_total_avg_rate, parent->fairness_coeff);
379385
}
380386
} else {
381-
// give the highest priority to new UE.
387+
// Give the highest priority to new UE.
382388
pf_weight = estimated_rate == 0 ? 0 : std::numeric_limits<double>::max();
383389
}
384390
const double rate_weight = compute_dl_rate_weight(
@@ -463,8 +469,10 @@ void scheduler_time_pf::ue_ctxt::compute_ul_prio(const slice_ue& u,
463469
const double current_avg_rate = total_ul_avg_rate();
464470
double pf_weight = 0;
465471
if (current_avg_rate != 0) {
466-
if (parent->fairness_coeff > 10) {
467-
// avoid overflow
472+
if (parent->fairness_coeff >= MAX_PF_COEFF) {
473+
// For very high coefficients, the pow(.) will be very high, leading to pf_weight of 0 due to lack of precision.
474+
// In such scenarios, we change the way to compute the PF weight. Instead, we completely disregard the estimated
475+
// rate, as its impact is minimal.
468476
pf_weight = 1 / current_avg_rate;
469477
} else {
470478
pf_weight = estimated_rate / pow(current_avg_rate, parent->fairness_coeff);

0 commit comments

Comments
 (0)