Module: kamailio Branch: master Commit: 430696019c23e7c019cb463ac84f76762ee9c2f1 URL: https://github.com/kamailio/kamailio/commit/430696019c23e7c019cb463ac84f7676...
Author: Henning Westerholt hw@kamailio.org Committer: Henning Westerholt hw@kamailio.org Date: 2018-03-12T21:31:57+01:00
core: performance optimzation for commit af3f94dd, add unlikely compiler builtin
- performance optimization for commit af3f94dd, default deactivated - this affect a really hot code path in the core receive part - add unlikely compiler builtin_expect, like in other places of the core
---
Modified: src/core/receive.c
---
Diff: https://github.com/kamailio/kamailio/commit/430696019c23e7c019cb463ac84f7676... Patch: https://github.com/kamailio/kamailio/commit/430696019c23e7c019cb463ac84f7676...
---
diff --git a/src/core/receive.c b/src/core/receive.c index b1feba0616..be585eb0ad 100644 --- a/src/core/receive.c +++ b/src/core/receive.c @@ -242,8 +242,8 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info) /* ... clear branches from previous message */ clear_branches();
- if(ksr_route_locks_set!=NULL && msg->callid && msg->callid->body.s - && msg->callid->body.len >0) { + if(unlikely(ksr_route_locks_set!=NULL && msg->callid && msg->callid->body.s + && msg->callid->body.len >0)) { cidlockidx = get_hash1_raw(msg->callid->body.s, msg->callid->body.len); cidlockidx = cidlockidx % ksr_route_locks_set->size; cidlockset = 1; @@ -309,23 +309,23 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info) LM_ERR("no config routing engine registered\n"); goto error_req; } - if(cidlockset) + if(unlikely(cidlockset) ) rec_lock_set_get(ksr_route_locks_set, cidlockidx); if(keng->froute(msg, REQUEST_ROUTE, NULL, NULL) < 0) { LM_NOTICE("negative return code from engine function\n"); } - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_release(ksr_route_locks_set, cidlockidx); } else { - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_get(ksr_route_locks_set, cidlockidx); if(run_top_route(main_rt.rlist[DEFAULT_RT], msg, 0) < 0) { - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_release(ksr_route_locks_set, cidlockidx); LM_WARN("error while trying script\n"); goto error_req; } - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_release(ksr_route_locks_set, cidlockidx); }
@@ -385,17 +385,17 @@ int receive_msg(char *buf, unsigned int len, struct receive_info *rcv_info) bctx = sr_kemi_act_ctx_get(); init_run_actions_ctx(&ctx); sr_kemi_act_ctx_set(&ctx); - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_get(ksr_route_locks_set, cidlockidx); ret = keng->froute(msg, CORE_ONREPLY_ROUTE, NULL, NULL); - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_release(ksr_route_locks_set, cidlockidx); sr_kemi_act_ctx_set(bctx); } else { - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_get(ksr_route_locks_set, cidlockidx); ret = run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, &ctx); - if(cidlockset) + if(unlikely(cidlockset)) rec_lock_set_release(ksr_route_locks_set, cidlockidx); } #ifndef NO_ONREPLY_ROUTE_ERROR