From 770021e36487106409713172b58f3c63854ea58a Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 11 Mar 2021 11:06:05 +0000 Subject: [PATCH] remove uneeded formatting and std::string creation/allocation in scheduler --- .../hdr/stack/mac/sched_ue_ctrl/sched_lch.h | 2 +- srsenb/src/stack/mac/sched_ue.cc | 15 ++++++++----- .../src/stack/mac/sched_ue_ctrl/sched_lch.cc | 22 +++++++++++++------ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h index 059f6477b..4876fbfd1 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h @@ -55,7 +55,7 @@ public: int get_bsr_with_overhead(uint32_t lcid) const; int get_max_prio_lcid() const; - std::string get_bsr_text() const; + const std::array& get_bsr_state() const; // Control Element Command queue using ce_cmd = srslte::dl_sch_lcid; diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index 41dba6d4e..cdd92fa45 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -15,8 +15,9 @@ #include "srsenb/hdr/stack/mac/sched.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" #include "srsenb/hdr/stack/mac/sched_ue.h" -#include "srslte/common/log_helper.h" #include "srslte/common/logmap.h" +#include "srslte/common/string_helpers.h" +#include "srslte/srslog/bundled/fmt/ranges.h" using srslte::tti_interval; @@ -942,10 +943,14 @@ uint32_t sched_ue::get_pending_ul_new_data(tti_point tti_tx_ul, int this_enb_cc_ pending_data = (pending_data > pending_ul_data) ? pending_data - pending_ul_data : 0; if (pending_data > 0) { - logger.debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s", - pending_data, - pending_ul_data, - lch_handler.get_bsr_text().c_str()); + if (logger.debug.enabled()) { + fmt::memory_buffer str_buffer; + fmt::format_to(str_buffer, "{}", lch_handler.get_bsr_state()); + logger.debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s", + pending_data, + pending_ul_data, + srslte::to_c_str(str_buffer)); + } } return pending_data; } diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc index 66711a394..c49d39cee 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc @@ -12,7 +12,8 @@ #include "srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" -#include "srslte/common/log_helper.h" +#include "srslte/common/string_helpers.h" +#include "srslte/srslog/bundled/fmt/ranges.h" namespace srsenb { @@ -110,7 +111,11 @@ void lch_ue_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) return; } lcg_bsr[lcg_id] = bsr; - logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, get_bsr_text().c_str()); + if (logger.debug.enabled()) { + fmt::memory_buffer str_buffer; + fmt::format_to(str_buffer, "{}", get_bsr_state()); + logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, srslte::to_c_str(str_buffer)); + } } void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) @@ -120,7 +125,12 @@ void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) return; } lcg_bsr[lch[lcid].cfg.group] += bytes; - logger.debug("SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, get_bsr_text().c_str()); + if (logger.debug.enabled()) { + fmt::memory_buffer str_buffer; + fmt::format_to(str_buffer, "{}", get_bsr_state()); + logger.debug( + "SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, srslte::to_c_str(str_buffer)); + } } void lch_ue_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) @@ -321,11 +331,9 @@ int lch_ue_manager::get_bsr_with_overhead(uint32_t lcg) const return get_ul_mac_sdu_size_with_overhead(get_bsr(lcg)); } -std::string lch_ue_manager::get_bsr_text() const +const std::array& lch_ue_manager::get_bsr_state() const { - std::stringstream ss; - ss << "{" << lcg_bsr[0] << ", " << lcg_bsr[1] << ", " << lcg_bsr[2] << ", " << lcg_bsr[3] << "}"; - return ss.str(); + return lcg_bsr; } uint32_t allocate_mac_sdus(sched_interface::dl_sched_data_t* data,