diff options
author | Russell Bryant <russell@russellbryant.com> | 2009-03-25 21:57:19 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2009-03-25 21:57:19 +0000 |
commit | ee77b475f2177c07e4208d24d9258e9ebc4008b5 (patch) | |
tree | fddbbf5a3e995692c45ca8a1952d3319299a01c6 /channels | |
parent | 9ae51a21c0a247d1ebf2373660064b53fb6d387a (diff) |
Improve performance of the ast_event cache functionality.
This code comes from svn/asterisk/team/russell/event_performance/.
Here is a summary of the changes that have been made, in order of both
invasiveness and performance impact, from smallest to largest.
1) Asterisk 1.6.1 introduces some additional logic to be able to handle
distributed device state. This functionality comes at a cost.
One relatively minor change in this patch is that the extra processing
required for distributed device state is now completely bypassed if
it's not needed.
2) One of the things that I noticed when profiling this code was that a
_lot_ of time was spent doing string comparisons. I changed the way
strings are represented in an event to include a hash value at the front.
So, before doing a string comparison, we do an integer comparison on the
hash.
3) Finally, the code that handles the event cache has been re-written.
I tried to do this in a such a way that it had minimal impact on the API.
I did have to change one API call, though - ast_event_queue_and_cache().
However, the way it works now is nicer, IMO. Each type of event that
can be cached (MWI, device state) has its own hash table and rules for
hashing and comparing objects. This by far made the biggest impact on
performance.
For additional details regarding this code and how it was tested, please see the
review request.
(closes issue #14738)
Reported by: russell
Review: http://reviewboard.digium.com/r/205/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@184339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_dahdi.c | 6 | ||||
-rw-r--r-- | channels/chan_iax2.c | 2 | ||||
-rw-r--r-- | channels/chan_mgcp.c | 1 | ||||
-rw-r--r-- | channels/chan_sip.c | 7 | ||||
-rw-r--r-- | channels/chan_unistim.c | 1 |
5 files changed, 2 insertions, 15 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 6e765ec69..6df93c795 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -2959,10 +2959,7 @@ static void notify_message(char *mailbox_full, int thereornot) return; } - ast_event_queue_and_cache(event, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, - AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, - AST_EVENT_IE_END); + ast_event_queue_and_cache(event); if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) { snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot); @@ -3016,7 +3013,6 @@ static int has_voicemail(struct dahdi_pvt *p) event = ast_event_get_cached(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); if (event) { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 48dd24a2a..3d88ecb48 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -7394,8 +7394,6 @@ static int update_registry(struct sockaddr_in *sin, int callno, char *devtype, i event = ast_event_get_cached(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); if (event) { new = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS); diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index de502dac8..1c1482975 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -472,7 +472,6 @@ static int has_voicemail(struct mgcp_endpoint *p) event = ast_event_get_cached(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cntx, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); if (event) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 67d41e4b3..bc121b128 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -18059,10 +18059,7 @@ static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, str AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(new), AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(old), AST_EVENT_IE_END))) { - ast_event_queue_and_cache(event, - AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, - AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, - AST_EVENT_IE_END); + ast_event_queue_and_cache(event); } } @@ -21038,8 +21035,6 @@ static int get_cached_mwi(struct sip_peer *peer, int *new, int *old) event = ast_event_get_cached(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox->mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, S_OR(mailbox->context, "default"), - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, - AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); if (!event) continue; diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 8229c9a32..818a32d71 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -4391,7 +4391,6 @@ static int unistim_send_mwi_to_peer(struct unistimsession *s, unsigned int tick) event = ast_event_get_cached(AST_EVENT_MWI, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, - AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); if (event) { |