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