add max hop count buckets to see how bad hopcounts are
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 7 Mar 2012 06:02:41 +0000 (17:02 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 20 Mar 2012 00:20:53 +0000 (11:20 +1100)
(This used to be ctdb commit 7d3931298e6477d92f43652c3006b0c426cb1307)

ctdb/include/ctdb_protocol.h
ctdb/server/ctdb_call.c
ctdb/tools/ctdb.c

index 3e466d83dbcc556c4066de1fd3a00a22ae762ccc..6c1cc647529fc500a32868e2b3bbf5c4d7f7967d 100644 (file)
@@ -646,6 +646,8 @@ 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];
        struct latency_counter call_latency;
        struct latency_counter lockwait_latency;
        struct latency_counter childwrite_latency;
index 50f4cb2e1f7d442cb0b2609bd9d5f82ca5e95fee..7e617103409ecbf184054f7f01408da20c0105c9 100644 (file)
@@ -465,6 +465,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        struct ctdb_ltdb_header header;
        struct ctdb_call *call;
        struct ctdb_db_context *ctdb_db;
+       int tmp_count, bucket;
 
        if (ctdb->methods == NULL) {
                DEBUG(DEBUG_INFO,(__location__ " Failed ctdb_request_call. Transport is DOWN\n"));
@@ -629,6 +630,17 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        }
 
        CTDB_UPDATE_STAT(ctdb, max_hop_count, c->hopcount);
+       tmp_count = c->hopcount;
+       bucket = 0;
+       while (tmp_count) {
+               tmp_count >>= 2;
+               bucket++;
+       }
+       if (bucket >= MAX_HOP_COUNT_BUCKETS) {
+               bucket = MAX_HOP_COUNT_BUCKETS - 1;
+       }
+       CTDB_INCREMENT_STAT(ctdb, hop_count_bucket[bucket]);
+
 
        /* Try if possible to migrate the record off to the caller node.
         * From the clients perspective a fetch of the data is just as 
index 756671b75d99be34fb4e3cd5d554172b86292b3d..3f112072732f21f73518da7ba334959d241550c1 100644 (file)
@@ -346,6 +346,7 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
                STATISTICS_FIELD(total_ro_delegations),
                STATISTICS_FIELD(total_ro_revokes),
        };
+       
        tmp = s->statistics_current_time.tv_sec - s->statistics_start_time.tv_sec;
        seconds = tmp%60;
        tmp    /= 60;
@@ -441,6 +442,11 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
                               preflen?0:4, "",
                               *(uint32_t *)(fields[i].offset+(uint8_t *)s));
                }
+               printf("Max hop count buckets:");
+               for (i=0;i<MAX_HOP_COUNT_BUCKETS;i++) {
+                       printf(" %d", s->hop_count_bucket[i]);
+               }
+               printf("\n");
                printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "reclock_ctdbd       MIN/AVG/MAX", s->reclock.ctdbd.min, s->reclock.ctdbd.num?s->reclock.ctdbd.total/s->reclock.ctdbd.num:0.0, s->reclock.ctdbd.max, s->reclock.ctdbd.num);
 
                printf(" %-30s     %.6f/%.6f/%.6f sec out of %d\n", "reclock_recd       MIN/AVG/MAX", s->reclock.recd.min, s->reclock.recd.num?s->reclock.recd.total/s->reclock.recd.num:0.0, s->reclock.recd.max, s->reclock.recd.num);