xrootd
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
34
35/* The XrdOucCacheStats object holds statistics on cache usage. It is available
36 in for each CacheIO and each Cache object. The former usually identifies
37 a specific file while the latter provides summary information.
38*/
39
41{
42public:
43long long BytesPead; // Bytes read via preread (not included in BytesRead)
44long long BytesRead; // Total number of bytes read into the cache
45long long BytesGet; // Number of bytes delivered from the cache
46long long BytesPass; // Number of bytes read but not cached
47long long BytesWrite; // Total number of bytes written from the cache
48long long BytesPut; // Number of bytes updated in the cache
49int Hits; // Number of times wanted data was in the cache
50int Miss; // Number of times wanted data was *not* in the cache
51int HitsPR; // Number of pages wanted data was just preread
52int MissPR; // Number of pages wanted data was just read
53
54inline void Get(XrdOucCacheStats &Dst)
55 {sMutex.Lock();
57 Dst.BytesPass = BytesPass;
59 Dst.Hits = Hits; Dst.Miss = Miss;
60 Dst.HitsPR = HitsPR; Dst.MissPR = MissPR;
61 sMutex.UnLock();
62 }
63
64inline void Add(XrdOucCacheStats &Src)
65 {sMutex.Lock();
67 BytesPass += Src.BytesPass;
69 Hits += Src.Hits; Miss += Src.Miss;
70 HitsPR += Src.HitsPR; MissPR += Src.MissPR;
71 sMutex.UnLock();
72 }
73
74inline void Add(long long &Dest, int &Val)
75 {sMutex.Lock(); Dest += Val; sMutex.UnLock();}
76
77inline void Lock() {sMutex.Lock();}
78inline void UnLock() {sMutex.UnLock();}
79
81 BytesPass(0), BytesWrite(0), BytesPut(0),
82 Hits(0), Miss(0),
83 HitsPR(0), MissPR(0) {}
85private:
87};
88#endif
Definition: XrdOucCacheStats.hh:41
~XrdOucCacheStats()
Definition: XrdOucCacheStats.hh:84
XrdOucCacheStats()
Definition: XrdOucCacheStats.hh:80
long long BytesPass
Definition: XrdOucCacheStats.hh:46
int HitsPR
Definition: XrdOucCacheStats.hh:51
long long BytesPut
Definition: XrdOucCacheStats.hh:48
void UnLock()
Definition: XrdOucCacheStats.hh:78
long long BytesGet
Definition: XrdOucCacheStats.hh:45
int Miss
Definition: XrdOucCacheStats.hh:50
int Hits
Definition: XrdOucCacheStats.hh:49
long long BytesRead
Definition: XrdOucCacheStats.hh:44
XrdSysMutex sMutex
Definition: XrdOucCacheStats.hh:86
int MissPR
Definition: XrdOucCacheStats.hh:52
void Add(long long &Dest, int &Val)
Definition: XrdOucCacheStats.hh:74
void Lock()
Definition: XrdOucCacheStats.hh:77
long long BytesPead
Definition: XrdOucCacheStats.hh:43
void Add(XrdOucCacheStats &Src)
Definition: XrdOucCacheStats.hh:64
void Get(XrdOucCacheStats &Dst)
Definition: XrdOucCacheStats.hh:54
long long BytesWrite
Definition: XrdOucCacheStats.hh:47
Definition: XrdSysPthread.hh:166
void Lock()
Definition: XrdSysPthread.hh:220
void UnLock()
Definition: XrdSysPthread.hh:222