Report inode I/O statistics, aggregate it in the monitor
This commit is contained in:
+1
-1
@@ -154,7 +154,7 @@ struct osd_primary_op_data_t;
|
||||
|
||||
struct osd_op_t
|
||||
{
|
||||
timespec tv_begin;
|
||||
timespec tv_begin = { 0 }, tv_end = { 0 };
|
||||
uint64_t op_type = OSD_OP_IN;
|
||||
int peer_fd;
|
||||
osd_any_op_t req;
|
||||
|
||||
+6
-4
@@ -109,8 +109,10 @@ void osd_messenger_t::measure_exec(osd_op_t *cur_op)
|
||||
{
|
||||
return;
|
||||
}
|
||||
timespec tv_end;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_end);
|
||||
if (!cur_op->tv_end.tv_sec)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &cur_op->tv_end);
|
||||
}
|
||||
stats.op_stat_count[cur_op->req.hdr.opcode]++;
|
||||
if (!stats.op_stat_count[cur_op->req.hdr.opcode])
|
||||
{
|
||||
@@ -119,8 +121,8 @@ void osd_messenger_t::measure_exec(osd_op_t *cur_op)
|
||||
stats.op_stat_bytes[cur_op->req.hdr.opcode] = 0;
|
||||
}
|
||||
stats.op_stat_sum[cur_op->req.hdr.opcode] += (
|
||||
(tv_end.tv_sec - cur_op->tv_begin.tv_sec)*1000000 +
|
||||
(tv_end.tv_nsec - cur_op->tv_begin.tv_nsec)/1000
|
||||
(cur_op->tv_end.tv_sec - cur_op->tv_begin.tv_sec)*1000000 +
|
||||
(cur_op->tv_end.tv_nsec - cur_op->tv_begin.tv_nsec)/1000
|
||||
);
|
||||
if (cur_op->req.hdr.opcode == OSD_OP_READ ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_WRITE)
|
||||
|
||||
@@ -55,6 +55,17 @@ struct osd_recovery_op_t
|
||||
osd_op_t *osd_op = NULL;
|
||||
};
|
||||
|
||||
// Posted as /osd/inodestats/$osd, then accumulated by the monitor
|
||||
#define INODE_STATS_READ 0
|
||||
#define INODE_STATS_WRITE 1
|
||||
#define INODE_STATS_DELETE 2
|
||||
struct inode_stats_t
|
||||
{
|
||||
uint64_t op_sum[3] = { 0 };
|
||||
uint64_t op_count[3] = { 0 };
|
||||
uint64_t op_bytes[3] = { 0 };
|
||||
};
|
||||
|
||||
class osd_t
|
||||
{
|
||||
// config
|
||||
@@ -126,6 +137,7 @@ class osd_t
|
||||
|
||||
// op statistics
|
||||
osd_op_stats_t prev_stats;
|
||||
std::map<uint64_t, inode_stats_t> inode_stats;
|
||||
const char* recovery_stat_names[2] = { "degraded", "misplaced" };
|
||||
uint64_t recovery_stat_count[2][2] = { 0 };
|
||||
uint64_t recovery_stat_bytes[2][2] = { 0 };
|
||||
|
||||
@@ -187,6 +187,27 @@ void osd_t::report_statistics()
|
||||
{
|
||||
inode_space[std::to_string(kv.first)] = kv.second;
|
||||
}
|
||||
json11::Json::object inode_ops;
|
||||
for (auto kv: inode_stats)
|
||||
{
|
||||
inode_ops[std::to_string(kv.first)] = json11::Json::object {
|
||||
{ "read", json11::Json::object {
|
||||
{ "count", kv.second.op_count[INODE_STATS_READ] },
|
||||
{ "usec", kv.second.op_sum[INODE_STATS_READ] },
|
||||
{ "bytes", kv.second.op_bytes[INODE_STATS_READ] },
|
||||
} },
|
||||
{ "write", json11::Json::object {
|
||||
{ "count", kv.second.op_count[INODE_STATS_WRITE] },
|
||||
{ "usec", kv.second.op_sum[INODE_STATS_WRITE] },
|
||||
{ "bytes", kv.second.op_bytes[INODE_STATS_WRITE] },
|
||||
} },
|
||||
{ "delete", json11::Json::object {
|
||||
{ "count", kv.second.op_count[INODE_STATS_DELETE] },
|
||||
{ "usec", kv.second.op_sum[INODE_STATS_DELETE] },
|
||||
{ "bytes", kv.second.op_bytes[INODE_STATS_DELETE] },
|
||||
} },
|
||||
};
|
||||
}
|
||||
json11::Json::array txn = { json11::Json::object {
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/stats/"+std::to_string(osd_num)) },
|
||||
@@ -196,6 +217,10 @@ void osd_t::report_statistics()
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/space/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(json11::Json(inode_space).dump()) },
|
||||
} },
|
||||
{ "request_put", json11::Json::object {
|
||||
{ "key", base64_encode(st_cli.etcd_prefix+"/osd/inodestats/"+std::to_string(osd_num)) },
|
||||
{ "value", base64_encode(json11::Json(inode_ops).dump()) },
|
||||
} },
|
||||
} };
|
||||
for (auto & p: pgs)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,29 @@ void osd_t::autosync()
|
||||
void osd_t::finish_op(osd_op_t *cur_op, int retval)
|
||||
{
|
||||
inflight_ops--;
|
||||
if (cur_op->req.hdr.opcode == OSD_OP_READ ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_WRITE ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_DELETE)
|
||||
{
|
||||
// Track inode statistics
|
||||
if (!cur_op->tv_end.tv_sec)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &cur_op->tv_end);
|
||||
}
|
||||
uint64_t usec = (
|
||||
(cur_op->tv_end.tv_sec - cur_op->tv_begin.tv_sec)*1000000 +
|
||||
(cur_op->tv_end.tv_nsec - cur_op->tv_begin.tv_nsec)/1000
|
||||
);
|
||||
int inode_st_op = cur_op->req.hdr.opcode == OSD_OP_DELETE
|
||||
? INODE_STATS_DELETE
|
||||
: (cur_op->req.hdr.opcode == OSD_OP_READ ? INODE_STATS_READ : INODE_STATS_WRITE);
|
||||
inode_stats[cur_op->req.rw.inode].op_count[inode_st_op]++;
|
||||
inode_stats[cur_op->req.rw.inode].op_sum[inode_st_op] += usec;
|
||||
if (cur_op->req.hdr.opcode == OSD_OP_DELETE)
|
||||
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += cur_op->op_data->pg_data_size * bs_block_size;
|
||||
else
|
||||
inode_stats[cur_op->req.rw.inode].op_bytes[inode_st_op] += cur_op->req.rw.len;
|
||||
}
|
||||
if (cur_op->op_data)
|
||||
{
|
||||
if (cur_op->op_data->pg_num > 0)
|
||||
@@ -66,7 +89,7 @@ void osd_t::finish_op(osd_op_t *cur_op, int retval)
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME add separate magic number
|
||||
// FIXME add separate magic number for primary ops
|
||||
auto cl_it = c_cli.clients.find(cur_op->peer_fd);
|
||||
if (cl_it != c_cli.clients.end())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user