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>
Wed, 7 Mar 2012 06:02:41 +0000 (17:02 +1100)
include/ctdb_protocol.h
server/ctdb_call.c
tools/ctdb.c

index be449c3687cc2be6b9b9b2d1e23f0513a13e0775..90af21f574d09f20f9a6a1899311614765cc942a 100644 (file)
@@ -617,6 +617,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 c6065710bec24552a68190dc085540992ee353ae..08710ebe62ef089b7ad785a0a1ae83f0980a5b88 100644 (file)
@@ -466,6 +466,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"));
@@ -519,6 +520,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]);
+
 
        /* if this nodes has done enough consecutive calls on the same record
           then give them the record
index d49bc8f813346c8362d935db51ae1b647e96a71f..0639220a80a1d36f8720a6eba699b9646c72e507 100644 (file)
@@ -202,6 +202,7 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
                STATISTICS_FIELD(memory_used),
                STATISTICS_FIELD(max_hop_count),
        };
+       
        tmp = s->statistics_current_time.tv_sec - s->statistics_start_time.tv_sec;
        seconds = tmp%60;
        tmp    /= 60;
@@ -297,6 +298,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);