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 
33 #include "XrdSys/XrdSysPthread.hh"
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 {
42 public:
43 long long BytesPead; // Bytes read via preread (not included in BytesRead)
44 long long BytesRead; // Total number of bytes read into the cache
45 long long BytesGet; // Number of bytes delivered from the cache
46 long long BytesPass; // Number of bytes read but not cached
47 long long BytesWrite; // Total number of bytes written from the cache
48 long long BytesPut; // Number of bytes updated in the cache
49 int Hits; // Number of times wanted data was in the cache
50 int Miss; // Number of times wanted data was *not* in the cache
51 int HitsPR; // Number of pages wanted data was just preread
52 int MissPR; // Number of pages wanted data was just read
53 
54 inline 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 
64 inline void Add(XrdOucCacheStats &Src)
65  {sMutex.Lock();
66  BytesRead += Src.BytesPead; BytesGet += Src.BytesRead;
67  BytesPass += Src.BytesPass;
68  BytesWrite += Src.BytesWrite; BytesPut += Src.BytesPut;
69  Hits += Src.Hits; Miss += Src.Miss;
70  HitsPR += Src.HitsPR; MissPR += Src.MissPR;
71  sMutex.UnLock();
72  }
73 
74 inline void Add(long long &Dest, int &Val)
75  {sMutex.Lock(); Dest += Val; sMutex.UnLock();}
76 
77 inline void Lock() {sMutex.Lock();}
78 inline void UnLock() {sMutex.UnLock();}
79 
81  BytesPass(0), BytesWrite(0), BytesPut(0),
82  Hits(0), Miss(0),
83  HitsPR(0), MissPR(0) {}
85 private:
87 };
88 #endif
XrdOucCacheStats()
Definition: XrdOucCacheStats.hh:80
long long BytesPass
Definition: XrdOucCacheStats.hh:46
~XrdOucCacheStats()
Definition: XrdOucCacheStats.hh:84
void Add(XrdOucCacheStats &Src)
Definition: XrdOucCacheStats.hh:64
long long BytesGet
Definition: XrdOucCacheStats.hh:45
void Get(XrdOucCacheStats &Dst)
Definition: XrdOucCacheStats.hh:54
Definition: XrdSysPthread.hh:165
long long BytesRead
Definition: XrdOucCacheStats.hh:44
int Hits
Definition: XrdOucCacheStats.hh:49
int Miss
Definition: XrdOucCacheStats.hh:50
int HitsPR
Definition: XrdOucCacheStats.hh:51
long long BytesPut
Definition: XrdOucCacheStats.hh:48
void Lock()
Definition: XrdSysPthread.hh:220
long long BytesPead
Definition: XrdOucCacheStats.hh:43
int MissPR
Definition: XrdOucCacheStats.hh:52
void UnLock()
Definition: XrdOucCacheStats.hh:78
XrdSysMutex sMutex
Definition: XrdOucCacheStats.hh:86
void Lock()
Definition: XrdOucCacheStats.hh:77
long long BytesWrite
Definition: XrdOucCacheStats.hh:47
Definition: XrdOucCacheStats.hh:40
void UnLock()
Definition: XrdSysPthread.hh:222
void Add(long long &Dest, int &Val)
Definition: XrdOucCacheStats.hh:74