More info
CI / test (push) Successful in 59s
Release rolling / release (push) Successful in 7m20s

This commit is contained in:
Raven Scott
2026-07-21 13:32:27 -04:00
parent 5f582d2e3d
commit 26298fb8d4
3 changed files with 61 additions and 18 deletions
+28 -14
View File
@@ -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 })
}