]> git.ipfire.org Git - thirdparty/squid.git/blame_incremental - src/StoreStats.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / StoreStats.cc
... / ...
CommitLineData
1/*
2 * $Id$
3 *
4 * DEBUG: section 20 Storage Manager Statistics
5 *
6 */
7
8#include "squid.h"
9#include "protos.h" /* for xmemset only */
10#include "StoreStats.h"
11
12/* StoreInfoStats */
13
14StoreInfoStats::StoreInfoStats()
15{
16 xmemset(this, 0, sizeof(*this));
17}
18
19StoreInfoStats &
20StoreInfoStats::operator +=(const StoreInfoStats &stats)
21{
22 swap.size += stats.swap.size;
23 swap.capacity += stats.swap.capacity;
24 swap.count += stats.swap.count;
25 swap.open_disk_fd += stats.swap.open_disk_fd;
26
27 // Assume that either all workers use shared memory cache or none do.
28 // It is possible but difficult to report correct stats for an arbitrary
29 // mix, and only rather unusual deployments can benefit from mixing.
30
31 // If workers share memory, we will get shared stats from those workers
32 // and non-shared stats from other processes. Ignore order and also
33 // ignore other processes stats because they are zero in most setups.
34 if (stats.mem.shared) { // workers share memory
35 // use the latest reported stats, they all should be about the same
36 mem.shared = true;
37 mem.size = stats.mem.size;
38 mem.capacity = stats.mem.capacity;
39 mem.count = stats.mem.count;
40 } else if (!mem.shared) { // do not corrupt shared stats, if any
41 // workers do not share so we must add everything up
42 mem.size += stats.mem.size;
43 mem.capacity += stats.mem.capacity;
44 mem.count += stats.mem.count;
45 }
46
47 store_entry_count += stats.store_entry_count;
48 mem_object_count += stats.mem_object_count;
49
50 return *this;
51}
52
53/* StoreIoStats */
54
55StoreIoStats::StoreIoStats()
56{
57 xmemset(this, 0, sizeof(*this));
58}
59