Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

resource-telemetry.md

50 lines2.9 KB

1# Resource telemetry
2​
3Process counters come from a [standalone Rust monitor](../../native/resource-monitor/src/main.rs)
4using `sysinfo`. Electron main supplies host power and Electron process metrics.
5Keeping native collection outside Node isolates collector crashes and avoids a
6Node/Electron addon ABI matrix. Desktop and CLI servers use the same child-process
7protocol. A missing or failed collector leaves the server running.
8​
9## Collection cost
10​
11The native child owns sampling and bounded in-memory history. The server requests
12continuous snapshots only while diagnostics has live subscribers and fetches
13history on demand. Consuming host power for background scheduling must not retain
14live diagnostics. There is no telemetry database or recurring shell-probe fallback.
15​
16History has independent bounds for age, snapshot count, process rows, and retained
17bytes. A count limit alone cannot bound memory when command lines vary in size.
18Large process trees therefore shorten the available history window. Linux task
19enumeration is disabled because walking every `/proc/<pid>/task/<tid>` directory
20makes sampling itself expensive.
21​
22Electron power updates travel over private inherited pipes, independent of the
23renderer connection. Power events and slow heartbeats continue with diagnostics
24closed; `app.getAppMetrics()` runs only on live demand. The receiver's stale deadline
25must exceed the slowest configured heartbeat plus scheduling grace, or intentional
26idle polling makes background policy oscillate between constrained and
27unconstrained states. Headless servers leave unavailable power data unknown.
28​
29## Measurement traps
30​
31- Process identity includes start time because operating systems reuse PIDs.
32 Electron and native start times have different precision, so merging allows a
33 small tolerance. Process signaling rechecks the native identity with a fresh
34 sample.
35- Snapshot sequence numbers belong to a monitor generation. Comparing them across
36 restarts would discard the new monitor's samples until its sequence caught up.
37- Sampling can miss a process that starts and exits between samples. Cumulative
38 counters still yield deltas for processes observed across samples.
39- Windows process I/O includes more than disk traffic. Unix counters report storage
40 I/O, which can differ from logical application reads and writes because of OS
41 caching. Keep instrumented logical I/O separate from these counters.
42- Group totals accumulate observed deltas since telemetry started. Per-process
43 cumulative counters cover the operating system's lifetime for that process.
44- Historical replay uses native samples without current Electron CPU or memory
45 metrics. Merging the latest Electron values would overwrite the past.
46​
47A WSL backend needs a Linux monitor even though Electron runs on Windows. Windows
48desktop packages currently supply only the Windows executable, so native process
49telemetry for the WSL backend is unavailable. The inherited Electron power feed
50still works.