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
36
#include "
XrdSys/XrdSysAtomics.hh
"
37
#include "
XrdSys/XrdSysPthread.hh
"
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
43
class
XrdOucCacheStats
44
{
45
public
:
46
47
struct
CacheStats
48
{
49
// General read/write information
50
//
51
long
long
BytesPead
;
// Bytes read via preread (not included in BytesRead)
52
long
long
BytesRead
;
// Total number of bytes read into the cache
53
long
long
BytesGet
;
// Number of bytes delivered from the cache
54
long
long
BytesPass
;
// Number of bytes read but not cached
55
long
long
BytesWrite
;
// Total number of bytes written from the cache
56
long
long
BytesPut
;
// Number of bytes updated in the cache
57
long
long
BytesSaved
;
// Number of bytes written from memory to disk
58
long
long
BytesPurged
;
// Number of bytes purged from the cache
59
long
long
Hits
;
// Number of times wanted data was in the cache
60
long
long
Miss
;
// Number of times wanted data was *not* in the cache
61
long
long
Pass
;
// Number of times wanted data was read but not cached
62
long
long
HitsPR
;
// Number of pages of wanted data was just preread
63
long
long
MissPR
;
// Number of pages of unwanted data was just preread
64
65
// Local file information
66
//
67
long
long
FilesOpened
;
// Number of cache files opened
68
long
long
FilesClosed
;
// Number of cache files closed
69
long
long
FilesCreated
;
// Number of cache files created
70
long
long
FilesPurged
;
// Number of cache files purged (i.e. deleted)
71
long
long
FilesInCache
;
// Number of files currently in the cache
72
long
long
FilesAreFull
;
// Number of full files currently in the cache
73
74
// Permanent storage information (all state information)
75
//
76
long
long
DiskSize
;
// Size of disk cache in bytes
77
long
long
DiskUsed
;
// Size of disk cache in use (bytes)
78
long
long
DiskMin
;
// Minimum bytes that were in use
79
long
long
DiskMax
;
// Maximum bytes that were in use
80
81
// Memory information (all state information)
82
//
83
long
long
MemSize
;
// Maximum bytes that can be in memory
84
long
long
MemUsed
;
// Actual bytes that are allocated in memory
85
long
long
MemWriteQ
;
// Actual bytes that are in write queue
86
87
// File information (supplied by the POSIX layer)
88
//
89
long
long
OpenDefers
;
// Number of opens that were deferred
90
long
long
DeferOpens
;
// Number of defers that were actually opened
91
long
long
ClosDefers
;
// Number of closes that were deferred
92
long
long
ClosedLost
;
// Number of closed file objects that were lost
93
}
X
;
// This must be a POD type
94
95
inline
void
Get
(
XrdOucCacheStats
&D)
96
{sMutex.Lock();
97
memcpy(&D.
X
, &
X
,
sizeof
(
CacheStats
));
98
sMutex.UnLock();
99
}
100
101
inline
void
Add
(
XrdOucCacheStats
&S)
102
{sMutex.Lock();
103
X
.BytesPead += S.
X
.
BytesPead
;
X
.BytesRead += S.
X
.
BytesRead
;
104
X
.BytesGet += S.
X
.
BytesGet
;
X
.BytesPass += S.
X
.
BytesPass
;
105
X
.BytesSaved += S.
X
.
BytesSaved
;
X
.BytesPurged+= S.
X
.
BytesPurged
;
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
113
inline
void
Set
(
XrdOucCacheStats
&S)
114
{sMutex.Lock();
115
X
.FilesOpened = S.
X
.
FilesOpened
;
X
.FilesClosed = S.
X
.
FilesClosed
;
116
X
.FilesCreated = S.
X
.
FilesCreated
;
X
.FilesPurged = S.
X
.
FilesPurged
;
117
X
.FilesInCache = S.
X
.
FilesInCache
;
X
.FilesAreFull= S.
X
.
FilesAreFull
;
118
119
X
.DiskSize = S.
X
.
DiskSize
;
X
.DiskUsed = S.
X
.
DiskUsed
;
120
X
.DiskMin = S.
X
.
DiskMin
;
X
.DiskMax = S.
X
.
DiskMax
;
121
122
X
.MemSize = S.
X
.
MemSize
;
X
.MemUsed = S.
X
.
MemUsed
;
123
X
.MemWriteQ = S.
X
.
MemWriteQ
;
124
sMutex.UnLock();
125
}
126
127
inline
void
Add
(
long
long
&Dest,
long
long
Val)
128
{sMutex.Lock(); Dest += Val; sMutex.UnLock();}
129
130
inline
void
Count
(
long
long
&Dest)
131
{
AtomicBeg
(sMutex);
AtomicInc
(Dest);
AtomicEnd
(sMutex);}
132
133
inline
void
Set
(
long
long
&Dest,
long
long
Val)
134
{sMutex.Lock(); Dest = Val; sMutex.UnLock();}
135
136
inline
void
Lock
() {sMutex.Lock();}
137
inline
void
UnLock
() {sMutex.UnLock();}
138
139
XrdOucCacheStats
() {memset(&
X
, 0,
sizeof
(
CacheStats
));}
140
~XrdOucCacheStats
() {}
141
private
:
142
XrdSysMutex
sMutex;
143
};
144
#endif
XrdSysAtomics.hh
AtomicInc
#define AtomicInc(x)
Definition
XrdSysAtomics.hh:72
AtomicBeg
#define AtomicBeg(Mtx)
Definition
XrdSysAtomics.hh:63
AtomicEnd
#define AtomicEnd(Mtx)
Definition
XrdSysAtomics.hh:64
XrdSysPthread.hh
XrdOucCacheStats::~XrdOucCacheStats
~XrdOucCacheStats()
Definition
XrdOucCacheStats.hh:140
XrdOucCacheStats::XrdOucCacheStats
XrdOucCacheStats()
Definition
XrdOucCacheStats.hh:139
XrdOucCacheStats::CacheStats::HitsPR
long long HitsPR
Definition
XrdOucCacheStats.hh:62
XrdOucCacheStats::Get
void Get(XrdOucCacheStats &D)
Definition
XrdOucCacheStats.hh:95
XrdOucCacheStats::CacheStats::MemSize
long long MemSize
Definition
XrdOucCacheStats.hh:83
XrdOucCacheStats::CacheStats::DeferOpens
long long DeferOpens
Definition
XrdOucCacheStats.hh:90
XrdOucCacheStats::CacheStats::MemWriteQ
long long MemWriteQ
Definition
XrdOucCacheStats.hh:85
XrdOucCacheStats::Add
void Add(XrdOucCacheStats &S)
Definition
XrdOucCacheStats.hh:101
XrdOucCacheStats::CacheStats::DiskMax
long long DiskMax
Definition
XrdOucCacheStats.hh:79
XrdOucCacheStats::CacheStats::BytesPass
long long BytesPass
Definition
XrdOucCacheStats.hh:54
XrdOucCacheStats::CacheStats::DiskUsed
long long DiskUsed
Definition
XrdOucCacheStats.hh:77
XrdOucCacheStats::CacheStats::BytesSaved
long long BytesSaved
Definition
XrdOucCacheStats.hh:57
XrdOucCacheStats::UnLock
void UnLock()
Definition
XrdOucCacheStats.hh:137
XrdOucCacheStats::CacheStats::OpenDefers
long long OpenDefers
Definition
XrdOucCacheStats.hh:89
XrdOucCacheStats::Add
void Add(long long &Dest, long long Val)
Definition
XrdOucCacheStats.hh:127
XrdOucCacheStats::CacheStats::BytesPut
long long BytesPut
Definition
XrdOucCacheStats.hh:56
XrdOucCacheStats::CacheStats::MemUsed
long long MemUsed
Definition
XrdOucCacheStats.hh:84
XrdOucCacheStats::CacheStats::Miss
long long Miss
Definition
XrdOucCacheStats.hh:60
XrdOucCacheStats::X
struct XrdOucCacheStats::CacheStats X
XrdOucCacheStats::CacheStats::FilesInCache
long long FilesInCache
Definition
XrdOucCacheStats.hh:71
XrdOucCacheStats::CacheStats::MissPR
long long MissPR
Definition
XrdOucCacheStats.hh:63
XrdOucCacheStats::Set
void Set(long long &Dest, long long Val)
Definition
XrdOucCacheStats.hh:133
XrdOucCacheStats::CacheStats::DiskSize
long long DiskSize
Definition
XrdOucCacheStats.hh:76
XrdOucCacheStats::CacheStats::ClosDefers
long long ClosDefers
Definition
XrdOucCacheStats.hh:91
XrdOucCacheStats::CacheStats::BytesRead
long long BytesRead
Definition
XrdOucCacheStats.hh:52
XrdOucCacheStats::CacheStats::FilesPurged
long long FilesPurged
Definition
XrdOucCacheStats.hh:70
XrdOucCacheStats::CacheStats::Pass
long long Pass
Definition
XrdOucCacheStats.hh:61
XrdOucCacheStats::CacheStats::DiskMin
long long DiskMin
Definition
XrdOucCacheStats.hh:78
XrdOucCacheStats::CacheStats::FilesCreated
long long FilesCreated
Definition
XrdOucCacheStats.hh:69
XrdOucCacheStats::CacheStats::BytesPead
long long BytesPead
Definition
XrdOucCacheStats.hh:51
XrdOucCacheStats::CacheStats::BytesGet
long long BytesGet
Definition
XrdOucCacheStats.hh:53
XrdOucCacheStats::CacheStats::ClosedLost
long long ClosedLost
Definition
XrdOucCacheStats.hh:92
XrdOucCacheStats::Count
void Count(long long &Dest)
Definition
XrdOucCacheStats.hh:130
XrdOucCacheStats::Lock
void Lock()
Definition
XrdOucCacheStats.hh:136
XrdOucCacheStats::CacheStats::BytesPurged
long long BytesPurged
Definition
XrdOucCacheStats.hh:58
XrdOucCacheStats::CacheStats::Hits
long long Hits
Definition
XrdOucCacheStats.hh:59
XrdOucCacheStats::CacheStats::FilesOpened
long long FilesOpened
Definition
XrdOucCacheStats.hh:67
XrdOucCacheStats::CacheStats::FilesAreFull
long long FilesAreFull
Definition
XrdOucCacheStats.hh:72
XrdOucCacheStats::CacheStats::FilesClosed
long long FilesClosed
Definition
XrdOucCacheStats.hh:68
XrdOucCacheStats::Set
void Set(XrdOucCacheStats &S)
Definition
XrdOucCacheStats.hh:113
XrdOucCacheStats::CacheStats::BytesWrite
long long BytesWrite
Definition
XrdOucCacheStats.hh:55
XrdOucCacheStats::CacheStats
Definition
XrdOucCacheStats.hh:48
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdOuc
XrdOucCacheStats.hh
Generated by
1.13.1