XRootD
Loading...
Searching...
No Matches
XrdCl::ActionMetrics Struct Reference

Metrics struct storing all timing and IO information of an action. More...

#include <XrdClActionMetrics.hh>

Collaboration diagram for XrdCl::ActionMetrics:

Classes

struct  synchronicity_t

Public Member Functions

 ActionMetrics ()
void add (const ActionMetrics &other)
void addDelays (const std::string &action, const std::string &field, double value)
void addIos (const std::string &action, const std::string &field, double value)
std::string Dump (bool json) const
size_t getBytesRead () const
size_t getBytesWritten () const
size_t getIopsRead () const
size_t getIopsWrite () const

Static Public Member Functions

static std::string humanreadable (uint64_t insize)

Public Attributes

synchronicity_t aggregated_synchronicity
std::map< std::string, double > delays
size_t errors
std::string fname
std::map< std::string, uint64_t > ios
std::mutex mtx
double synchronicity
std::string url

Detailed Description

Metrics struct storing all timing and IO information of an action.

Definition at line 46 of file XrdClActionMetrics.hh.

Constructor & Destructor Documentation

◆ ActionMetrics()

XrdCl::ActionMetrics::ActionMetrics ( )
inline

Definition at line 48 of file XrdClActionMetrics.hh.

49 {
50 std::string op[] = { "OpenR", "OpenW", "Open", "Read", "Write", "Stat", "Close",
51 "PgRead", "PgWrite", "Truncate", "Sync", "VectorRead", "VectorWrite" };
52 for (auto& i : op)
53 {
54 std::string gain = i + "::tgain"; // time early for IO submission
55 std::string loss = i + "::tloss"; // time late for IO submission
56 std::string nomi = i + "::tnomi"; // nominal IO time
57 std::string exec = i + "::texec"; // time to submit IO
58 std::string meas = i + "::tmeas"; // time measured for IO to complete
59
60 delays[gain] = 0;
61 delays[loss] = 0;
62 delays[nomi] = 0;
63 delays[exec] = 0;
64 delays[meas] = 0;
65
66 std::string cnt = i + "::n"; // IOPS
67 std::string vol = i + "::b"; // number of bytes
68 std::string err = i + "::e"; // number of unsuccessful IOs
69 std::string off = i + "::o"; // maximum offset seen
70
71 ios[cnt] = 0;
72 ios[vol] = 0;
73 ios[err] = 0;
74 ios[off] = 0;
75 }
76
77 ios["All::e"] = 0; // Error counter for summing over files
78 synchronicity = 0.0;
79 errors = 0;
80 }
std::map< std::string, uint64_t > ios
std::map< std::string, double > delays

References delays, errors, ios, and synchronicity.

Referenced by add().

Here is the caller graph for this function:

Member Function Documentation

◆ add()

void XrdCl::ActionMetrics::add ( const ActionMetrics & other)
inline

Definition at line 208 of file XrdClActionMetrics.hh.

209 {
210 for (auto& k : other.ios)
211 {
212 ios[k.first] += k.second;
213 }
214 for (auto& k : other.delays)
215 {
216 delays[k.first] += k.second;
217 }
218 errors += other.errors;
219
220 auto w1 = other.ios.find("Write::b");
221 auto w2 = other.ios.find("PgWrite::b");
222 auto w3 = other.ios.find("VectorWrite::b");
223
224 if (((w1 != other.ios.end()) && w1->second) || ((w2 != other.ios.end()) && w2->second)
225 || ((w3 != other.ios.end()) && w3->second))
226 {
227 // count as EGRES
228 aggregated_synchronicity.writes.push_back(other.synchronicity);
229 }
230 else
231 {
232 // count es INGRES
233 aggregated_synchronicity.reads.push_back(other.synchronicity);
234 }
235 }
synchronicity_t aggregated_synchronicity

References ActionMetrics(), aggregated_synchronicity, delays, errors, ios, and synchronicity.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addDelays()

void XrdCl::ActionMetrics::addDelays ( const std::string & action,
const std::string & field,
double value )
inline

Definition at line 190 of file XrdClActionMetrics.hh.

191 {
192 // function called from callbacks requires a guard
193 std::unique_lock<std::mutex> guard(mtx);
194 delays[action + "::" + field] += value;
195 }
Response NullRef< Response >::value

References delays, mtx, and XrdCl::NullRef< Response >::value.

Referenced by XrdCl::ActionExecutor::Execute(), and XrdCl::ExecuteActions().

Here is the caller graph for this function:

◆ addIos()

void XrdCl::ActionMetrics::addIos ( const std::string & action,
const std::string & field,
double value )
inline

Definition at line 197 of file XrdClActionMetrics.hh.

198 {
199 // function called from callbacks requires a guard
200 std::unique_lock<std::mutex> guard(mtx);
201 ios[action + "::" + field] += value;
202 if (field == "e")
203 {
204 ios["All::e"] += value;
205 }
206 }

References ios, mtx, and XrdCl::NullRef< Response >::value.

Referenced by XrdCl::ActionExecutor::Execute().

Here is the caller graph for this function:

◆ Dump()

std::string XrdCl::ActionMetrics::Dump ( bool json) const
inline

Definition at line 82 of file XrdClActionMetrics.hh.

83 {
84 std::stringstream ss;
85 if (!json)
86 {
87 ss << "# -----------------------------------------------------------------" << std::endl;
88 if (fname != "")
89 {
90 ss << "# File: " << fname << std::endl;
91 ss << "# Sync: " << std::fixed << std::setprecision(2) << synchronicity << "%" << std::endl;
92 ss << "# Errs: " << std::fixed << errors << std::endl;
93 }
94 else
95 {
96 ss << "# Summary" << std::endl;
97 }
98 ss << "# -----------------------------------------------------------------" << std::endl;
99 for (auto& i : delays)
100 {
101 std::string key = i.first;
102 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
103 if (i.second)
104 {
105 ss << "# " << std::setw(16) << key << " : " << std::setw(16) << std::fixed << i.second
106 << " s" << std::endl;
107 }
108 }
109 for (auto& i : ios)
110 {
111 std::string key = i.first;
112 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
113 if (i.second)
114 {
115 ss << "# " << std::setw(16) << key << " : " << std::setw(16) << i.second << std::endl;
116 }
117 }
118 }
119 else
120 {
121 std::string name = fname;
122 if (fname.empty())
123 name = "_files_summary_";
124
125 ss << " {" << std::endl;
126 ss << " \"name\":"
127 << "\"" << name << "\"," << std::endl;
128 ss << " \"synchronicity\": " << synchronicity << "," << std::endl;
129 ss << " \"errors\": " << errors << "," << std::endl;
130 for (auto& i : delays)
131 {
132 std::string key = i.first;
133 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
134 if (i.second)
135 {
136 ss << " \"" << key << "\": " << i.second << "," << std::endl;
137 }
138 }
139 for (auto& i : ios)
140 {
141 std::string key = i.first;
142 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
143 if (i.second)
144 {
145 ss << " \"" << key << "\": " << i.second << "," << std::endl;
146 }
147 }
148 ss.seekp(-2, std::ios_base::end);
149 ss << "\n";
150 if (fname.empty())
151 ss << " }" << std::endl;
152 else
153 ss << " }," << std::endl;
154 }
155 return ss.str();
156 }
nlohmann::json json

References delays, errors, fname, ios, and synchronicity.

Referenced by main().

Here is the caller graph for this function:

◆ getBytesRead()

size_t XrdCl::ActionMetrics::getBytesRead ( ) const
inline

Definition at line 174 of file XrdClActionMetrics.hh.

175 {
176 auto v1 = ios.find("Read::b");
177 auto v2 = ios.find("PgRead::b");
178 auto v3 = ios.find("VectorRead::b");
179 return (v1->second + v2->second + v3->second);
180 }

References ios.

Referenced by main().

Here is the caller graph for this function:

◆ getBytesWritten()

size_t XrdCl::ActionMetrics::getBytesWritten ( ) const
inline

Definition at line 182 of file XrdClActionMetrics.hh.

183 {
184 auto v1 = ios.find("Write::b");
185 auto v2 = ios.find("PgWrite::b");
186 auto v3 = ios.find("VectorWrite::b");
187 return (v1->second + v2->second + v3->second);
188 }

References ios.

Referenced by main().

Here is the caller graph for this function:

◆ getIopsRead()

size_t XrdCl::ActionMetrics::getIopsRead ( ) const
inline

Definition at line 158 of file XrdClActionMetrics.hh.

159 {
160 auto v1 = ios.find("Read::n");
161 auto v2 = ios.find("PgRead::n");
162 auto v3 = ios.find("VectorRead::n");
163 return (v1->second + v2->second + v3->second);
164 }

References ios.

Referenced by main().

Here is the caller graph for this function:

◆ getIopsWrite()

size_t XrdCl::ActionMetrics::getIopsWrite ( ) const
inline

Definition at line 166 of file XrdClActionMetrics.hh.

167 {
168 auto v1 = ios.find("Write::n");
169 auto v2 = ios.find("PgWrite::n");
170 auto v3 = ios.find("VectorWrite::n");
171 return (v1->second + v2->second + v3->second);
172 }

References ios.

Referenced by main().

Here is the caller graph for this function:

◆ humanreadable()

std::string XrdCl::ActionMetrics::humanreadable ( uint64_t insize)
inlinestatic

Definition at line 237 of file XrdClActionMetrics.hh.

238 {
239 const uint64_t KB = 1000ll;
240 const uint64_t MB = 1000ll * KB;
241 const uint64_t GB = 1000ll * MB;
242 const uint64_t TB = 1000ll * GB;
243 const uint64_t PB = 1000ll * TB;
244 const uint64_t EB = 1000ll * PB;
245 std::stringstream ss;
246 if (insize >= (10 * KB))
247 {
248 if (insize >= MB)
249 {
250 if (insize >= GB)
251 {
252 if (insize >= TB)
253 {
254 if (insize >= PB)
255 {
256 if (insize >= EB)
257 {
258 // EB
259 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / EB) << " EB";
260 }
261 else
262 {
263 // PB
264 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / PB) << " PB";
265 }
266 }
267 else
268 {
269 // TB
270 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / TB) << " TB";
271 }
272 }
273 else
274 {
275 // GB
276 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / GB) << " GB";
277 }
278 }
279 else
280 {
281 // MB
282 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / MB) << " MB";
283 }
284 }
285 else
286 {
287 // KB
288 ss << std::fixed << std::setprecision(2) << (insize * 1.0 / KB) << " KB";
289 }
290 }
291 else
292 {
293 ss << std::fixed << insize << " B";
294 }
295 return ss.str();
296 }

Referenced by main().

Here is the caller graph for this function:

Member Data Documentation

◆ aggregated_synchronicity

synchronicity_t XrdCl::ActionMetrics::aggregated_synchronicity

Definition at line 334 of file XrdClActionMetrics.hh.

Referenced by add(), and main().

◆ delays

std::map<std::string, double> XrdCl::ActionMetrics::delays

Definition at line 337 of file XrdClActionMetrics.hh.

Referenced by ActionMetrics(), add(), addDelays(), Dump(), XrdCl::ExecuteActions(), and main().

◆ errors

size_t XrdCl::ActionMetrics::errors

Definition at line 302 of file XrdClActionMetrics.hh.

Referenced by ActionMetrics(), add(), and Dump().

◆ fname

std::string XrdCl::ActionMetrics::fname

Definition at line 299 of file XrdClActionMetrics.hh.

Referenced by Dump().

◆ ios

std::map<std::string, uint64_t> XrdCl::ActionMetrics::ios

◆ mtx

std::mutex XrdCl::ActionMetrics::mtx

Definition at line 338 of file XrdClActionMetrics.hh.

Referenced by addDelays(), and addIos().

◆ synchronicity

double XrdCl::ActionMetrics::synchronicity

Definition at line 301 of file XrdClActionMetrics.hh.

Referenced by ActionMetrics(), add(), and Dump().

◆ url

std::string XrdCl::ActionMetrics::url

Definition at line 300 of file XrdClActionMetrics.hh.

Referenced by XrdCl::ExecuteActions().


The documentation for this struct was generated from the following file: