]> git.ipfire.org Git - thirdparty/squid.git/blame - src/StoreStats.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / StoreStats.cc
CommitLineData
93bc1434 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
93bc1434 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
93bc1434
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 20 Storage Manager Statistics */
10
f7f3304a 11#include "squid.h"
93bc1434 12#include "StoreStats.h"
602d9612 13#include "tools.h"
93bc1434 14
93bc1434
AR
15/* StoreInfoStats */
16
17StoreInfoStats::StoreInfoStats()
18{
e297be13 19 memset(this, 0, sizeof(*this));
93bc1434
AR
20}
21
22StoreInfoStats &
23StoreInfoStats::operator +=(const StoreInfoStats &stats)
a46ed03b 24{
93bc1434
AR
25 swap.size += stats.swap.size;
26 swap.capacity += stats.swap.capacity;
27 swap.count += stats.swap.count;
28 swap.open_disk_fd += stats.swap.open_disk_fd;
29
30 // Assume that either all workers use shared memory cache or none do.
31 // It is possible but difficult to report correct stats for an arbitrary
32 // mix, and only rather unusual deployments can benefit from mixing.
33
34 // If workers share memory, we will get shared stats from those workers
35 // and non-shared stats from other processes. Ignore order and also
36 // ignore other processes stats because they are zero in most setups.
37 if (stats.mem.shared) { // workers share memory
38 // use the latest reported stats, they all should be about the same
39 mem.shared = true;
40 mem.size = stats.mem.size;
41 mem.capacity = stats.mem.capacity;
42 mem.count = stats.mem.count;
43 } else if (!mem.shared) { // do not corrupt shared stats, if any
44 // workers do not share so we must add everything up
45 mem.size += stats.mem.size;
46 mem.capacity += stats.mem.capacity;
47 mem.count += stats.mem.count;
48 }
49
50 store_entry_count += stats.store_entry_count;
51 mem_object_count += stats.mem_object_count;
52
53 return *this;
54}
55
93bc1434
AR
56/* StoreIoStats */
57
58StoreIoStats::StoreIoStats()
59{
e297be13 60 memset(this, 0, sizeof(*this));
93bc1434
AR
61}
62