@hydranium/core 1.0.0-next.270 → 1.0.0-next.271
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/lib/langium/document-builder/build-session.d.ts +6 -5
- package/lib/langium/document-builder/build-session.d.ts.map +1 -1
- package/lib/langium/document-builder/build-session.js +5 -5
- package/lib/langium/document-builder/build-session.js.map +1 -1
- package/lib/langium/document-builder/document-builder.d.ts +3 -2
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +10 -11
- package/lib/langium/document-builder/document-builder.js.map +1 -1
- package/lib/langium/integrity/integrity-service.js +2 -2
- package/lib/langium/integrity/integrity-service.js.map +1 -1
- package/lib/langium/workspace/self-save-registry.d.ts +6 -8
- package/lib/langium/workspace/self-save-registry.d.ts.map +1 -1
- package/lib/langium/workspace/self-save-registry.js +8 -10
- package/lib/langium/workspace/self-save-registry.js.map +1 -1
- package/lib/node/measure-memory.d.ts.map +1 -1
- package/lib/node/measure-memory.js +4 -4
- package/lib/node/measure-memory.js.map +1 -1
- package/lib/node/memory-monitor.d.ts.map +1 -1
- package/lib/node/memory-monitor.js +6 -5
- package/lib/node/memory-monitor.js.map +1 -1
- package/lib/node/profile-capture.d.ts +4 -2
- package/lib/node/profile-capture.d.ts.map +1 -1
- package/lib/node/profile-capture.js +7 -5
- package/lib/node/profile-capture.js.map +1 -1
- package/lib/node/server-state-snapshot.js +4 -4
- package/lib/node/server-state-snapshot.js.map +1 -1
- package/lib/testing/stub-writable-file-system.d.ts.map +1 -1
- package/lib/testing/stub-writable-file-system.js +2 -1
- package/lib/testing/stub-writable-file-system.js.map +1 -1
- package/package.json +5 -5
- package/src/langium/document-builder/build-session.ts +4 -3
- package/src/langium/document-builder/document-builder.ts +11 -11
- package/src/langium/integrity/integrity-service.ts +2 -2
- package/src/langium/workspace/self-save-registry.ts +10 -12
- package/src/node/measure-memory.ts +4 -4
- package/src/node/memory-monitor.ts +6 -5
- package/src/node/profile-capture.ts +7 -12
- package/src/node/server-state-snapshot.ts +5 -5
- package/src/testing/stub-writable-file-system.ts +2 -1
|
@@ -17,17 +17,10 @@
|
|
|
17
17
|
* `ProfileSession` (aggregate self-time spans).
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { Format, type ProfileCaptureOptions } from '@hydranium/protocol';
|
|
20
|
+
import { type Clock, Format, type ProfileCaptureOptions, type Stopwatch, SystemClock } from '@hydranium/protocol';
|
|
21
21
|
import * as fs from 'node:fs';
|
|
22
22
|
import { Session } from 'node:inspector';
|
|
23
|
-
import {
|
|
24
|
-
constants,
|
|
25
|
-
monitorEventLoopDelay,
|
|
26
|
-
PerformanceObserver,
|
|
27
|
-
performance,
|
|
28
|
-
type IntervalHistogram,
|
|
29
|
-
type PerformanceEntry
|
|
30
|
-
} from 'node:perf_hooks';
|
|
23
|
+
import { constants, monitorEventLoopDelay, PerformanceObserver, type IntervalHistogram, type PerformanceEntry } from 'node:perf_hooks';
|
|
31
24
|
import { snapshotFilePath, writeHeapSnapshotToDir } from '@hydranium/protocol/node';
|
|
32
25
|
|
|
33
26
|
export const DEFAULT_CPU_INTERVAL_MICROS = 1000;
|
|
@@ -181,7 +174,9 @@ let active: ProfileCapture | undefined;
|
|
|
181
174
|
* session at a time); prefer {@link profileWorkload} for the common wrap-a-block case.
|
|
182
175
|
*/
|
|
183
176
|
export class ProfileCapture {
|
|
184
|
-
|
|
177
|
+
/** Times the window: real time, since what it frames is real CPU and memory. */
|
|
178
|
+
protected readonly clock: Clock = new SystemClock();
|
|
179
|
+
protected sinceStart: Stopwatch = this.clock.stopwatch();
|
|
185
180
|
protected startCpu: NodeJS.CpuUsage = { user: 0, system: 0 };
|
|
186
181
|
protected startMem: NodeJS.MemoryUsage = process.memoryUsage();
|
|
187
182
|
protected session?: InspectorSessionLike;
|
|
@@ -214,7 +209,7 @@ export class ProfileCapture {
|
|
|
214
209
|
}
|
|
215
210
|
|
|
216
211
|
protected async begin(): Promise<void> {
|
|
217
|
-
this.
|
|
212
|
+
this.sinceStart = this.clock.stopwatch();
|
|
218
213
|
this.startCpu = process.cpuUsage();
|
|
219
214
|
this.startMem = process.memoryUsage();
|
|
220
215
|
if (this.options.cpu || this.options.allocation) {
|
|
@@ -254,7 +249,7 @@ export class ProfileCapture {
|
|
|
254
249
|
if (active !== this) {
|
|
255
250
|
throw new Error('ProfileCapture.stop called on an inactive capture.');
|
|
256
251
|
}
|
|
257
|
-
const durationMs =
|
|
252
|
+
const durationMs = this.sinceStart.elapsedMs;
|
|
258
253
|
// Sample cpu + memory at the workload boundary (alongside durationMs), NOT
|
|
259
254
|
// after teardown: the synchronous profile write inflates RSS and the heap
|
|
260
255
|
// snapshot forces a full GC, so a post-teardown read would fold the
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import { Format } from '@hydranium/protocol';
|
|
10
|
+
import { Format, type Stopwatch, SystemClock } from '@hydranium/protocol';
|
|
11
11
|
import { DocumentState, type LangiumDocuments } from '@hydranium/langium';
|
|
12
12
|
import { isCstShed } from '../langium/residency/cst-residency-service.js';
|
|
13
13
|
import { performance } from 'node:perf_hooks';
|
|
@@ -15,7 +15,7 @@ import * as v8 from 'node:v8';
|
|
|
15
15
|
|
|
16
16
|
/** Cumulative samples kept across calls so each snapshot can report deltas. */
|
|
17
17
|
interface DeltaState {
|
|
18
|
-
|
|
18
|
+
sinceSample: Stopwatch;
|
|
19
19
|
cpu: NodeJS.CpuUsage;
|
|
20
20
|
elu: { idle: number; active: number };
|
|
21
21
|
}
|
|
@@ -62,7 +62,7 @@ export interface ServerStateSnapshotOptions {
|
|
|
62
62
|
* requested via `options` ({@link ServerStateSnapshotOptions}).
|
|
63
63
|
*/
|
|
64
64
|
export function formatServerState(documents?: LangiumDocuments, label?: string, options?: ServerStateSnapshotOptions): string {
|
|
65
|
-
const
|
|
65
|
+
const sinceSample = new SystemClock().stopwatch();
|
|
66
66
|
const mem = process.memoryUsage();
|
|
67
67
|
const heap = v8.getHeapStatistics();
|
|
68
68
|
const cpu = process.cpuUsage();
|
|
@@ -87,7 +87,7 @@ export function formatServerState(documents?: LangiumDocuments, label?: string,
|
|
|
87
87
|
`native contexts ${heap.number_of_native_contexts}, detached contexts ${heap.number_of_detached_contexts}`
|
|
88
88
|
);
|
|
89
89
|
if (lastSample) {
|
|
90
|
-
const wallMs =
|
|
90
|
+
const wallMs = lastSample.sinceSample.elapsedMs;
|
|
91
91
|
const userMs = (cpu.user - lastSample.cpu.user) / 1000;
|
|
92
92
|
const systemMs = (cpu.system - lastSample.cpu.system) / 1000;
|
|
93
93
|
const cpuPct = wallMs > 0 ? Math.round(((userMs + systemMs) / wallMs) * 100) : 0;
|
|
@@ -138,7 +138,7 @@ export function formatServerState(documents?: LangiumDocuments, label?: string,
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
lastSample = {
|
|
141
|
+
lastSample = { sinceSample, cpu, elu };
|
|
142
142
|
return lines.join('\n');
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import type { URI } from '@hydranium/langium';
|
|
11
|
+
import { SystemClock } from '@hydranium/protocol';
|
|
11
12
|
import type { WritableFileSystemProvider } from '../langium/workspace/file-system-provider.js';
|
|
12
13
|
import type { StubSelfSaveRegistry } from './stub-self-save-registry.js';
|
|
13
14
|
|
|
@@ -49,7 +50,7 @@ export function makeStubWritableFileSystem(selfSaveRegistry?: StubSelfSaveRegist
|
|
|
49
50
|
readDirectory: async () => [],
|
|
50
51
|
async writeFile(uri: URI, content: string) {
|
|
51
52
|
writes.push({ uri: uri.toString(), content });
|
|
52
|
-
selfSaveRegistry?.register(uri.fsPath,
|
|
53
|
+
selfSaveRegistry?.register(uri.fsPath, new SystemClock().now());
|
|
53
54
|
},
|
|
54
55
|
reset() {
|
|
55
56
|
writes.length = 0;
|