STATISTICS: add per-db hop count statistics
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 20 Mar 2012 01:08:12 +0000 (12:08 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 20 Mar 2012 01:11:55 +0000 (12:11 +1100)
include/ctdb_protocol.h
server/ctdb_call.c
tools/ctdb.c

index 6c1cc647529fc500a32868e2b3bbf5c4d7f7967d..ec52f5626c7b5db60a4e9d1571047ba78a6e95bc 100644 (file)
@@ -603,6 +603,8 @@ struct ctdb_traverse_start_ext {
 /*
   ctdb statistics information
  */
+#define MAX_COUNT_BUCKETS 16
+
 struct ctdb_statistics {
        uint32_t num_clients;
        uint32_t frozen;
@@ -646,8 +648,7 @@ struct ctdb_statistics {
        uint32_t memory_used;
        uint32_t __last_counter; /* hack for control_statistics_all */
        uint32_t max_hop_count;
-#define MAX_HOP_COUNT_BUCKETS 16
-       uint32_t hop_count_bucket[MAX_HOP_COUNT_BUCKETS];
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
        struct latency_counter call_latency;
        struct latency_counter lockwait_latency;
        struct latency_counter childwrite_latency;
@@ -672,6 +673,7 @@ struct ctdb_statistics_wire {
 struct ctdb_db_statistics {
        uint32_t db_ro_delegations;
        uint32_t db_ro_revokes;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
 };
 
 /*
index 7e617103409ecbf184054f7f01408da20c0105c9..c015fbfff6684f7ed660a1717e17eb2575958006 100644 (file)
@@ -636,10 +636,11 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                tmp_count >>= 2;
                bucket++;
        }
-       if (bucket >= MAX_HOP_COUNT_BUCKETS) {
-               bucket = MAX_HOP_COUNT_BUCKETS - 1;
+       if (bucket >= MAX_COUNT_BUCKETS) {
+               bucket = MAX_COUNT_BUCKETS - 1;
        }
        CTDB_INCREMENT_STAT(ctdb, hop_count_bucket[bucket]);
+       CTDB_INCREMENT_DB_STAT(ctdb_db, hop_count_bucket[bucket]);
 
 
        /* Try if possible to migrate the record off to the caller node.
index 28b6e8fc3a014e664747802cd07042bd1b4955d8..893d91fb23b7dbc3be3440930cee8953215e0810 100644 (file)
@@ -443,7 +443,7 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
                               *(uint32_t *)(fields[i].offset+(uint8_t *)s));
                }
                printf(" hop_count_buckets:");
-               for (i=0;i<MAX_HOP_COUNT_BUCKETS;i++) {
+               for (i=0;i<MAX_COUNT_BUCKETS;i++) {
                        printf(" %d", s->hop_count_bucket[i]);
                }
                printf("\n");
@@ -615,6 +615,11 @@ static int control_dbstatistics(struct ctdb_context *ctdb, int argc, const char
        printf("DB Statistics:\n");
        printf("RO Delegations: %d\n", dbstatistics->db_ro_delegations);
        printf("RO Revokes:     %d\n", dbstatistics->db_ro_revokes);
+       printf(" hop_count_buckets:");
+       for (i=0;i<MAX_COUNT_BUCKETS;i++) {
+               printf(" %d", dbstatistics->hop_count_bucket[i]);
+       }
+       printf("\n");
 
        ctdb_free_dbstat(dbstatistics);
        return 0;