From 08fdff451166068f3e7e2ba6c915ab3034e6c969 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 11 Dec 2012 16:35:53 -0500 Subject: [PATCH 1/4] don't block on db for fifo track_calls --- src/mod/applications/mod_fifo/mod_fifo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 1a6ed6dc27..e7388a9b9a 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2217,7 +2217,7 @@ SWITCH_STANDARD_APP(fifo_track_call_function) sql = switch_mprintf("update fifo_outbound set stop_time=0,start_time=%ld,outbound_fail_count=0,use_count=use_count+1,%s=%s+1,%s=%s+1 where uuid='%q'", (long) switch_epoch_time_now(NULL), col1, col1, col2, col2, data); - fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE); + fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_FALSE); if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) { From 61ca331a28b229488d3f361c239e215a11bdb5ca Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Dec 2012 14:04:58 -0600 Subject: [PATCH 2/4] FS-4928 --- src/switch_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_event.c b/src/switch_event.c index 32bc5b2d2d..b93f8746ad 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -766,13 +766,13 @@ SWITCH_DECLARE(switch_status_t) switch_event_del_header_val(switch_event_t *even unsigned long hash = 0; tp = event->headers; + hash = switch_ci_hashfunc_default(header_name, &hlen); while (tp) { hp = tp; tp = tp->next; x++; switch_assert(x < 1000000); - hash = switch_ci_hashfunc_default(header_name, &hlen); if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name) && (zstr(val) || !strcmp(hp->value, val))) { if (lp) { From 5d35d71cfde988c66a1fd6c2a26c17155f86949f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Dec 2012 19:18:25 -0600 Subject: [PATCH 3/4] FS-4928 doing 100 calls I found 7 million calls to toupper, this patch replaces it with an inline optimized one I found online. Not sure it helps but maybe you can profile it again with latest. --- src/include/switch_utils.h | 13 ++++++++++++- src/switch_utils.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index c9e2c189c8..92618a81d5 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -40,7 +40,18 @@ #include -SWITCH_BEGIN_EXTERN_C SWITCH_DECLARE(int) switch_toupper(int c); +SWITCH_BEGIN_EXTERN_C + +/* https://code.google.com/p/stringencoders/wiki/PerformanceAscii */ +static inline uint32_t switch_toupper(uint32_t eax) +{ + uint32_t ebx = (0x7f7f7f7ful & eax) + 0x05050505ul; + ebx = (0x7f7f7f7ful & ebx) + 0x1a1a1a1aul; + ebx = ((ebx & ~eax) >> 2 ) & 0x20202020ul; + return eax - ebx; +} + +SWITCH_DECLARE(int) old_switch_toupper(int c); SWITCH_DECLARE(int) switch_tolower(int c); SWITCH_DECLARE(int) switch_isalnum(int c); SWITCH_DECLARE(int) switch_isalpha(int c); diff --git a/src/switch_utils.c b/src/switch_utils.c index 4335b4dcd3..83b77744a3 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -2609,7 +2609,7 @@ const short _switch_C_toupper_[1 + SWITCH_CTYPE_NUM_CHARS] = { const short *_switch_toupper_tab_ = _switch_C_toupper_; -SWITCH_DECLARE(int) switch_toupper(int c) +SWITCH_DECLARE(int) old_switch_toupper(int c) { if ((unsigned int) c > 255) return (c); From 063962cae0dead938889d79ef51c693b6c9c306a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Dec 2012 20:12:25 -0600 Subject: [PATCH 4/4] add switch_toupper_max to uppercase a string 4 bytes at a time with new switch_toupper function --- src/include/switch_utils.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 92618a81d5..b23ebf5445 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -51,6 +51,37 @@ static inline uint32_t switch_toupper(uint32_t eax) return eax - ebx; } + +static inline void switch_toupper_max(char *s) +{ + uint32_t *b,*p; + char *c; + size_t l; + int div = 0, rem = 0; + int i; + + l = strlen(s); + div = l / 4; + rem = l % 4; + + p = (uint32_t *) s; + + for (i = 0; i < div; i++) { + b = p; + *b = (uint32_t) switch_toupper(*b); + b++; + p++; + } + + c = (char *)p; + + for (i = 0; i < rem; i++) { + *c = (char) switch_toupper(*c); + c++; + } +} + + SWITCH_DECLARE(int) old_switch_toupper(int c); SWITCH_DECLARE(int) switch_tolower(int c); SWITCH_DECLARE(int) switch_isalnum(int c);