xrootd
Loading...
Searching...
No Matches
XrdOucCacheStats.hh
Go to the documentation of this file.
1#ifndef __XRDOUCCACHESTATS_HH__
2#define __XRDOUCCACHESTATS_HH__
3/******************************************************************************/
4/* */
5/* X r d O u c C a c h e S t a t s . h h */
6/* */
7/* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <cstdint>
34#include <cstring>
35
38
39/* The XrdOucCacheStats object holds statistics on cache usage. It is available
40 in each Cache object that records the summary information for that cache.
41*/
42
44{
45public:
46
48{
49// General read/write information
50//
51long long BytesPead; // Bytes read via preread (not included in BytesRead)
52long long BytesRead; // Total number of bytes read into the cache
53long long BytesGet; // Number of bytes delivered from the cache
54long long BytesPass; // Number of bytes read but not cached
55long long BytesWrite; // Total number of bytes written from the cache
56long long BytesPut; // Number of bytes updated in the cache
57long long BytesSaved; // Number of bytes written from memory to disk
58long long BytesPurged; // Number of bytes purged from the cache
59long long Hits; // Number of times wanted data was in the cache
60long long Miss; // Number of times wanted data was *not* in the cache
61long long Pass; // Number of times wanted data was read but not cached
62long long HitsPR; // Number of pages of wanted data was just preread
63long long MissPR; // Number of pages of unwanted data was just preread
64
65// Local file information
66//
67long long FilesOpened; // Number of cache files opened
68long long FilesClosed; // Number of cache files closed
69long long FilesCreated;// Number of cache files created
70long long FilesPurged; // Number of cache files purged (i.e. deleted)
71long long FilesInCache;// Number of files currently in the cache
72long long FilesAreFull;// Number of full files currently in the cache
73
74// Permanent storage information (all state information)
75//
76long long DiskSize; // Size of disk cache in bytes
77long long DiskUsed; // Size of disk cache in use (bytes)
78long long DiskMin; // Minimum bytes that were in use
79long long DiskMax; // Maximum bytes that were in use
80
81// Memory information (all state information)
82//
83long long MemSize; // Maximum bytes that can be in memory
84long long MemUsed; // Actual bytes that are allocated in memory
85long long MemWriteQ; // Actual bytes that are in write queue
86
87// File information (supplied by the POSIX layer)
88//
89long long OpenDefers; // Number of opens that were deferred
90long long DeferOpens; // Number of defers that were actually opened
91long long ClosDefers; // Number of closes that were deferred
92long long ClosedLost; // Number of closed file objects that were lost
93} X; // This must be a POD type
94
95inline void Get(XrdOucCacheStats &D)
96 {sMutex.Lock();
97 memcpy(&D.X, &X, sizeof(CacheStats));
98 sMutex.UnLock();
99 }
100
101inline void Add(XrdOucCacheStats &S)
102 {sMutex.Lock();
106/* R/W Cache */ X.BytesWrite += S.X.BytesWrite; X.BytesPut += S.X.BytesPut;
107 X.Hits += S.X.Hits; X.Miss += S.X.Miss;
108 X.Pass += S.X.Pass;
109 X.HitsPR += S.X.HitsPR; X.MissPR += S.X.MissPR;
110 sMutex.UnLock();
111 }
112
126
127inline void Add(long long &Dest, long long Val)
128 {sMutex.Lock(); Dest += Val; sMutex.UnLock();}
129
130inline void Count(long long &Dest)
132
133inline void Set(long long &Dest, long long Val)
134 {sMutex.Lock(); Dest = Val; sMutex.UnLock();}
135
136inline void Lock() {sMutex.Lock();}
137inline void UnLock() {sMutex.UnLock();}
138
139 XrdOucCacheStats() {memset(&X, 0, sizeof(CacheStats));}
141private:
143};
144#endif
#define AtomicInc(x)
Definition XrdSysAtomics.hh:72
#define AtomicBeg(Mtx)
Definition XrdSysAtomics.hh:63
#define AtomicEnd(Mtx)
Definition XrdSysAtomics.hh:64
Definition XrdOucCacheStats.hh:44
~XrdOucCacheStats()
Definition XrdOucCacheStats.hh:140
XrdOucCacheStats()
Definition XrdOucCacheStats.hh:139
void Get(XrdOucCacheStats &D)
Definition XrdOucCacheStats.hh:95
void Add(XrdOucCacheStats &S)
Definition XrdOucCacheStats.hh:101
void UnLock()
Definition XrdOucCacheStats.hh:137
void Add(long long &Dest, long long Val)
Definition XrdOucCacheStats.hh:127
struct XrdOucCacheStats::CacheStats X
void Set(long long &Dest, long long Val)
Definition XrdOucCacheStats.hh:133
XrdSysMutex sMutex
Definition XrdOucCacheStats.hh:142
void Count(long long &Dest)
Definition XrdOucCacheStats.hh:130
void Lock()
Definition XrdOucCacheStats.hh:136
void Set(XrdOucCacheStats &S)
Definition XrdOucCacheStats.hh:113
Definition XrdSysPthread.hh:165
void Lock()
Definition XrdSysPthread.hh:222
void UnLock()
Definition XrdSysPthread.hh:224
Definition XrdOucCacheStats.hh:48
long long HitsPR
Definition XrdOucCacheStats.hh:62
long long MemSize
Definition XrdOucCacheStats.hh:83
long long DeferOpens
Definition XrdOucCacheStats.hh:90
long long MemWriteQ
Definition XrdOucCacheStats.hh:85
long long DiskMax
Definition XrdOucCacheStats.hh:79
long long BytesPass
Definition XrdOucCacheStats.hh:54
long long DiskUsed
Definition XrdOucCacheStats.hh:77
long long BytesSaved
Definition XrdOucCacheStats.hh:57
long long OpenDefers
Definition XrdOucCacheStats.hh:89
long long BytesPut
Definition XrdOucCacheStats.hh:56
long long MemUsed
Definition XrdOucCacheStats.hh:84
long long Miss
Definition XrdOucCacheStats.hh:60
long long FilesInCache
Definition XrdOucCacheStats.hh:71
long long MissPR
Definition XrdOucCacheStats.hh:63
long long DiskSize
Definition XrdOucCacheStats.hh:76
long long ClosDefers
Definition XrdOucCacheStats.hh:91
long long BytesRead
Definition XrdOucCacheStats.hh:52
long long FilesPurged
Definition XrdOucCacheStats.hh:70
long long Pass
Definition XrdOucCacheStats.hh:61
long long DiskMin
Definition XrdOucCacheStats.hh:78
long long FilesCreated
Definition XrdOucCacheStats.hh:69
long long BytesPead
Definition XrdOucCacheStats.hh:51
long long BytesGet
Definition XrdOucCacheStats.hh:53
long long ClosedLost
Definition XrdOucCacheStats.hh:92
long long BytesPurged
Definition XrdOucCacheStats.hh:58
long long Hits
Definition XrdOucCacheStats.hh:59
long long FilesOpened
Definition XrdOucCacheStats.hh:67
long long FilesAreFull
Definition XrdOucCacheStats.hh:72
long long FilesClosed
Definition XrdOucCacheStats.hh:68
long long BytesWrite
Definition XrdOucCacheStats.hh:55