mon: Do not truncate per-OSD iops before summing them #224
14
mon/stats.js
14
mon/stats.js
@@ -9,6 +9,7 @@ function derive_osd_stats(st, prev, prev_diff)
|
||||
return diff;
|
||||
}
|
||||
const timediff = BigInt(st.time*1000 - prev.time*1000);
|
||||
// iops are in 1/1000 op/s until sum_op_stats() and sum_inode_stats() add them up
|
||||
for (const op in st.op_stats||{})
|
||||
{
|
||||
const pr = prev && prev.op_stats && prev.op_stats[op];
|
||||
@@ -17,7 +18,7 @@ function derive_osd_stats(st, prev, prev_diff)
|
||||
const b = c.bytes - BigInt(pr && pr.bytes||0);
|
||||
const us = c.usec - BigInt(pr && pr.usec||0);
|
||||
const n = c.count - BigInt(pr && pr.count||0);
|
||||
diff.op_stats[op] = { ...c, bps: n > 0 ? b*1000n/timediff : 0n, iops: n > 0 ? n*1000n/timediff : 0n, lat: n > 0 ? us/n : 0n };
|
||||
diff.op_stats[op] = { ...c, bps: n > 0 ? b*1000n/timediff : 0n, iops: n > 0 ? n*1000000n/timediff : 0n, lat: n > 0 ? us/n : 0n };
|
||||
}
|
||||
for (const op in st.subop_stats||{})
|
||||
{
|
||||
@@ -26,7 +27,7 @@ function derive_osd_stats(st, prev, prev_diff)
|
||||
c = { usec: BigInt(c.usec||0), count: BigInt(c.count||0) };
|
||||
const us = c.usec - BigInt(pr && pr.usec||0);
|
||||
const n = c.count - BigInt(pr && pr.count||0);
|
||||
diff.subop_stats[op] = { ...c, iops: n > 0 ? n*1000n/timediff : 0n, lat: n > 0 ? us/n : 0n };
|
||||
diff.subop_stats[op] = { ...c, iops: n > 0 ? n*1000000n/timediff : 0n, lat: n > 0 ? us/n : 0n };
|
||||
}
|
||||
for (const op in st.recovery_stats||{})
|
||||
{
|
||||
@@ -35,7 +36,7 @@ function derive_osd_stats(st, prev, prev_diff)
|
||||
c = { bytes: BigInt(c.bytes||0), count: BigInt(c.count||0) };
|
||||
const b = c.bytes - BigInt(pr && pr.bytes||0);
|
||||
const n = c.count - BigInt(pr && pr.count||0);
|
||||
diff.recovery_stats[op] = { ...c, bps: n > 0 ? b*1000n/timediff : 0n, iops: n > 0 ? n*1000n/timediff : 0n };
|
||||
diff.recovery_stats[op] = { ...c, bps: n > 0 ? b*1000n/timediff : 0n, iops: n > 0 ? n*1000000n/timediff : 0n };
|
||||
}
|
||||
diff.inode_stats = {};
|
||||
for (const pool_id in st.inode_stats||{})
|
||||
@@ -52,7 +53,7 @@ function derive_osd_stats(st, prev, prev_diff)
|
||||
const n = BigInt(c.count||0) - BigInt(pr && pr.count||0);
|
||||
inode_diff[op] = {
|
||||
bps: n > 0 ? (BigInt(c.bytes||0) - BigInt(pr && pr.bytes||0))*1000n/timediff : 0n,
|
||||
iops: n > 0 ? n*1000n/timediff : 0n,
|
||||
iops: n > 0 ? n*1000000n/timediff : 0n,
|
||||
lat: n > 0 ? (BigInt(c.usec||0) - BigInt(pr && pr.usec||0))/n : 0n,
|
||||
};
|
||||
}
|
||||
@@ -105,6 +106,10 @@ function sum_op_stats(all_osd, prev_stats)
|
||||
{
|
||||
sum_diff[type][op].lat /= sum_diff[type][op].iops;
|
||||
}
|
||||
if (sum_diff[type][op].iops)
|
||||
{
|
||||
sum_diff[type][op].iops = (sum_diff[type][op].iops + 999n) / 1000n;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum_diff;
|
||||
@@ -305,6 +310,7 @@ function sum_inode_stats(state, prev_stats)
|
||||
const op_st = inode_stats[pool_id][inode_num][op];
|
||||
if (op_st.lat)
|
||||
op_st.lat /= op_st.iops;
|
||||
op_st.iops = (op_st.iops + 999n) / 1000n;
|
||||
if (op_st.bps > 0 || op_st.iops > 0)
|
||||
nonzero = true;
|
||||
}
|
||||
|
||||
43
mon/test-stats-iops.js
Normal file
43
mon/test-stats-iops.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) Vitaliy Filippov, 2019+
|
||||
// License: VNPL-1.1 (see README.md for details)
|
||||
|
||||
// Rates summed over OSDs that each serve less than 1 op/s. Run: node mon/test-stats-iops.js
|
||||
|
||||
const assert = require('assert');
|
||||
const { sum_op_stats, sum_inode_stats } = require('./stats.js');
|
||||
|
||||
// One image read at 0.8 op/s on each of <osds> OSDs, 200 us per op, OSD stats reported every 5 s
|
||||
function run(osds)
|
||||
{
|
||||
const prev_stats = { osd_stats: {}, osd_diff: {} };
|
||||
let res;
|
||||
for (let round = 1; round <= 2; round++)
|
||||
{
|
||||
const st = { count: 4*round, usec: 800*round, bytes: 16384*round };
|
||||
const state = {
|
||||
config: { pools: { 1: {} }, inode: { 1: { 1: {} } } },
|
||||
pool: { stats: {} },
|
||||
osd: { state: {}, stats: {}, inodestats: {}, space: {} },
|
||||
};
|
||||
for (let osd = 1; osd <= osds; osd++)
|
||||
{
|
||||
state.osd.state[osd] = { state: 'up' };
|
||||
state.osd.stats[osd] = { time: 5*round, op_stats: { primary_read: st } };
|
||||
state.osd.inodestats[osd] = { 1: { 1: { read: st, write: {}, delete: {} } } };
|
||||
}
|
||||
res = { stats: sum_op_stats(state.osd, prev_stats), inode: sum_inode_stats(state, prev_stats).inode_stats[1][1] };
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
let { stats, inode } = run(48);
|
||||
// 48 * 0.8 = 38.4 op/s, rounded up
|
||||
assert.equal(stats.op_stats.primary_read.iops, 39n);
|
||||
assert.equal(stats.op_stats.primary_read.lat, 200n);
|
||||
assert.equal(inode.read.iops, 39n);
|
||||
assert.equal(inode.read.lat, 200n);
|
||||
({ stats, inode } = run(1));
|
||||
// Any I/O shows as at least 1 op/s
|
||||
assert.equal(inode.read.iops, 1n);
|
||||
assert.equal(inode.read.lat, 200n);
|
||||
console.log('OK');
|
||||
Reference in New Issue
Block a user