Changeset 487

Show
Ignore:
Timestamp:
04/08/07 15:21:12 (2 years ago)
Author:
plindner
Message:

Merge up changes from trunk, add STATS_LOCK()/STATS_UNLOCK() for
new stats counter calls. Command used:

svn merge -r 473:486 http://code.sixapart.com/svn/memcached/trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/multithreaded/server/ChangeLog

    r474 r487  
    1 2007-03-18  Paul Lindner  <lindner@mirth.inuus.com> 
    2  
     12007-04-04  Paul Lindner  <lindner@inuus.com> 
     2 
     3        * Add clarification of flush_all in the protocol docs 
     4          from Elizabeth Mattijsen <liz@dijkmat.nl> 
     5 
     62007-03-31  Paul Lindner  <lindner@inuus.com> 
     7 
     8        * Add patch from Eli Bingham <eli@pandora.com> to  
     9          re-enable the -n switch to memcached. 
     10 
     112007-03-20  Paul Lindner  <lindner@inuus.com> 
     12        * Add patch to collect eviction statistics from 
     13          Jean-Francois BUSTARRET <jfbustarret@wat.tv>. 
     14 
     15        * Updated docs, added new test cases for t/stats.t 
    316 
    4172007-03-18  Paul Lindner  <lindner@inuus.com> 
  • branches/multithreaded/server/doc/protocol.txt

    r357 r487  
    347347connection_structures 32u  Number of connection structures allocated  
    348348                           by the server 
    349 cmd_get           32u      Cumulative number of retrieval requests 
    350 cmd_set           32u      Cumulative number of storage requests 
    351 get_hits          32u      Number of keys that have been requested and  
     349cmd_get           64u      Cumulative number of retrieval requests 
     350cmd_set           64u      Cumulative number of storage requests 
     351get_hits          64u      Number of keys that have been requested and  
    352352                           found present 
    353 get_misses        32u      Number of items that have been requested  
     353get_misses        64u      Number of items that have been requested  
    354354                           and not found 
     355evictions         64u      Number of items removed from cache because 
     356                           they passed their expiration time 
    355357bytes_read        64u      Total number of bytes read by this server  
    356358                           from network 
     
    377379executed to be ignored for retrieval purposes. 
    378380 
     381The intent of flush_all with a delay, was that in a setting where you 
     382have a pool of memcached servers, and you need to flush all content, 
     383you have the option of not resetting all memcached servers at the 
     384same time (which could e.g. cause a spike in database load with all 
     385clients suddenly needing to recreate content that would otherwise 
     386have been found in the memcached daemon). 
     387 
     388The delay option allows you to have them reset in e.g. 10 second 
     389intervals (by passing 0 to the first, 10 to the second, 20 to the 
     390third, etc. etc.). 
     391 
     392 
    379393"version" is a command with no arguments: 
    380394 
  • branches/multithreaded/server/items.c

    r474 r487  
    108108        for (search = tails[id]; tries>0 && search; tries--, search=search->prev) { 
    109109            if (search->refcount==0) { 
     110               if (search->exptime > current_time) { 
     111                       STATS_LOCK(); 
     112                       stats.evictions++; 
     113                       STATS_UNLOCK(); 
     114                } 
    110115                do_item_unlink(search); 
    111116                break; 
  • branches/multithreaded/server/memcached.c

    r474 r487  
    147147static void stats_init(void) { 
    148148    stats.curr_items = stats.total_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0; 
    149     stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0; 
     149    stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = 0; 
    150150    stats.curr_bytes = stats.bytes_read = stats.bytes_written = 0; 
    151151 
     
    161161    STATS_LOCK(); 
    162162    stats.total_items = stats.total_conns = 0; 
    163     stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = 0; 
     163    stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = 0; 
    164164    stats.bytes_read = stats.bytes_written = 0; 
    165165    stats_prefix_clear(); 
     
    866866        pos += sprintf(pos, "STAT get_hits %llu\r\n", stats.get_hits); 
    867867        pos += sprintf(pos, "STAT get_misses %llu\r\n", stats.get_misses); 
     868        pos += sprintf(pos, "STAT evictions %llu\r\n", stats.evictions); 
    868869        pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read); 
    869870        pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written); 
     
    24252426 
    24262427    /* process arguments */ 
    2427     while ((c = getopt(argc, argv, "bp:s:U:m:Mc:khirvdl:u:P:f:t:D:")) != -1) { 
     2428    while ((c = getopt(argc, argv, "bp:s:U:m:Mc:khirvdl:u:P:f:s:n:t:D:")) != -1) { 
    24282429        switch (c) { 
    24292430        case 'U': 
  • branches/multithreaded/server/memcached.h

    r474 r487  
    5555    unsigned long long  get_hits; 
    5656    unsigned long long  get_misses; 
     57    unsigned long long  evictions; 
    5758    time_t        started;          /* when the process was started */ 
    5859    unsigned long long bytes_read; 
  • branches/multithreaded/server/t/maxconns.t

    r474 r487  
    44use warnings; 
    55 
    6 use Test::More tests => 10
     6use Test::More tests => 21
    77 
    88use FindBin qw($Bin); 
     
    1919push (@sockets, $sock); 
    2020 
    21 foreach my $conn (1..20) { 
     21 
     22foreach my $conn (1..10) { 
    2223  $sock = $server->new_sock; 
    23   if ($conn > 10) { 
    24     ok(!defined($sock), "Failed Connection $conn $sock"); 
    25   } else { 
    26     ok(defined($sock), "Connection $conn"); 
    27     push(@sockets, $sock); 
    28   }     
     24  ok(defined($sock), "Made connection $conn"); 
     25  push(@sockets, $sock); 
    2926} 
    3027 
    31 mem_stats($sock, ''); 
    32 sleep(100); 
     28TODO: { 
     29local $TODO = "Need to decide on what -c semantics are"; 
     30 
     31foreach my $conn (11..20) { 
     32  $sock = $server->new_sock; 
     33  ok(defined($sock), "Connection $conn"); 
     34  push(@sockets, $sock); 
     35
     36
  • branches/multithreaded/server/t/stats.t

    r351 r487  
    22 
    33use strict; 
    4 use Test::More skip_all => "Tests not written.";  # tests => 1 
     4use Test::More tests => 16; 
    55use FindBin qw($Bin); 
    66use lib "$Bin/lib"; 
     
    1010my $sock = $server->sock; 
    1111 
     12 
     13## Output looks like this: 
     14## 
     15## STAT pid 16293 
     16## STAT uptime 7 
     17## STAT time 1174419597 
     18## STAT version 1.2.1 
     19## STAT pointer_size 32 
     20## STAT rusage_user 0.012998 
     21## STAT rusage_system 0.119981 
     22## STAT curr_items 0 
     23## STAT total_items 0 
     24## STAT bytes 0 
     25## STAT curr_connections 1 
     26## STAT total_connections 2 
     27## STAT connection_structures 2 
     28## STAT cmd_get 0 
     29## STAT cmd_set 0 
     30## STAT get_hits 0 
     31## STAT get_misses 0 
     32## STAT evictions 0 
     33## STAT bytes_read 7 
     34## STAT bytes_written 0 
     35## STAT limit_maxbytes 67108864 
     36 
     37my $stats = mem_stats($sock); 
     38 
     39# Test number of keys 
     40is(scalar(keys(%$stats)), 22, "22 stats values"); 
     41 
     42# Test initial state 
     43foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses bytes_written)) { 
     44    is($stats->{$key}, 0, "initial $key is zero"); 
     45} 
     46 
     47# Do some operations 
     48 
     49print $sock "set foo 0 0 6\r\nfooval\r\n"; 
     50is(scalar <$sock>, "STORED\r\n", "stored foo"); 
     51mem_get_is($sock, "foo", "fooval"); 
     52 
     53my $stats = mem_stats($sock); 
     54 
     55foreach my $key (qw(total_items curr_items cmd_get cmd_set get_hits)) { 
     56    is($stats->{$key}, 1, "after one set/one get $key is 1"); 
     57}