[svn-commits] murf: branch murf/bug11210 r99222 - in /team/murf/bug11210: channels/ configs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 22 10:39:02 CST 2008


Author: murf
Date: Sat Jan 19 13:24:14 2008
New Revision: 99222

URL: http://svn.digium.com/view/asterisk?view=rev&rev=99222
Log:
Made IAX hash table sizes settable via the config file.

Modified:
    team/murf/bug11210/channels/chan_iax2.c
    team/murf/bug11210/configs/iax.conf.sample

Change Statistics:
 team/murf/bug11210/channels/chan_iax2.c    |   67 +++++++++++++----
 team/murf/bug11210/configs/iax.conf.sample |   37 +++++++++
 2 files changed, 89 insertions(+), 15 deletions(-)

Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=99222&r1=99221&r2=99222
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Sat Jan 19 13:24:14 2008
@@ -655,18 +655,20 @@
  * containers is considered random, so you will not be able to depend on
  * the order the entires are specified in iax.conf for matching order. */
 #ifdef LOW_MEMORY
-#define MAX_PEER_BUCKETS 17
+static int hash_peer_size = 17;
+static int hash_user_size = 17;
+static int hash_findcallno_size = 17;
+static int hash_findcallno3_size = 17;
+static int hash_findcallno4_size = 17;
 #else
-#define MAX_PEER_BUCKETS 563
+static int hash_peer_size = 563;
+static int hash_user_size = 563;
+static int hash_findcallno_size = 563;
+static int hash_findcallno3_size = 151;
+static int hash_findcallno4_size = 61;
 #endif
+
 static struct ao2_container *peers;
-
-#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
-
-#define MAX_FINDCALL1_BUCKETS 563
-#define MAX_FINDCALL2_BUCKETS 563
-#define MAX_FINDCALL3_BUCKETS 153
-#define MAX_FINDCALL4_BUCKETS 153
 
 static struct ao2_container *users;
 
@@ -11012,6 +11014,41 @@
 			} else {
 				amaflags = format;
 			}
+		} else if (!strcasecmp(v->name, "hash_user")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) > 2) {
+				hash_user_size = i;
+			} else {
+				ast_log(LOG_WARNING, "Invalid hash_user size '%s' at line %d -- should be much larger than 2\n", v->value, v->lineno);
+			}
+		} else if (!strcasecmp(v->name, "hash_peer")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) > 2) {
+				hash_peer_size = i;
+			} else {
+				ast_log(LOG_WARNING, "Invalid hash_peer size '%s' at line %d -- should be much larger than 2\n", v->value, v->lineno);
+			}
+		} else if (!strcasecmp(v->name, "hash_calls")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) > 2) {
+				hash_findcallno_size = i;
+			} else {
+				ast_log(LOG_WARNING, "Invalid hash_calls size '%s' at line %d -- should be much larger than 2\n", v->value, v->lineno);
+			}
+		} else if (!strcasecmp(v->name, "hash_transfers")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) > 2) {
+				hash_findcallno3_size = i;
+			} else {
+				ast_log(LOG_WARNING, "Invalid hash_transfers size '%s' at line %d -- should be much larger than 2\n", v->value, v->lineno);
+			}
+		} else if (!strcasecmp(v->name, "hash_media")) {
+			int i;
+			if (sscanf(v->value, "%d", &i) > 2) {
+				hash_findcallno4_size = i;
+			} else {
+				ast_log(LOG_WARNING, "Invalid hash_media size '%s' at line %d -- should be much larger than 2\n", v->value, v->lineno);
+			}
 		} else if (!strcasecmp(v->name, "language")) {
 			ast_copy_string(language, v->value, sizeof(language));
 		} else if (!strcasecmp(v->name, "maxauthreq")) {
@@ -11940,28 +11977,28 @@
 	int x = 0;
 	struct iax2_registry *reg = NULL;
 
-	peers = ao2_container_alloc(MAX_PEER_BUCKETS, peer_hash_cb, peer_cmp_cb);
+	peers = ao2_container_alloc(hash_peer_size, peer_hash_cb, peer_cmp_cb);
 	if (!peers)
 		return AST_MODULE_LOAD_FAILURE;
-	users = ao2_container_alloc(MAX_USER_BUCKETS, user_hash_cb, user_cmp_cb);
+	users = ao2_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb);
 	if (!users) {
 		ao2_ref(peers, -1);
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall1 = ao2_container_alloc(MAX_FINDCALL1_BUCKETS, findcall1_hash_cb, findcall1_cmp_cb);
+	findcall1 = ao2_container_alloc(hash_findcallno_size, findcall1_hash_cb, findcall1_cmp_cb);
 	if (!findcall1) {
 		ao2_ref(peers, -1);
 		ao2_ref(users, -1);
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall2 = ao2_container_alloc(MAX_FINDCALL2_BUCKETS, findcall2_hash_cb, findcall2_cmp_cb);
+	findcall2 = ao2_container_alloc(hash_findcallno_size, findcall2_hash_cb, findcall2_cmp_cb);
 	if (!findcall1) {
 		ao2_ref(peers, -1);
 		ao2_ref(users, -1);
 		ao2_ref(findcall1, -1);
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall3 = ao2_container_alloc(MAX_FINDCALL3_BUCKETS, findcall3_hash_cb, findcall3_cmp_cb);
+	findcall3 = ao2_container_alloc(hash_findcallno3_size, findcall3_hash_cb, findcall3_cmp_cb);
 	if (!findcall1) {
 		ao2_ref(peers, -1);
 		ao2_ref(users, -1);
@@ -11969,7 +12006,7 @@
 		ao2_ref(findcall2, -1);
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall4 = ao2_container_alloc(MAX_FINDCALL4_BUCKETS, findcall4_hash_cb, findcall4_cmp_cb);
+	findcall4 = ao2_container_alloc(hash_findcallno4_size, findcall4_hash_cb, findcall4_cmp_cb);
 	if (!findcall1) {
 		ao2_ref(peers, -1);
 		ao2_ref(users, -1);

Modified: team/murf/bug11210/configs/iax.conf.sample
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/configs/iax.conf.sample?view=diff&rev=99222&r1=99221&r2=99222
==============================================================================
--- team/murf/bug11210/configs/iax.conf.sample (original)
+++ team/murf/bug11210/configs/iax.conf.sample Sat Jan 19 13:24:14 2008
@@ -246,6 +246,43 @@
 ; See 'qualify' for individual peers to turn on for just a specific peer.
 ;
 autokill=yes
+;
+; hash table sizes
+;
+; hash tables are used for quick lookups of peers, users, and ongoing calls
+; hash sizes, for best results, should be prime numbers.
+; If you set too small a hash size, the system will not break, it will just slow
+; down by degrees.
+;
+; hash_user tells the driver how big to make the user hash table. It should be a number
+; slightly larger than the total number of users (and friends) in your config file.
+; by default, it is set to 563, which should handle smaller to medium sized sites.
+; in small memory situations, it defaults to 17.
+;hash_user = 563
+;
+; hash_peer tells the driver how big to make the peer hash table. It should be a number
+; slightly larger than the total number of peers (and friends) in your config file.
+; by default, it is set to 563, which should handle smaller to medium sized sites.
+; in small memory situations, it defaults to 17.
+;hash_peer = 563
+;
+; hash_calls tells the driver how big to make the callno hash table. It should be a number
+; slightly larger than the total number of simultaneous calls possible.
+; by default, it is set to 563, which should handle smaller to medium sized sites.
+; in small memory situations, it defaults to 17.
+;hash_calls = 563
+;
+; hash_transfers tells the driver how big to make the transfer hash table. It should be a number
+; slightly larger than the total number of simultaneous transfers possible.
+; by default, it is set to 151, which should handle smaller to medium sized sites.
+; in small memory situations, it defaults to 17.
+;hash_transfers = 151
+;
+; hash_media tells the driver how big to make the transfer media hash table. It should be a number
+; slightly larger than the total number of simultaneous transfers in MEDIAPASS mode that are  possible.
+; by default, it is set to 61, which should handle smaller to medium sized sites.
+; in small memory situations, it defaults to 17.
+;hash_media = 61
 ;
 ; codecpriority controls the codec negotiation of an inbound IAX call.
 ; This option is inherited to all user entities.  It can also be defined 




More information about the svn-commits mailing list