XRootD
XrdOssStatsFileSystem.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
5 #include "XrdSys/XrdSysError.hh"
6 
7 #include <atomic>
8 #include <chrono>
9 #include <memory>
10 
11 class XrdXrootdGStream;
12 
13 // The "stats" filesystem is a wrapper that collects information
14 // about the performance of the underlying storage.
15 //
16 // It allows one to accumulate time spent in I/O, the number of operations,
17 // and information about "slow" operations
19  friend class StatsFile;
20  friend class StatsDirectory;
21 
22 public:
23  // Note: StatsFileSystem takes ownerhip of the underlying oss
24  StatsFileSystem(XrdOss *oss, XrdSysLogger *log, const char *configName, XrdOucEnv *envP);
25  virtual ~StatsFileSystem();
26 
27  bool
28  Config(const char *configfn);
29 
30  XrdOssDF *newDir(const char *user=0) override;
31  XrdOssDF *newFile(const char *user=0) override;
32  int Chmod(const char * path, mode_t mode, XrdOucEnv *env=0) override;
33  int Rename(const char *oPath, const char *nPath,
34  XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0) override;
35  int Stat(const char *path, struct stat *buff,
36  int opts=0, XrdOucEnv *env=0) override;
37  int StatFS(const char *path, char *buff, int &blen,
38  XrdOucEnv *env=0) override;
39  int StatLS(XrdOucEnv &env, const char *path,
40  char *buff, int &blen) override;
41  int StatPF(const char *path, struct stat *buff, int opts) override;
42  int StatPF(const char *path, struct stat *buff) override;
43  int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0) override;
44  int StatXA(const char *path, char *buff, int &blen,
45  XrdOucEnv *env=0) override;
46  int StatXP(const char *path, unsigned long long &attr,
47  XrdOucEnv *env=0) override;
48  int Truncate(const char *path, unsigned long long fsize,
49  XrdOucEnv *env=0) override;
50  int Unlink(const char *path, int Opts=0, XrdOucEnv *env=0) override;
51 
52 private:
53  static void * AggregateBootstrap(void *instance);
54  void AggregateStats();
55 
56  XrdXrootdGStream* m_gstream{nullptr};
57 
58  std::unique_ptr<XrdOss> m_oss;
59  XrdOucEnv *m_env;
60  XrdSysError m_log;
61 
62  class OpTimer {
63  public:
64  OpTimer(std::atomic<uint64_t> &op_count, std::atomic<uint64_t> &slow_op_count, std::atomic<uint64_t> &timing, std::atomic<uint64_t> &slow_timing, std::chrono::steady_clock::duration duration);
65  ~OpTimer();
66 
67  private:
68  std::atomic<uint64_t> &m_op_count;
69  std::atomic<uint64_t> &m_slow_op_count;
70  std::atomic<uint64_t> &m_timing;
71  std::atomic<uint64_t> &m_slow_timing;
72  std::chrono::steady_clock::time_point m_start;
73  std::chrono::steady_clock::duration m_slow_duration;
74  };
75 
76  struct OpRecord {
77  std::atomic<uint64_t> m_read_ops{0};
78  std::atomic<uint64_t> m_write_ops{0};
79  std::atomic<uint64_t> m_stat_ops{0};
80  std::atomic<uint64_t> m_pgread_ops{0};
81  std::atomic<uint64_t> m_pgwrite_ops{0};
82  std::atomic<uint64_t> m_readv_ops{0};
83  std::atomic<uint64_t> m_readv_segs{0};
84  std::atomic<uint64_t> m_dirlist_ops{0};
85  std::atomic<uint64_t> m_dirlist_entries{0};
86  std::atomic<uint64_t> m_truncate_ops{0};
87  std::atomic<uint64_t> m_unlink_ops{0};
88  std::atomic<uint64_t> m_chmod_ops{0};
89  std::atomic<uint64_t> m_open_ops{0};
90  std::atomic<uint64_t> m_rename_ops{0};
91  };
92 
93  struct OpTiming {
94  std::atomic<uint64_t> m_open{0};
95  std::atomic<uint64_t> m_read{0};
96  std::atomic<uint64_t> m_readv{0};
97  std::atomic<uint64_t> m_pgread{0};
98  std::atomic<uint64_t> m_write{0};
99  std::atomic<uint64_t> m_pgwrite{0};
100  std::atomic<uint64_t> m_dirlist{0};
101  std::atomic<uint64_t> m_stat{0};
102  std::atomic<uint64_t> m_truncate{0};
103  std::atomic<uint64_t> m_unlink{0};
104  std::atomic<uint64_t> m_rename{0};
105  std::atomic<uint64_t> m_chmod{0};
106  };
107 
108  OpRecord m_ops;
109  OpTiming m_times;
110  OpRecord m_slow_ops;
111  OpTiming m_slow_times;
112  std::chrono::steady_clock::duration m_slow_duration;
113 };
int stat(const char *path, struct stat *buf)
struct myOpts opts
XrdOssDF * newDir(const char *user=0) override
StatsFileSystem(XrdOss *oss, XrdSysLogger *log, const char *configName, XrdOucEnv *envP)
int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *env=0) override
int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *env=0) override
int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *env=0) override
XrdOssDF * newFile(const char *user=0) override
bool Config(const char *configfn)
int StatPF(const char *path, struct stat *buff, int opts) override
int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen) override
int Unlink(const char *path, int Opts=0, XrdOucEnv *env=0) override
int Chmod(const char *path, mode_t mode, XrdOucEnv *env=0) override
int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0) override
int Truncate(const char *path, unsigned long long fsize, XrdOucEnv *env=0) override
int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *env=0) override
int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0) override
int Opts
Definition: XrdMpxStats.cc:58
XrdOucEnv * envP
Definition: XrdPss.cc:109