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