Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Thank you!
Brian Degenhardt <bmd@mp3.com>
Brian Denehy <B-Denehy@adfa.oz.au>
Bruce Murphy <pack-squid@rattus.net>
Carl Vuosalo <cvuosalo@cern.ch>
Comment thread
rousskov marked this conversation as resolved.
Carson Gaspar <carson@cs.columbia.edu>
Carson Gaspar <carson@lehman.com>
Carsten Grzemba <cgrzemba@opencsw.org>
Expand Down
8 changes: 8 additions & 0 deletions src/MemStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ MemStore::getStats(StoreInfoStats &stats) const
const size_t pageSize = Ipc::Mem::PageSize();

stats.mem.shared = true;

// In SMP mode, only the first worker reports shared memory stats to avoid
// adding up same-cache positive stats (reported by multiple worker
// processes) when Coordinator aggregates worker-reported stats.
// See also: Store::Disk::doReportStat().
if (UsingSmp() && KidIdentifier != 1)
return;

stats.mem.capacity =
Ipc::Mem::PageLimit(Ipc::Mem::PageId::cachePage) * pageSize;
stats.mem.size =
Expand Down
20 changes: 4 additions & 16 deletions src/StoreStats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,10 @@ StoreInfoStats::operator +=(const StoreInfoStats &stats)
// Assume that either all workers use shared memory cache or none do.
// It is possible but difficult to report correct stats for an arbitrary
// mix, and only rather unusual deployments can benefit from mixing.

// If workers share memory, we will get shared stats from those workers
// and non-shared stats from other processes. Ignore order and also
// ignore other processes stats because they are zero in most setups.
if (stats.mem.shared) { // workers share memory
// use the latest reported stats, they all should be about the same
mem.shared = true;
mem.size = stats.mem.size;
mem.capacity = stats.mem.capacity;
mem.count = stats.mem.count;
} else if (!mem.shared) { // do not corrupt shared stats, if any
// workers do not share so we must add everything up
mem.size += stats.mem.size;
mem.capacity += stats.mem.capacity;
mem.count += stats.mem.count;
}
mem.shared = mem.shared || stats.mem.shared; // TODO: Remove mem.shared as effectively unused?
mem.size += stats.mem.size;
mem.capacity += stats.mem.capacity;
mem.count += stats.mem.count;

store_entry_count += stats.store_entry_count;
mem_object_count += stats.mem_object_count;
Expand Down
9 changes: 7 additions & 2 deletions src/snmp_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "store/Controller.h"
#include "StoreStats.h"
#include "tools.h"
#include "util.h"

Expand Down Expand Up @@ -409,11 +411,14 @@ snmp_prfSysFn(variable_list * Var, snint * ErrP)
SMI_GAUGE32);
break;

case PERF_SYS_NUMOBJCNT:
case PERF_SYS_NUMOBJCNT: {
StoreInfoStats stats;
Store::Root().getStats(stats);
Answer = snmp_var_new_integer(Var->name, Var->name_length,
(snint) StoreEntry::inUseCount(),
(snint) (stats.mem.count + stats.swap.count),
SMI_GAUGE32);
break;
}

default:
*ErrP = SNMP_ERR_NOSUCHNAME;
Expand Down