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