Browse Source

Temporary feature: log amount of numwants. See if we can save traffic if we reduce max numwant to something less than 200

dynamic-accesslists
erdgeist 16 years ago
parent
commit
4c4303a156
  1. 14
      ot_http.c
  2. 1
      ot_mutex.h
  3. 17
      ot_stats.c

14
ot_http.c

@ -171,7 +171,11 @@ static const ot_keywords keywords_mode[] = @@ -171,7 +171,11 @@ static const ot_keywords keywords_mode[] =
{ "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE },
{ "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED },
{ "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION },
{ "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG }, { NULL, -3 } };
{ "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG },
#ifdef WANT_LOG_NUMWANT
{ "numwants", TASK_STATS_NUMWANTS},
#endif
{ NULL, -3 } };
static const ot_keywords keywords_format[] =
{ { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED },
{ "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,6 +336,10 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c
return ws->reply_size;
}
#ifdef WANT_LOG_NUMWANT
unsigned long long numwants[201];
#endif
static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "event", 3 }, { "numwant", 4 }, { "compact", 5 }, { "compact6", 5 }, { "info_hash", 6 },
#ifdef WANT_IP_FROM_QUERY_STRING
{ "ip", 7 },
@ -479,6 +487,10 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, @@ -479,6 +487,10 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws,
}
}
#ifdef WANT_LOG_NUMWANT
numwants[numwant]++;
#endif
/* XXX DEBUG */
stats_issue_event( EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply );

1
ot_mutex.h

@ -32,6 +32,7 @@ typedef enum { @@ -32,6 +32,7 @@ typedef enum {
TASK_STATS_RENEW = 0x000a,
TASK_STATS_SYNCS = 0x000b,
TASK_STATS_COMPLETED = 0x000c,
TASK_STATS_NUMWANTS = 0x000d,
TASK_STATS = 0x0100, /* Mask */
TASK_STATS_TORRENTS = 0x0101,

17
ot_stats.c

@ -135,7 +135,7 @@ static int stats_shift_down_network_count( stats_network_node **node, int depth, @@ -135,7 +135,7 @@ static int stats_shift_down_network_count( stats_network_node **node, int depth,
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 ) {
size_t score = 0;
int i;
malloc(100);
if( !node ) return 0;
if( depth < limit ) {
@ -478,6 +478,17 @@ static size_t stats_return_completed_mrtg( char * reply ) { @@ -478,6 +478,17 @@ static size_t stats_return_completed_mrtg( char * reply ) {
);
}
#ifdef WANT_LOG_NUMWANT
extern unsigned long long numwants[201];
static size_t stats_return_numwants( char * reply ) {
char * r = reply;
int i;
for( i=0; i<=200; ++i )
r += sprintf( r, "%03d => %lld\n", i, numwants[i] );
return r-reply;
}
#endif
#ifdef WANT_FULLLOG_NETWORKS
static void stats_return_fulllog( int *iovec_entries, struct iovec **iovector, char *r ) {
ot_log *loglist = g_logchain_first, *llnext;
@ -584,6 +595,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { @@ -584,6 +595,10 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) {
return stats_return_renew_bucket( reply );
case TASK_STATS_SYNCS:
return stats_return_sync_mrtg( reply );
#ifdef WANT_LOG_NUMWANT
case TASK_STATS_NUMWANTS:
return stats_return_numwants( reply );
#endif
default:
return 0;
}

Loading…
Cancel
Save