diff options
author | erdgeist <> | 2009-08-30 17:57:54 +0000 |
---|---|---|
committer | erdgeist <> | 2009-08-30 17:57:54 +0000 |
commit | 4c4303a15614404535d3be065d213ac8a992b530 (patch) | |
tree | e660f718a3176af0e97c42db6339bbb3b6527aba | |
parent | 517adde681d6aec49f359c4e7925641b1c86a075 (diff) |
Temporary feature: log amount of numwants. See if we can save traffic if we reduce max numwant to something less than 200
-rw-r--r-- | ot_http.c | 14 | ||||
-rw-r--r-- | ot_mutex.h | 1 | ||||
-rw-r--r-- | ot_stats.c | 17 |
3 files changed, 30 insertions, 2 deletions
@@ -171,7 +171,11 @@ static const ot_keywords keywords_mode[] = | |||
171 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, | 171 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, |
172 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, | 172 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, |
173 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, | 173 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, |
174 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG }, { NULL, -3 } }; | 174 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG }, |
175 | #ifdef WANT_LOG_NUMWANT | ||
176 | { "numwants", TASK_STATS_NUMWANTS}, | ||
177 | #endif | ||
178 | { NULL, -3 } }; | ||
175 | static const ot_keywords keywords_format[] = | 179 | static const ot_keywords keywords_format[] = |
176 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, | 180 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, |
177 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; | 181 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; |
@@ -332,6 +336,10 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c | |||
332 | return ws->reply_size; | 336 | return ws->reply_size; |
333 | } | 337 | } |
334 | 338 | ||
339 | #ifdef WANT_LOG_NUMWANT | ||
340 | unsigned long long numwants[201]; | ||
341 | #endif | ||
342 | |||
335 | static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "event", 3 }, { "numwant", 4 }, { "compact", 5 }, { "compact6", 5 }, { "info_hash", 6 }, | 343 | static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "event", 3 }, { "numwant", 4 }, { "compact", 5 }, { "compact6", 5 }, { "info_hash", 6 }, |
336 | #ifdef WANT_IP_FROM_QUERY_STRING | 344 | #ifdef WANT_IP_FROM_QUERY_STRING |
337 | { "ip", 7 }, | 345 | { "ip", 7 }, |
@@ -479,6 +487,10 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, | |||
479 | } | 487 | } |
480 | } | 488 | } |
481 | 489 | ||
490 | #ifdef WANT_LOG_NUMWANT | ||
491 | numwants[numwant]++; | ||
492 | #endif | ||
493 | |||
482 | /* XXX DEBUG */ | 494 | /* XXX DEBUG */ |
483 | stats_issue_event( EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply ); | 495 | stats_issue_event( EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply ); |
484 | 496 | ||
@@ -32,6 +32,7 @@ typedef enum { | |||
32 | TASK_STATS_RENEW = 0x000a, | 32 | TASK_STATS_RENEW = 0x000a, |
33 | TASK_STATS_SYNCS = 0x000b, | 33 | TASK_STATS_SYNCS = 0x000b, |
34 | TASK_STATS_COMPLETED = 0x000c, | 34 | TASK_STATS_COMPLETED = 0x000c, |
35 | TASK_STATS_NUMWANTS = 0x000d, | ||
35 | 36 | ||
36 | TASK_STATS = 0x0100, /* Mask */ | 37 | TASK_STATS = 0x0100, /* Mask */ |
37 | TASK_STATS_TORRENTS = 0x0101, | 38 | TASK_STATS_TORRENTS = 0x0101, |
@@ -135,7 +135,7 @@ static int stats_shift_down_network_count( stats_network_node **node, int depth, | |||
135 | static size_t stats_get_highscore_networks( stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, int limit ) { | 135 | static size_t stats_get_highscore_networks( stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, int limit ) { |
136 | size_t score = 0; | 136 | size_t score = 0; |
137 | int i; | 137 | int i; |
138 | 138 | malloc(100); | |
139 | if( !node ) return 0; | 139 | if( !node ) return 0; |
140 | 140 | ||
141 | if( depth < limit ) { | 141 | if( depth < limit ) { |
@@ -478,6 +478,17 @@ static size_t stats_return_completed_mrtg( char * reply ) { | |||
478 | ); | 478 | ); |
479 | } | 479 | } |
480 | 480 | ||
481 | #ifdef WANT_LOG_NUMWANT | ||
482 | extern unsigned long long numwants[201]; | ||
483 | static size_t stats_return_numwants( char * reply ) { | ||
484 | char * r = reply; | ||
485 | int i; | ||
486 | for( i=0; i<=200; ++i ) | ||
487 | r += sprintf( r, "%03d => %lld\n", i, numwants[i] ); | ||
488 | return r-reply; | ||
489 | } | ||
490 | #endif | ||
491 | |||
481 | #ifdef WANT_FULLLOG_NETWORKS | 492 | #ifdef WANT_FULLLOG_NETWORKS |
482 | static void stats_return_fulllog( int *iovec_entries, struct iovec **iovector, char *r ) { | 493 | static void stats_return_fulllog( int *iovec_entries, struct iovec **iovector, char *r ) { |
483 | ot_log *loglist = g_logchain_first, *llnext; | 494 | ot_log *loglist = g_logchain_first, *llnext; |
@@ -584,6 +595,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { | |||
584 | return stats_return_renew_bucket( reply ); | 595 | return stats_return_renew_bucket( reply ); |
585 | case TASK_STATS_SYNCS: | 596 | case TASK_STATS_SYNCS: |
586 | return stats_return_sync_mrtg( reply ); | 597 | return stats_return_sync_mrtg( reply ); |
598 | #ifdef WANT_LOG_NUMWANT | ||
599 | case TASK_STATS_NUMWANTS: | ||
600 | return stats_return_numwants( reply ); | ||
601 | #endif | ||
587 | default: | 602 | default: |
588 | return 0; | 603 | return 0; |
589 | } | 604 | } |