diff options
author | Ian Miell <ian.miell@gmail.com> | 2013-01-24 14:08:20 +0000 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2015-11-18 22:52:32 -0800 |
commit | a1f269ee67fdb23a9b972dae8e99d15beabc37f9 (patch) | |
tree | 036ef5a96df4da135950d7edfff87a2c7bbf878f | |
parent | 210764e936a7e32e91ec84e169de718ef726484c (diff) | |
download | memcached-a1f269ee67fdb23a9b972dae8e99d15beabc37f9.tar.gz |
Record and report on time spent in listen_disabled
-rw-r--r-- | memcached.c | 10 | ||||
-rw-r--r-- | memcached.h | 2 | ||||
-rwxr-xr-x | t/binary.t | 1 | ||||
-rwxr-xr-x | t/stats.t | 7 |
4 files changed, 16 insertions, 4 deletions
diff --git a/memcached.c b/memcached.c index d3c2a63..47d7430 100644 --- a/memcached.c +++ b/memcached.c @@ -185,6 +185,7 @@ static void stats_init(void) { stats.slab_reassign_running = false; stats.lru_crawler_running = false; stats.lru_crawler_starts = 0; + stats.time_in_listen_disabled_us = 0; /* make the time we started always be 2 seconds before we really did, so time(0) - time.started is never zero. if so, things @@ -2623,6 +2624,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) { APPEND_STAT("limit_maxbytes", "%llu", (unsigned long long)settings.maxbytes); APPEND_STAT("accepting_conns", "%u", stats.accepting_conns); APPEND_STAT("listen_disabled_num", "%llu", (unsigned long long)stats.listen_disabled_num); + APPEND_STAT("time_in_listen_disabled_us", "%llu", stats.time_in_listen_disabled_us); APPEND_STAT("threads", "%d", settings.num_threads); APPEND_STAT("conn_yields", "%llu", (unsigned long long)thread_stats.conn_yields); APPEND_STAT("hash_power_level", "%u", stats.hash_power_level); @@ -3953,11 +3955,19 @@ void do_accept_new_conns(const bool do_accept) { if (do_accept) { STATS_LOCK(); + struct timeval maxconns_exited; + uint64_t elapsed_us; + gettimeofday(&maxconns_exited,NULL); + elapsed_us = + (maxconns_exited.tv_sec - stats.maxconns_entered.tv_sec) * 1000000 + + (maxconns_exited.tv_usec - stats.maxconns_entered.tv_usec); + stats.time_in_listen_disabled_us += elapsed_us; stats.accepting_conns = true; STATS_UNLOCK(); } else { STATS_LOCK(); stats.accepting_conns = false; + gettimeofday(&stats.maxconns_entered,NULL); stats.listen_disabled_num++; STATS_UNLOCK(); allow_new_conns = false; diff --git a/memcached.h b/memcached.h index 99cf0b5..4ae3164 100644 --- a/memcached.h +++ b/memcached.h @@ -288,6 +288,8 @@ struct stats { uint64_t lru_crawler_starts; /* Number of item crawlers kicked off */ bool lru_crawler_running; /* crawl in progress */ uint64_t lru_maintainer_juggles; /* number of LRU bg pokes */ + uint64_t time_in_listen_disabled_us; /* elapsed time in microseconds while server unable to process new connections */ + struct timeval maxconns_entered; /* last time maxconns entered */ }; #define MAX_VERBOSITY_LEVEL 2 @@ -61,7 +61,6 @@ my $mc = MC::Client->new; # Let's turn on detail stats for all this stuff $mc->stats('detail on'); - my $check = sub { my ($key, $orig_flags, $orig_val) = @_; my ($flags, $val, $cas) = $mc->get($key); @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -use Test::More tests => 97; +use Test::More tests => 98; use FindBin qw($Bin); use lib "$Bin/lib"; use MemcachedTest; @@ -48,6 +48,7 @@ my $sock = $server->sock; ## STAT limit_maxbytes 67108864 ## STAT accepting_conns 1 ## STAT listen_disabled_num 0 +## STAT time_in_listen_disabled_us 0 ## STAT threads 4 ## STAT conn_yields 0 ## STAT hash_power_level 16 @@ -70,12 +71,12 @@ my $sock = $server->sock; my $stats = mem_stats($sock); # Test number of keys -is(scalar(keys(%$stats)), 52, "52 stats values"); +is(scalar(keys(%$stats)), 52, "53 stats values"); # Test initial state foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses bytes_written delete_hits delete_misses incr_hits incr_misses decr_hits - decr_misses listen_disabled_num lrutail_reflocked)) { + decr_misses listen_disabled_num lrutail_reflocked time_in_listen_disabled_us)) { is($stats->{$key}, 0, "initial $key is zero"); } is($stats->{accepting_conns}, 1, "initial accepting_conns is one"); |