mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
Monitor: an impossible PCIe traffic reading is no reading (#4713)
PR #4713 by ruibeikaa, its three commits taken as one (cherry-pick -n; they applied cleanly): - serve/telemetry.py: NVML PCIe throughput above 150 GiB/s (no link carries it; PCIe 6.0 x16 is under 120 GiB/s) is read once more, since a GP100 reports just under 200 GiB/s now and then even when idle, which looks like a wrapped counter; a second impossible value is dropped (no reading); - apps/host/server/device-probes.mjs: the desktop app drops the same readings. Test: serve/test_server.py NvmlPcieTraffic (3 cases) error on2ce8d8272, pass; with AmdTelemetry and test_monitored_gpu 12/12; tests/monitor-dashboard.test.mjs: 1 fails on2ce8d8272, 19/19 here.
This commit is contained in:
1 parent
2ce8d8272c
commit
a1047b7fdf
4 files changed
+45
-5
No files matched your search
@@ -51,12 +51,14 @@ export function parseNvidiaReadings(raw) {
|
||||
return [{id,temperatureC:t!==null&&t>=0&&t<=150?t:null,utilizationPct:u!==null&&u>=0&&u<=100?u:null,memoryUsedGb:m!==null&&m>=0?round(m/1024,2):null,powerW:positive(power),powerLimitW:positive(limit),pcieGen:positive(gen),pcieGenMax:positive(maxGen),pcieWidth:positive(width),pcieRxMbs:null,fanPct:percentOf(fan),clockMhz:positive(clock)}];
|
||||
});
|
||||
}
|
||||
/** A GP100 reports just under 200 GiB/s now and then, even idle (see serve/telemetry.py). No PCIe link carries that: 6.0 x16 is under 120 GiB/s. */
|
||||
const PCIE_MBS_MAX=150*1024;
|
||||
export function parsePcieThroughput(raw) {
|
||||
const values=new Map();
|
||||
for(const line of raw.split('\n')) {
|
||||
if(line.trim().startsWith('#'))continue;
|
||||
const fields=line.trim().split(/\s+/),index=number(fields[0]),rx=number(fields[1]);
|
||||
if(fields.length===3&&index!==null&&Number.isInteger(index)&&index>=0&&rx!==null&&rx>=0)values.set(index,rx);
|
||||
if(fields.length===3&&index!==null&&Number.isInteger(index)&&index>=0&&rx!==null&&rx>=0&&rx<=PCIE_MBS_MAX)values.set(index,rx);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ test('NVIDIA power and PCIe link readings survive unavailable driver fields',()=
|
||||
assert.equal(missing.temperatureC,null);assert.equal(missing.powerW,null);assert.equal(missing.utilizationPct,0);
|
||||
const transfer=parsePcieThroughput('# gpu rxpci txpci\n# Idx MB/s MB/s\n0 12.5 8\n1 200 0\n2 - -');
|
||||
assert.equal(transfer.get(0),12.5);assert.equal(transfer.get(1),200);assert.equal(transfer.has(2),false);
|
||||
const wrapped=parsePcieThroughput('# Idx MB/s MB/s\n0 59392 0\n1 209673 0\n2 5 209710');
|
||||
assert.equal(wrapped.get(0),59392);assert.equal(wrapped.has(1),false);assert.equal(wrapped.get(2),5);
|
||||
});
|
||||
test('chart paths reuse the exact original 100×32 geometry',()=>{
|
||||
const {paths}=referencePaths([0,5,10]);
|
||||
|
||||
+11
-4
@@ -23,6 +23,9 @@ import threading
|
||||
import time
|
||||
|
||||
HISTORY = 60
|
||||
# A GP100 (Pascal) reports PCIe traffic of just under 200 GiB/s now and then, even idle: 2^22 KB in NVML's 20 ms window,
|
||||
# which reads like the counter stepping back and wrapping. No link carries it (PCIe 6.0 x16 is under 120 GiB/s).
|
||||
PCIE_KB_S_MAX = 150 << 20
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------ NVML
|
||||
@@ -101,12 +104,16 @@ class _Nvml:
|
||||
out["pcie_gen"] = self._uint("nvmlDeviceGetCurrPcieLinkGeneration") # drops at idle (power saving)
|
||||
out["pcie_gen_max"] = self._uint("nvmlDeviceGetMaxPcieLinkGeneration")
|
||||
out["pcie_width"] = self._uint("nvmlDeviceGetCurrPcieLinkWidth")
|
||||
rx = self._uint("nvmlDeviceGetPcieThroughput", ctypes.c_uint(1)) # NVML_PCIE_UTIL_RX_BYTES, KB/s
|
||||
tx = self._uint("nvmlDeviceGetPcieThroughput", ctypes.c_uint(0))
|
||||
out["pcie_rx_mb"] = rx / 1024.0 if rx is not None else None
|
||||
out["pcie_tx_mb"] = tx / 1024.0 if tx is not None else None
|
||||
out["pcie_rx_mb"] = self._pcie_mb(1) # NVML_PCIE_UTIL_RX_BYTES
|
||||
out["pcie_tx_mb"] = self._pcie_mb(0)
|
||||
return out
|
||||
|
||||
def _pcie_mb(self, counter):
|
||||
kb = self._uint("nvmlDeviceGetPcieThroughput", ctypes.c_uint(counter)) # KB/s
|
||||
if kb is not None and kb > PCIE_KB_S_MAX: # wrapped: the next read is good
|
||||
kb = self._uint("nvmlDeviceGetPcieThroughput", ctypes.c_uint(counter))
|
||||
return kb / 1024.0 if kb is not None and kb <= PCIE_KB_S_MAX else None
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------ AMD (Linux sysfs)
|
||||
SYSFS = "/sys"
|
||||
|
||||
@@ -5255,6 +5255,35 @@ class ModelAliases(unittest.TestCase):
|
||||
httpd.server_close()
|
||||
|
||||
|
||||
class NvmlPcieTraffic(unittest.TestCase):
|
||||
"""A GP100 hands back 200 GiB/s now and then, idle: it reaches neither the tile nor a card's total."""
|
||||
WRAPPED = 209_708_000 # 7 MB/s under 2^22 KB / 20 ms
|
||||
|
||||
def reads(self, *kb_s):
|
||||
"""What one reading gives from these driver answers, and how many answers were left unread."""
|
||||
from serve import telemetry
|
||||
|
||||
class Lib:
|
||||
left = list(kb_s)
|
||||
|
||||
def nvmlDeviceGetPcieThroughput(self, dev, counter, out):
|
||||
out._obj.value = self.left.pop(0)
|
||||
return 0
|
||||
|
||||
g = telemetry._Nvml.__new__(telemetry._Nvml)
|
||||
g.dev, g.lib = None, Lib()
|
||||
return g._pcie_mb(1), len(g.lib.left)
|
||||
|
||||
def test_a_real_reading_is_kept(self):
|
||||
self.assertEqual(self.reads(58 << 20, 0), (59392.0, 1)) # about PCIe 5.0 x16's top
|
||||
|
||||
def test_a_wrapped_reading_is_read_again(self):
|
||||
self.assertEqual(self.reads(self.WRAPPED, 2048), (2.0, 0))
|
||||
|
||||
def test_it_is_read_again_once(self):
|
||||
self.assertEqual(self.reads(self.WRAPPED, self.WRAPPED, 2048), (None, 1))
|
||||
|
||||
|
||||
class AmdTelemetry(unittest.TestCase):
|
||||
"""#301: the AMD backend's readings from a fake amdgpu sysfs tree: KFD node -> render node, as setup numbers the
|
||||
cards (the CPU node skipped), and free_vram_mib on HIP."""
|
||||
|
||||
Reference in new issue
Block a user