fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40716?usp=email )
Change subject: s1ap_proxy: cache GlobalENBId string ......................................................................
s1ap_proxy: cache GlobalENBId string
Avoid calling genb_id_str/1 every time a counter is incremented. Generate the string once, cache, and use it in ctr_inc/2.
Change-Id: I68d394213563c68757b7490e6af2321259feda4f Related: SYS#7065 --- M src/s1ap_proxy.erl 1 file changed, 6 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/16/40716/1
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index f2fd722..fdcf98c 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -73,6 +73,7 @@ -record(proxy_state, {erabs :: dict:dict(), enb_id :: undefined | non_neg_integer(), plmn_id :: undefined | plmn_id(), + genb_id_str :: undefined | string(), mme_ue_id :: undefined | mme_ue_id(), enb_ue_id :: undefined | enb_ue_id(), erab_id :: undefined | erab_id(), @@ -233,12 +234,10 @@ parse_enb_id({'long-macroENB-ID', << ID:21 >>}) -> ID.
--spec genb_id_str(proxy_state()) -> string() | none. +-spec genb_id_str(proxy_state()) -> string(). genb_id_str(#proxy_state{plmn_id = {MCC, MNC}, enb_id = ENBId}) -> - MCC ++ "-" ++ MNC ++ "-" ++ integer_to_list(ENBId); - -genb_id_str(#proxy_state{}) -> none. + MCC ++ "-" ++ MNC ++ "-" ++ integer_to_list(ENBId).
%% register a single per-eNB counter @@ -266,8 +265,8 @@ when C0 :: [ctr | _], S :: proxy_state(). ctr_inc([ctr | _] = C0, S) -> - case genb_id_str(S) of - none -> + case S#proxy_state.genb_id_str of + undefined -> %% increment the global counter only s1gw_metrics:ctr_inc(C0); GlobalENBId -> @@ -643,7 +642,7 @@ set_logging_prefix("eNB " ++ GlobalENBId), %% register per-eNB metrics ctr_reg_all(GlobalENBId), - {{ok, C}, S1}; + {{ok, C}, S1#proxy_state{genb_id_str = GlobalENBId}};
%% E-RAB SETUP REQUEST related IEs handle_ie([?'id-E-RABToBeSetupListBearerSUReq'], C, S) ->