pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42108?usp=email )
Change subject: ss7_as: Optimize ASP Tx selection in Override traffic mode ......................................................................
ss7_as: Optimize ASP Tx selection in Override traffic mode
Cache the last selected ASP, and expect it to still be the active ASP most of the time until it changes.
Change-Id: I3d480d23591f4bd216293be60b22389b182fd8f3 --- M src/ss7_as.c 1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/08/42108/1
diff --git a/src/ss7_as.c b/src/ss7_as.c index f5f7c82..aa53e9d 100644 --- a/src/ss7_as.c +++ b/src/ss7_as.c @@ -402,8 +402,16 @@ { struct ss7_as_asp_assoc *assoc;
- llist_for_each_entry(assoc, &as->asp_list, as_entry) { - if (osmo_ss7_asp_active(assoc->asp)) + /* Hot path: Override traffic mode has only max 1 active ASP at a time. + * Unless there's a change in state, the last ASP used to transmit is most + * probably the active one: */ + if (as->last_asp_idx_sent && osmo_ss7_asp_active(as->last_asp_idx_sent->asp)) + return as->last_asp_idx_sent->asp; + + /* Slow path: Activate ASP changed, look it up: */ + for (unsigned int i = 0; i < as->num_asps; i++) { + assoc = ss7_as_asp_assoc_llist_round_robin(as, &as->last_asp_idx_sent); + if (assoc && osmo_ss7_asp_active(assoc->asp)) return assoc->asp; } return NULL;