diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2011-10-25 14:11:13 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2011-10-25 16:47:27 +0200 |
commit | 7fbc0184334da7325d983d187ee14fdc0326123a (patch) | |
tree | 63ca6a9e69485bee82b4bfd22415fad76f412fba /src/or/rephist.c | |
parent | ea0518f209959250dd07272d739a6d9aa9531444 (diff) | |
download | tor-7fbc0184334da7325d983d187ee14fdc0326123a.tar.gz tor-7fbc0184334da7325d983d187ee14fdc0326123a.zip |
Add percentiles to the desc stats reporting
To get a better idea what's going on on Tonga, add some code to report
how often the most and least frequently fetched descriptor was fetched,
as well as 25, 50, 75 percentile.
Also ensure we only count bridge descriptors here.
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index f8ebe644fc..359e4886a3 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -2643,7 +2643,7 @@ rep_hist_reset_desc_stats(time_t now) void rep_hist_desc_stats_term(void) { - digestmap_free(served_descs, NULL); + digestmap_free(served_descs, _tor_free); served_descs = NULL; start_of_served_descs_stats_interval = 0; total_descriptor_downloads = 0; @@ -2659,18 +2659,43 @@ rep_hist_format_desc_stats(time_t now) char t[ISO_TIME_LEN+1]; char *result; + digestmap_iter_t *iter; + const char *key; + void *val; + unsigned size; + int *vals; + int n = 0, *count; + if (!start_of_served_descs_stats_interval) return NULL; + size = digestmap_size(served_descs); + vals = tor_malloc(size * sizeof(int)); + + for (iter = digestmap_iter_init(served_descs); !digestmap_iter_done(iter); + iter = digestmap_iter_next(served_descs, iter) ) { + digestmap_iter_get(iter, &key, &val); + count = val; + vals[n++] = *count; + (void)key; + } + format_iso_time(t, now); tor_asprintf(&result, - "served-descs-stats-end %s (%d s) total=%lu unique=%u\n", + "served-descs-stats-end %s (%d s) total=%lu unique=%u " + "max=%d q3=%d md=%d q1=%d min=%d\n", t, (unsigned) (now - start_of_served_descs_stats_interval), total_descriptor_downloads, - digestmap_size(served_descs)); - + size, + find_nth_int(vals, size, size-1), + find_nth_int(vals, size, (3*size-1)/4), + find_nth_int(vals, size, (size-1)/2), + find_nth_int(vals, size, (size-1)/4), + find_nth_int(vals, size, 0)); + + tor_free(vals); return result; } @@ -2712,9 +2737,17 @@ rep_hist_desc_stats_write(time_t now) void rep_hist_note_desc_served(const char * desc) { + int *val; if (!served_descs) return; // We're not collecting stats - digestmap_set(served_descs, desc, (void *)1); + val = digestmap_get(served_descs, desc); + if (!val) { + val = tor_malloc(sizeof(int)); + *val = 1; + digestmap_set(served_descs, desc, val); + } else { + (*val)++; + } total_descriptor_downloads++; } |