2
0
Эх сурвалжийг харах

modules/ims_usrloc_scscf: added coutners for reporting hashtable usage
- collision slot count for impus, contacts and subscriptions

jaybeepee 10 жил өмнө
parent
commit
9874185397

+ 2 - 2
modules/ims_usrloc_scscf/impurecord.c

@@ -849,7 +849,7 @@ int update_impurecord(struct udomain* _d, str* public_identity, impurecord_t* im
             if (compare_subscription(subs_ptr, subscription) != 0) {
                 subs_ptr = subscription;
             } else {
-                // Treat it as a new Subscription - it's not the same as the previos one
+                // Treat it as a new Subscription - it's not the same as the previous one
                 ref_subscription_unsafe(subs_ptr); //we reference coz we are using it - will be unreferenced later.
                 add_subscription_unsafe(subs_ptr);
                 unlock_subscription_slot(subs_ptr->sl);
@@ -1071,7 +1071,7 @@ void ref_subscription_unsafe(ims_subscription* s) {
 }
 
 /**
- * @brief unref a subscription - assume slot and subsription locked!
+ * @brief unref a subscription - assume slot and subscription locked!
  * @param s
  */
 void unref_subscription_unsafe(ims_subscription* s) {

+ 23 - 2
modules/ims_usrloc_scscf/udomain.c

@@ -256,9 +256,10 @@ void mem_delete_impurecord(udomain_t* _d, struct impurecord* _r) {
 void mem_timer_udomain(udomain_t* _d) {
     struct impurecord* ptr, *t;
     struct ucontact* contact_ptr;
-    int i;
+    int i, n, temp;
 
     //go through contacts first
+    n = contact_list->max_collisions;
     LM_DBG("*** mem_timer_udomain - checking contacts - START ***\n");
     for (i = 0; i < contact_list->size; i++) {
         lock_contact_slot_i(i);
@@ -268,11 +269,16 @@ void mem_timer_udomain(udomain_t* _d) {
 		//contacts are now deleted during impurecord processing
             contact_ptr = contact_ptr->next;
         } 
+        if (contact_list->slot[i].n > n) {
+            n = contact_list->slot[i].n;
+        }
         unlock_contact_slot_i(i);
+        contact_list->max_collisions = n;
     }
     LM_DBG("*** mem_timer_udomain - checking contacts - FINISHED ***\n");
 
-    int temp = 0;
+    temp = 0;
+    n = _d->max_collisions;
 
     LM_DBG("*** mem_timer_udomain - checking IMPUs - START ***\n");
     for (i = 0; i < _d->size; i++) {
@@ -293,9 +299,24 @@ void mem_timer_udomain(udomain_t* _d) {
             LM_DBG("ULSLOT %d UN-LOCKED\n", i);
 #endif
         }
+        if (_d->table[i].n > n)
+            n = _d->table[i].n;
+        
         unlock_ulslot(_d, i);
+        _d->max_collisions = n;
     }
     LM_DBG("*** mem_timer_udomain - checking IMPUs - FINISHED ***\n");
+    
+    n = ims_subscription_list->max_collisions;
+    for (i = 0; i < ims_subscription_list->size; i++) {
+        lock_subscription_slot(i);
+        if (ims_subscription_list->slot[i].n > n) {
+            n = ims_subscription_list->slot[i].n;
+        }
+        unlock_subscription_slot(i);
+    }
+    ims_subscription_list->max_collisions = n;
+    
 }
 
 

+ 1 - 0
modules/ims_usrloc_scscf/udomain.h

@@ -72,6 +72,7 @@ struct udomain {
     str* name; /*!< Domain name (NULL terminated) */
     int size; /*!< Hash table size */
     struct hslot* table; /*!< Hash table - array of collision slots */
+    int max_collisions;
 };
 
 

+ 30 - 14
modules/ims_usrloc_scscf/ul_scscf_stats.c

@@ -1,17 +1,23 @@
 #include "ul_scscf_stats.h"
 #include "usrloc.h"
+#include "dlist.h"
 
 extern struct ims_subscription_list* ims_subscription_list;
+extern struct contact_list* contact_list;
 
 struct ul_scscf_counters_h ul_scscf_cnts_h;
-enum ul_scscf_info_req { ULSCSF_SUBSCRIPTIONCOUNT };
+enum ul_scscf_info_req { ULSCSF_SUBSCRIPTIONCOLLISIONS, ULSCSCF_CONTACT_COLLISIONS, ULSCSCF_IMPUCOLLISIONS };
 
-//static counter_val_t ims_usrloc_scscf_internal_stats(counter_handle_t h, void* what);
+static counter_val_t ims_usrloc_scscf_internal_stats(counter_handle_t h, void* what);
 
 counter_def_t ul_scscf_cnt_defs[] = {
     {&ul_scscf_cnts_h.active_subscriptions, "active_subscriptions", 0, 0, 0, "active_subscriptions"},
-//    {&ul_scscf_cnts_h.active_subscriptions, "active_subscriptions", 0,
-    //            ims_usrloc_scscf_internal_stats, (void*) (long) ULSCSF_SUBSCRIPTIONCOUNT, "number of registered subscribers (IMPIs)"},
+    {&ul_scscf_cnts_h.subscription_collisions, "subscription_collisions", 0,
+                ims_usrloc_scscf_internal_stats, (void*) (long) ULSCSF_SUBSCRIPTIONCOLLISIONS, "number of collisions in subscription hash"},
+    {&ul_scscf_cnts_h.impu_collisions, "impu_collisions", 0,
+                ims_usrloc_scscf_internal_stats, (void*) (long) ULSCSCF_IMPUCOLLISIONS, "number of collisions in impu hash"},
+    {&ul_scscf_cnts_h.contact_collisions, "contact_collisions", 0,
+                ims_usrloc_scscf_internal_stats, (void*) (long) ULSCSCF_CONTACT_COLLISIONS, "number of collisions in contact hash"},                
     {&ul_scscf_cnts_h.active_impus, "active_impus", 0, 0, 0, "number of registered IMPUs"},
     {&ul_scscf_cnts_h.active_contacts, "active_contacts", 0, 0, 0, "number of registered contacts"},
     {0, 0, 0, 0, 0, 0}};
@@ -28,15 +34,25 @@ void ul_scscf_destroy_counters() {
     
 }
 
+static str domain_str={"location", 8};
 /** helper function for some stats (which are kept internally). to be used in future...
  */
-//static counter_val_t ims_usrloc_scscf_internal_stats(counter_handle_t h, void* what) {
-//    enum ul_scscf_info_req w;
-//
-//    w = (int) (long) what;
-//    switch (w) {
-//	case ULSCSF_SUBSCRIPTIONCOUNT:
-//	    return ims_subscription_list->subscriptions;
-//    };
-//    return 0;
-//}
+static counter_val_t ims_usrloc_scscf_internal_stats(counter_handle_t h, void* what) {
+    enum ul_scscf_info_req w;
+    udomain_t* _d;
+
+    w = (int) (long) what;
+    switch (w) {
+	case ULSCSF_SUBSCRIPTIONCOLLISIONS:
+	    return ims_subscription_list->max_collisions;
+        case ULSCSCF_CONTACT_COLLISIONS:
+            return contact_list->max_collisions;
+        case ULSCSCF_IMPUCOLLISIONS:
+            if (find_domain(&domain_str, &_d) !=0) {
+                return -1;
+                //This is terrible - hardwiring domain to "location" but right now IMS is single domain but has the ability to extend to multiple domains later...
+            };
+            return _d->max_collisions;
+    };
+    return 0;
+}

+ 3 - 0
modules/ims_usrloc_scscf/ul_scscf_stats.h

@@ -17,6 +17,9 @@ struct ul_scscf_counters_h {
     counter_handle_t active_impus;
     counter_handle_t active_contacts;
     counter_handle_t expired_contacts;
+    counter_handle_t subscription_collisions;
+    counter_handle_t impu_collisions;
+    counter_handle_t contact_collisions;
 };
 
 int ul_scscf_init_counters();

+ 2 - 0
modules/ims_usrloc_scscf/usrloc.h

@@ -420,6 +420,7 @@ typedef struct impurecord_info {
 typedef struct contact_list {
     struct contact_hslot* slot;
     int size;
+    int max_collisions;
 //    stat_var *contacts;        /*!< no of contacts in table */
 }contact_list_t;
 
@@ -427,6 +428,7 @@ typedef struct ims_subscription_list {
     struct hslot_sp* slot;
     int size;               /* size of list (slots) */
     int subscriptions;      /* total number of subscriptions in storage */
+    int max_collisions;
 }ims_subscription_list_t;
 
 typedef int (*insert_impurecord_t)(struct udomain* _d, str* public_identity, str* private_identity, int reg_state, int barring,