More info
This commit is contained in:
@@ -17,6 +17,20 @@ function readFile(p) {
|
||||
return readFileCached(p)
|
||||
}
|
||||
|
||||
let _profileIdx = 0
|
||||
function profile(label, fn) {
|
||||
const t0 = performance.now()
|
||||
const r = fn()
|
||||
const dur = performance.now() - t0
|
||||
if (dur > 2) {
|
||||
_profileIdx++
|
||||
if (_profileIdx <= 20) {
|
||||
process.stderr.write(`host_more:${label} ${Math.round(dur * 10) / 10}ms\n`)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
function rate(prev, cur, dtSec) {
|
||||
if (dtSec <= 0 || cur < prev) return 0
|
||||
return (cur - prev) / dtSec
|
||||
@@ -487,7 +501,7 @@ export function collectKsmExtras(batch, ts) {
|
||||
*/
|
||||
export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {}) {
|
||||
// softirqs
|
||||
const soft = parseSoftirqs()
|
||||
const soft = profile('parseSoftirqs', parseSoftirqs)
|
||||
const prevSoft = state.lastSoftirqs
|
||||
if (Object.keys(soft).length) {
|
||||
/** @type {Record<string, number>} */
|
||||
@@ -500,7 +514,7 @@ export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {
|
||||
}
|
||||
|
||||
// IRQs
|
||||
const irqs = parseInterrupts()
|
||||
const irqs = profile('parseInterrupts', parseInterrupts)
|
||||
const prevIrq = state.lastIrqs || {}
|
||||
/** @type {Record<string, number>} */
|
||||
const nextIrq = {}
|
||||
@@ -520,7 +534,7 @@ export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {
|
||||
state.lastIrqs = nextIrq
|
||||
|
||||
// icmpmsg
|
||||
const icmpMsg = parseIcmpMsg()
|
||||
const icmpMsg = profile('parseIcmpMsg', parseIcmpMsg)
|
||||
const prevMsg = state.lastIcmpMsg
|
||||
if (Object.keys(icmpMsg).length) {
|
||||
const pick = (k) => (prevMsg ? rate(prevMsg[k] || 0, icmpMsg[k] || 0, dtSec) : 0)
|
||||
@@ -543,7 +557,7 @@ export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {
|
||||
}
|
||||
|
||||
// ipv6
|
||||
const s6 = parseSnmp6()
|
||||
const s6 = profile('parseSnmp6', parseSnmp6)
|
||||
const prev6 = state.lastSnmp6
|
||||
if (Object.keys(s6).length) {
|
||||
const r = (k) => (prev6 ? rate(prev6[k] || 0, s6[k] || 0, dtSec) : 0)
|
||||
@@ -585,7 +599,7 @@ export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {
|
||||
}
|
||||
|
||||
// conntrack
|
||||
const ct = parseConntrack()
|
||||
const ct = profile('parseConntrack', parseConntrack)
|
||||
const prevCt = state.lastCt
|
||||
batch.push({
|
||||
chart: 'net.conntrack',
|
||||
@@ -619,15 +633,15 @@ export function collectHostMore(batch, ts, dtSec, state, { mem, vm, prevVm } = {
|
||||
chart: 'mem.pagetype_global',
|
||||
context: 'mem.pagetype_global',
|
||||
ts,
|
||||
values: parsePagetypeGlobal(),
|
||||
values: profile('parsePagetypeGlobal', parsePagetypeGlobal),
|
||||
})
|
||||
|
||||
collectNumaNodes(batch, ts)
|
||||
collectCpuidle(batch, ts, dtSec, state)
|
||||
collectPowercap(batch, ts, state)
|
||||
collectEdac(batch, ts)
|
||||
collectDebugfsExtras(batch, ts)
|
||||
if (mem) collectMemExtras(batch, ts, mem)
|
||||
collectThpMore(batch, ts, dtSec, vm, prevVm)
|
||||
collectKsmExtras(batch, ts)
|
||||
profile('collectNumaNodes', () => { collectNumaNodes(batch, ts); return true })
|
||||
profile('collectCpuidle', () => { collectCpuidle(batch, ts, dtSec, state); return true })
|
||||
profile('collectPowercap', () => { collectPowercap(batch, ts, state); return true })
|
||||
profile('collectEdac', () => { collectEdac(batch, ts); return true })
|
||||
profile('collectDebugfsExtras', () => { collectDebugfsExtras(batch, ts); return true })
|
||||
if (mem) profile('collectMemExtras', () => { collectMemExtras(batch, ts, mem); return true })
|
||||
profile('collectThpMore', () => { collectThpMore(batch, ts, dtSec, vm, prevVm); return true })
|
||||
profile('collectKsmExtras', () => { collectKsmExtras(batch, ts); return true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user