@hydranium/core 1.0.0-next.198 → 1.0.0-next.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/lib/documents/ast-document-manager.d.ts +2 -52
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/index.d.ts +0 -1
- package/lib/documents/index.d.ts.map +1 -1
- package/lib/documents/index.js +0 -1
- package/lib/documents/index.js.map +1 -1
- package/lib/langium/integrity/integrity-service.d.ts +1 -1
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/language-module.d.ts +2 -2
- package/lib/langium/language-module.d.ts.map +1 -1
- package/lib/langium/language-module.js +2 -2
- package/lib/langium/language-module.js.map +1 -1
- package/lib/langium/module.d.ts +3 -3
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +1 -1
- package/lib/langium/module.js.map +1 -1
- package/lib/langium/shared-services.d.ts +2 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/validation/validation-contribution-collector.d.ts +9 -1
- package/lib/langium/validation/validation-contribution-collector.d.ts.map +1 -1
- package/lib/langium/validation/validation-contribution-collector.js +1 -1
- package/lib/langium/validation/validation-contribution-collector.js.map +1 -1
- package/lib/langium/workspace/file-system-provider.d.ts +52 -2
- package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/file-system-provider.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/index.d.ts +1 -0
- package/lib/langium/workspace/index.d.ts.map +1 -1
- package/lib/langium/workspace/index.js +1 -0
- package/lib/langium/workspace/index.js.map +1 -1
- package/lib/langium/workspace/persistent-file-system-provider.d.ts +1 -1
- package/lib/langium/workspace/persistent-file-system-provider.d.ts.map +1 -1
- package/lib/{documents → langium/workspace}/self-save-registry.d.ts +1 -1
- package/lib/langium/workspace/self-save-registry.d.ts.map +1 -0
- package/lib/{documents → langium/workspace}/self-save-registry.js +1 -1
- package/lib/langium/workspace/self-save-registry.js.map +1 -0
- package/lib/langium/workspace/virtual-document.d.ts +1 -1
- package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
- package/lib/lsp/hydranium-document-update-handler.d.ts +2 -2
- package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
- package/lib/node/index.d.ts +0 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -1
- package/lib/node/index.js.map +1 -1
- package/lib/node/node-file-system-provider.d.ts +2 -2
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/profile-capture.js +1 -1
- package/lib/node/profile-capture.js.map +1 -1
- package/lib/testing/stub-ast-document-manager.d.ts +2 -1
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-self-save-registry.d.ts +1 -1
- package/lib/testing/stub-self-save-registry.d.ts.map +1 -1
- package/lib/testing/stub-writable-file-system.d.ts +1 -1
- package/lib/testing/stub-writable-file-system.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/documents/ast-document-manager.ts +2 -61
- package/src/documents/index.ts +0 -1
- package/src/langium/integrity/integrity-service.ts +1 -1
- package/src/langium/language-module.ts +6 -3
- package/src/langium/module.ts +4 -3
- package/src/langium/shared-services.ts +2 -2
- package/src/langium/validation/validation-contribution-collector.ts +10 -1
- package/src/langium/workspace/file-system-provider.ts +53 -2
- package/src/langium/workspace/hydranium-workspace-manager.ts +1 -1
- package/src/langium/workspace/in-memory-file-system-provider.ts +1 -1
- package/src/langium/workspace/index.ts +1 -0
- package/src/langium/workspace/persistent-file-system-provider.ts +1 -1
- package/src/{documents → langium/workspace}/self-save-registry.ts +2 -2
- package/src/langium/workspace/virtual-document.ts +1 -1
- package/src/lsp/hydranium-document-update-handler.ts +2 -2
- package/src/node/index.ts +0 -1
- package/src/node/node-file-system-provider.ts +2 -2
- package/src/node/profile-capture.ts +1 -1
- package/src/testing/parse-semantic-root.ts +1 -1
- package/src/testing/stub-ast-document-manager.ts +2 -2
- package/src/testing/stub-self-save-registry.ts +1 -1
- package/src/testing/stub-writable-file-system.ts +1 -1
- package/lib/documents/self-save-registry.d.ts.map +0 -1
- package/lib/documents/self-save-registry.js.map +0 -1
- package/lib/node/process-memory.d.ts +0 -66
- package/lib/node/process-memory.d.ts.map +0 -1
- package/lib/node/process-memory.js +0 -252
- package/lib/node/process-memory.js.map +0 -1
- package/src/node/process-memory.ts +0 -299
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
-
*
|
|
4
|
-
* This program and the accompanying materials are made available under the
|
|
5
|
-
* terms of the MIT License which is available in the project root.
|
|
6
|
-
*
|
|
7
|
-
* SPDX-License-Identifier: MIT
|
|
8
|
-
********************************************************************************/
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
* Node-only process- and pod-level memory introspection plus heap-snapshot
|
|
12
|
-
* writing. Everything here is generic OS-level code (V8 stats, cgroup v2/v1,
|
|
13
|
-
* `/proc`); the only host-specific part is naming the processes, which a head
|
|
14
|
-
* supplies through a `ProcessClassifier`.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Format } from '@hydranium/protocol';
|
|
18
|
-
import * as fs from 'node:fs';
|
|
19
|
-
import * as os from 'node:os';
|
|
20
|
-
import * as path from 'node:path';
|
|
21
|
-
import * as v8 from 'node:v8';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Format a one-shot memory snapshot of the CURRENT process (heap, rss, external, V8 limit).
|
|
25
|
-
* Suited to a process that hosts no Langium documents (e.g. a host backend); for the
|
|
26
|
-
* language-server process with document counts, see `formatServerState`.
|
|
27
|
-
*/
|
|
28
|
-
export function formatProcessMemory(label: string): string {
|
|
29
|
-
const mem = process.memoryUsage();
|
|
30
|
-
const heap = v8.getHeapStatistics();
|
|
31
|
-
const heapPercent = Math.round((mem.heapUsed / heap.heap_size_limit) * 100);
|
|
32
|
-
return [
|
|
33
|
-
`${label}:`,
|
|
34
|
-
` heap ${Format.bytes(mem.heapUsed)} used / ${Format.bytes(mem.heapTotal)} total / ` +
|
|
35
|
-
`${Format.bytes(heap.heap_size_limit)} limit (${heapPercent}% of limit)`,
|
|
36
|
-
` rss ${Format.bytes(mem.rss)}, external ${Format.bytes(mem.external)}, arrayBuffers ${Format.bytes(mem.arrayBuffers)}`,
|
|
37
|
-
` uptime ${Math.round(process.uptime())}s, pid ${process.pid}`
|
|
38
|
-
].join('\n');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Compose an absolute artifact file path of the form `<prefix>[-<label>].<ext>` inside
|
|
43
|
-
* {@link directory} (e.g. the workspace folder, so it lands on the persistent volume in cloud and
|
|
44
|
-
* is visible in the file explorer), falling back to the OS temp dir when the directory is missing
|
|
45
|
-
* or does not exist. The {@link prefix} carries the origin-first stem (e.g. `server-cpu`) and, when
|
|
46
|
-
* a non-empty {@link label} is given (a named capture window), it is sanitised (non-word characters
|
|
47
|
-
* → `_`, truncated to 40 chars) and appended as `-<label>`; an empty label yields the bare
|
|
48
|
-
* `<prefix>.<ext>` so the manifest `kind` equals the filename stem. No timestamp — a fresh session
|
|
49
|
-
* directory per run keeps names stable and collision-free. Shared by the heap-snapshot writer and
|
|
50
|
-
* the sampled-profile capture so heap / CPU / allocation artefacts land identically, differing only
|
|
51
|
-
* by extension.
|
|
52
|
-
*/
|
|
53
|
-
export function snapshotFilePath(directory: string | undefined, label: string, prefix: string, ext: string): string {
|
|
54
|
-
const safeLabel = label ? label.replace(/[^\w.-]+/g, '_').slice(0, 40) : '';
|
|
55
|
-
const dir = directory && fs.existsSync(directory) ? directory : os.tmpdir();
|
|
56
|
-
const stem = safeLabel ? `${prefix}-${safeLabel}` : prefix;
|
|
57
|
-
return path.join(dir, `${stem}.${ext}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Write a V8 heap snapshot of the CURRENT process to {@link directory}, falling back to the OS temp
|
|
62
|
-
* dir when it is missing (see {@link snapshotFilePath}). `v8.writeHeapSnapshot` runs a full GC first and
|
|
63
|
-
* briefly pauses the process; it also transiently inflates RSS while serialising. Returns the
|
|
64
|
-
* absolute file path. The {@link prefix} (default `server-heap`, the origin-first stem) and
|
|
65
|
-
* {@link label} are folded into the name.
|
|
66
|
-
*/
|
|
67
|
-
export function writeHeapSnapshotToDir(directory: string | undefined, label: string, prefix = 'server-heap'): string {
|
|
68
|
-
const filePath = snapshotFilePath(directory, label, prefix, 'heapsnapshot');
|
|
69
|
-
v8.writeHeapSnapshot(filePath);
|
|
70
|
-
return filePath;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const CGROUP_ROOT = '/sys/fs/cgroup';
|
|
74
|
-
|
|
75
|
-
function readNumber(file: string): number | undefined {
|
|
76
|
-
try {
|
|
77
|
-
const text = fs.readFileSync(file, 'utf8').trim();
|
|
78
|
-
if (text === 'max') {
|
|
79
|
-
return Number.POSITIVE_INFINITY;
|
|
80
|
-
}
|
|
81
|
-
const value = Number(text);
|
|
82
|
-
return Number.isFinite(value) ? value : undefined;
|
|
83
|
-
} catch {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Parse a `key value` per-line file (cgroup memory.stat) into a map. */
|
|
89
|
-
function readKeyedBytes(file: string): Record<string, number> {
|
|
90
|
-
const out: Record<string, number> = {};
|
|
91
|
-
try {
|
|
92
|
-
for (const line of fs.readFileSync(file, 'utf8').split('\n')) {
|
|
93
|
-
const [key, value] = line.trim().split(/\s+/);
|
|
94
|
-
if (key && value !== undefined) {
|
|
95
|
-
const num = Number(value);
|
|
96
|
-
if (Number.isFinite(num)) {
|
|
97
|
-
out[key] = num;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
} catch {
|
|
102
|
-
// file absent or unreadable; caller handles the empty map.
|
|
103
|
-
}
|
|
104
|
-
return out;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
interface ProcInfo {
|
|
108
|
-
pid: number;
|
|
109
|
-
rssBytes: number;
|
|
110
|
-
label: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface RawProc extends ProcInfo {
|
|
114
|
-
ppid: number;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** A readable role for a process, whether it belongs to the app, and whether exactly one is expected. */
|
|
118
|
-
export interface ProcessRole {
|
|
119
|
-
/** Human-readable role shown in the snapshot. */
|
|
120
|
-
role: string;
|
|
121
|
-
/** Whether this process is part of the application (vs. tooling/debugger), counted in the app total. */
|
|
122
|
-
isApp: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Set when at most one instance of this role should exist; `formatPodMemory` warns when more than
|
|
125
|
-
* one is found (e.g. a duplicated/ghost language server).
|
|
126
|
-
*/
|
|
127
|
-
singletonExpected?: boolean;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** Map a raw command line to a {@link ProcessRole}. A head supplies this to label its own processes. */
|
|
131
|
-
export type ProcessClassifier = (cmdline: string) => ProcessRole;
|
|
132
|
-
|
|
133
|
-
/** Generic fallback: every process is shown under the app heading, labelled by its (truncated) command line. */
|
|
134
|
-
const defaultProcessClassifier: ProcessClassifier = cmdline => ({ role: cmdline ? cmdline.slice(0, 60) : 'process', isApp: true });
|
|
135
|
-
|
|
136
|
-
/** Read /proc for every visible process: pid, ppid, RSS, and a command label. */
|
|
137
|
-
function readAllProcs(): RawProc[] {
|
|
138
|
-
const procs: RawProc[] = [];
|
|
139
|
-
let entries: string[] = [];
|
|
140
|
-
try {
|
|
141
|
-
entries = fs.readdirSync('/proc');
|
|
142
|
-
} catch {
|
|
143
|
-
return procs;
|
|
144
|
-
}
|
|
145
|
-
for (const entry of entries) {
|
|
146
|
-
if (!/^\d+$/.test(entry)) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
let status = '';
|
|
150
|
-
try {
|
|
151
|
-
status = fs.readFileSync(`/proc/${entry}/status`, 'utf8');
|
|
152
|
-
} catch {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const rssMatch = status.match(/^VmRSS:\s+(\d+)\s+kB/m);
|
|
156
|
-
if (!rssMatch) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const ppid = Number(status.match(/^PPid:\s+(\d+)/m)?.[1] ?? 0);
|
|
160
|
-
let label = '';
|
|
161
|
-
try {
|
|
162
|
-
label = fs.readFileSync(`/proc/${entry}/cmdline`, 'utf8').replace(/\0/g, ' ').trim();
|
|
163
|
-
} catch {
|
|
164
|
-
// fall back to the process name from status below.
|
|
165
|
-
}
|
|
166
|
-
if (!label) {
|
|
167
|
-
label = status.match(/^Name:\s+(.+)$/m)?.[1] ?? `pid ${entry}`;
|
|
168
|
-
}
|
|
169
|
-
procs.push({ pid: Number(entry), ppid, rssBytes: Number(rssMatch[1]) * 1024, label });
|
|
170
|
-
}
|
|
171
|
-
return procs;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Sum and list per-process RSS. When {@link rootPid} is given, restrict to that process and its
|
|
176
|
-
* descendants (the app's own process tree), which keeps the figure meaningful in local dev where
|
|
177
|
-
* /proc otherwise shows the whole machine. In a container's PID namespace the tree is effectively
|
|
178
|
-
* all the pod's processes anyway.
|
|
179
|
-
*/
|
|
180
|
-
function collectProcessRss(rootPid?: number): { total: number; processes: ProcInfo[]; scoped: boolean } {
|
|
181
|
-
const all = readAllProcs();
|
|
182
|
-
let selected: RawProc[] = all;
|
|
183
|
-
let scoped = false;
|
|
184
|
-
if (rootPid !== undefined) {
|
|
185
|
-
const childrenByPpid = new Map<number, RawProc[]>();
|
|
186
|
-
for (const proc of all) {
|
|
187
|
-
(childrenByPpid.get(proc.ppid) ?? childrenByPpid.set(proc.ppid, []).get(proc.ppid)!).push(proc);
|
|
188
|
-
}
|
|
189
|
-
const tree: RawProc[] = [];
|
|
190
|
-
const queue = all.filter(proc => proc.pid === rootPid);
|
|
191
|
-
while (queue.length > 0) {
|
|
192
|
-
const proc = queue.shift()!;
|
|
193
|
-
tree.push(proc);
|
|
194
|
-
queue.push(...(childrenByPpid.get(proc.pid) ?? []));
|
|
195
|
-
}
|
|
196
|
-
if (tree.length > 0) {
|
|
197
|
-
selected = tree;
|
|
198
|
-
scoped = true;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const total = selected.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
202
|
-
selected.sort((a, b) => b.rssBytes - a.rssBytes);
|
|
203
|
-
return { total, processes: selected, scoped };
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** Options for {@link formatPodMemory}. */
|
|
207
|
-
export interface PodMemoryOptions {
|
|
208
|
-
/** Map a process command line to a readable role; lets a head label its own processes. */
|
|
209
|
-
classify?: ProcessClassifier;
|
|
210
|
-
/** Heading for the in-app process group (default `Application`). */
|
|
211
|
-
appLabel?: string;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Format a pod/container-level memory snapshot read from the cgroup this process belongs to
|
|
216
|
-
* (cgroup v2 `memory.current`/`peak`/`max`/`stat`, falling back to cgroup v1). This is the figure
|
|
217
|
-
* the Kubernetes OOM-killer watches — it covers every process in the pod plus page cache and kernel
|
|
218
|
-
* memory, so it is higher than any single `process.memoryUsage().rss`. Also sums per-process RSS so
|
|
219
|
-
* the per-process split is visible. Explains itself when no cgroup memory controller is present
|
|
220
|
-
* (e.g. local dev outside a container).
|
|
221
|
-
*/
|
|
222
|
-
export function formatPodMemory(options: PodMemoryOptions = {}): string {
|
|
223
|
-
const classify = options.classify ?? defaultProcessClassifier;
|
|
224
|
-
const appLabel = options.appLabel ?? 'Application';
|
|
225
|
-
const lines: string[] = ['Pod memory snapshot:'];
|
|
226
|
-
|
|
227
|
-
const v2Current = path.join(CGROUP_ROOT, 'memory.current');
|
|
228
|
-
const v1Usage = path.join(CGROUP_ROOT, 'memory', 'memory.usage_in_bytes');
|
|
229
|
-
|
|
230
|
-
if (fs.existsSync(v2Current)) {
|
|
231
|
-
const current = readNumber(v2Current);
|
|
232
|
-
const peak = readNumber(path.join(CGROUP_ROOT, 'memory.peak'));
|
|
233
|
-
const max = readNumber(path.join(CGROUP_ROOT, 'memory.max'));
|
|
234
|
-
const stat = readKeyedBytes(path.join(CGROUP_ROOT, 'memory.stat'));
|
|
235
|
-
lines.push(' cgroup v2');
|
|
236
|
-
lines.push(` current ${current !== undefined ? Format.bytes(current) : 'n/a'}`);
|
|
237
|
-
lines.push(` peak ${peak !== undefined ? Format.bytes(peak) : 'n/a (kernel too old for memory.peak)'}`);
|
|
238
|
-
lines.push(` limit ${max === Number.POSITIVE_INFINITY ? 'unlimited' : max !== undefined ? Format.bytes(max) : 'n/a'}`);
|
|
239
|
-
if (Object.keys(stat).length > 0) {
|
|
240
|
-
lines.push(
|
|
241
|
-
` breakdown anon ${Format.bytes(stat.anon ?? 0)} (heaps/stacks), file ${Format.bytes(stat.file ?? 0)} (page cache), ` +
|
|
242
|
-
`kernel ${Format.bytes(stat.kernel ?? stat.slab ?? 0)}, sock ${Format.bytes(stat.sock ?? 0)}`
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
} else if (fs.existsSync(v1Usage)) {
|
|
246
|
-
const v1 = path.join(CGROUP_ROOT, 'memory');
|
|
247
|
-
const current = readNumber(v1Usage);
|
|
248
|
-
const peak = readNumber(path.join(v1, 'memory.max_usage_in_bytes'));
|
|
249
|
-
const limit = readNumber(path.join(v1, 'memory.limit_in_bytes'));
|
|
250
|
-
const stat = readKeyedBytes(path.join(v1, 'memory.stat'));
|
|
251
|
-
lines.push(' cgroup v1');
|
|
252
|
-
lines.push(` current ${current !== undefined ? Format.bytes(current) : 'n/a'}`);
|
|
253
|
-
lines.push(` peak ${peak !== undefined ? Format.bytes(peak) : 'n/a'}`);
|
|
254
|
-
// v1 reports a huge sentinel for "unlimited"; treat anything >= 2^60 as unlimited.
|
|
255
|
-
lines.push(` limit ${limit !== undefined && limit < 2 ** 60 ? Format.bytes(limit) : 'unlimited'}`);
|
|
256
|
-
if (Object.keys(stat).length > 0) {
|
|
257
|
-
lines.push(
|
|
258
|
-
` breakdown rss ${Format.bytes(stat.rss ?? 0)}, cache ${Format.bytes(stat.cache ?? 0)} (page cache), ` +
|
|
259
|
-
`kernel ${Format.bytes(stat.kernel ?? 0)}`
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
lines.push(' cgroup no memory controller under /sys/fs/cgroup (not running in a container?)');
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Root at this process so local dev reports only the app's tree, not the whole machine.
|
|
267
|
-
const { processes } = collectProcessRss(process.pid);
|
|
268
|
-
if (processes.length > 0) {
|
|
269
|
-
const classified = processes.map(proc => ({ ...proc, ...classify(proc.label) }));
|
|
270
|
-
const appProcs = classified.filter(proc => proc.isApp);
|
|
271
|
-
const otherProcs = classified.filter(proc => !proc.isApp);
|
|
272
|
-
const appTotal = appProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
273
|
-
|
|
274
|
-
lines.push('');
|
|
275
|
-
lines.push(` ${appLabel}: ${Format.bytes(appTotal)} across ${appProcs.length} process(es)`);
|
|
276
|
-
for (const proc of appProcs) {
|
|
277
|
-
lines.push(` ${Format.bytes(proc.rssBytes).padStart(10)} ${proc.role} (pid ${proc.pid})`);
|
|
278
|
-
}
|
|
279
|
-
const singletonCounts = new Map<string, number>();
|
|
280
|
-
for (const proc of appProcs) {
|
|
281
|
-
if (proc.singletonExpected) {
|
|
282
|
-
singletonCounts.set(proc.role, (singletonCounts.get(proc.role) ?? 0) + 1);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
for (const [role, count] of singletonCounts) {
|
|
286
|
-
if (count > 1) {
|
|
287
|
-
lines.push(` WARNING: ${count} instances of "${role}" running - likely ghost process(es); expected 1`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (otherProcs.length > 0) {
|
|
291
|
-
const otherTotal = otherProcs.reduce((sum, proc) => sum + proc.rssBytes, 0);
|
|
292
|
-
lines.push(` Other (tooling/debugger, not counted above): ${Format.bytes(otherTotal)} across ${otherProcs.length} process(es)`);
|
|
293
|
-
}
|
|
294
|
-
lines.push(' Note: in a real pod the cgroup figure above is the OOM ceiling; this per-process');
|
|
295
|
-
lines.push(' split is for attribution. Local dev may include debugger processes (excluded here).');
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return lines.join('\n');
|
|
299
|
-
}
|