fixeria has submitted this change. (
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(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, but someone else must approve
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index 17403ec..9b7a105 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -74,6 +74,7 @@
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(),
@@ -237,12 +238,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
@@ -270,8 +269,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 ->
@@ -662,7 +661,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) ->
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40716?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I68d394213563c68757b7490e6af2321259feda4f
Gerrit-Change-Number: 40716
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>