From 7df308c756194bdc23bedc0a475986873e8a185f Mon Sep 17 00:00:00 2001 From: faluco Date: Tue, 20 Apr 2021 18:28:20 +0200 Subject: [PATCH] Remove two mallocs in the stack: 1) Extend the small buffer to 64bytes for the move_callback class. 2) Replace a std::map for a fixed size circular map in sched_time_pf. --- lib/include/srsran/adt/move_callback.h | 2 +- srsenb/hdr/stack/mac/schedulers/sched_time_pf.h | 6 +++++- srsenb/src/stack/mac/schedulers/sched_time_pf.cc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/include/srsran/adt/move_callback.h b/lib/include/srsran/adt/move_callback.h index fbeef74b6..a80d3aa80 100644 --- a/lib/include/srsran/adt/move_callback.h +++ b/lib/include/srsran/adt/move_callback.h @@ -183,7 +183,7 @@ template constexpr task_details::empty_table_t move_callback::empty_table; //! Generic move task -using move_task_t = move_callback; +using move_task_t = move_callback; } // namespace srsran diff --git a/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h b/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h index f11b59147..6c1d7c5ef 100644 --- a/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h +++ b/srsenb/hdr/stack/mac/schedulers/sched_time_pf.h @@ -14,6 +14,8 @@ #define SRSRAN_SCHED_TIME_PF_H #include "sched_base.h" +#include "srsenb/hdr/common/common_enb.h" +#include "srsran/adt/circular_map.h" #include namespace srsenb { @@ -61,7 +63,9 @@ private: uint32_t dl_nof_samples = 0; uint32_t ul_nof_samples = 0; }; - std::map ue_history_db; + + srsran::static_circular_map ue_history_db; + struct ue_dl_prio_compare { bool operator()(const ue_ctxt* lhs, const ue_ctxt* rhs) const; }; diff --git a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc index 0bef003ea..1bcf98428 100644 --- a/srsenb/src/stack/mac/schedulers/sched_time_pf.cc +++ b/srsenb/src/stack/mac/schedulers/sched_time_pf.cc @@ -39,7 +39,7 @@ void sched_time_pf::new_tti(sched_ue_list& ue_db, sf_sched* tti_sched) for (auto& u : ue_db) { auto it = ue_history_db.find(u.first); if (it == ue_history_db.end()) { - it = ue_history_db.insert(std::make_pair(u.first, ue_ctxt{u.first, fairness_coeff})).first; + it = ue_history_db.insert(u.first, ue_ctxt{u.first, fairness_coeff}).value(); } it->second.new_tti(*cc_cfg, *u.second, tti_sched); if (it->second.dl_newtx_h != nullptr or it->second.dl_retx_h != nullptr) {