@agoric/telemetry 0.6.3-dev-7564f29.0 → 0.6.3-dev-aa4385b.0
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/package.json +2 -2
- package/src/flight-recorder.js +12 -9
- package/src/frcat-entrypoint.js +2 -2
- package/test/flight-recorder.test.js +10 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/telemetry",
|
|
3
|
-
"version": "0.6.3-dev-
|
|
3
|
+
"version": "0.6.3-dev-aa4385b.0+aa4385b",
|
|
4
4
|
"description": "Agoric's telemetry implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"typeCoverage": {
|
|
70
70
|
"atLeast": 88.83
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "aa4385bf3a8331460d3723a2a3279b0f44f0b708"
|
|
73
73
|
}
|
package/src/flight-recorder.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-env node */
|
|
3
3
|
/// <reference types="ses" />
|
|
4
4
|
|
|
5
|
-
import fs from 'node:fs';
|
|
6
5
|
import fsp from 'node:fs/promises';
|
|
7
6
|
import path from 'node:path';
|
|
8
7
|
import { Fail } from '@endo/errors';
|
|
@@ -80,7 +79,7 @@ const initializeCircularBuffer = async (bufferFile, circularBufferSize) => {
|
|
|
80
79
|
* @param {(record: Uint8Array, firstWriteLength: number, circEnd: bigint) => Promise<void>} writeRecord
|
|
81
80
|
*/
|
|
82
81
|
function makeCircBufMethods(arenaSize, header, readRecord, writeRecord) {
|
|
83
|
-
const readCircBuf = (outbuf, offset = 0) => {
|
|
82
|
+
const readCircBuf = async (outbuf, offset = 0) => {
|
|
84
83
|
offset + outbuf.byteLength <= arenaSize ||
|
|
85
84
|
Fail`Reading past end of circular buffer`;
|
|
86
85
|
|
|
@@ -102,7 +101,7 @@ function makeCircBufMethods(arenaSize, header, readRecord, writeRecord) {
|
|
|
102
101
|
// The data is contiguous, like ---AAABBB---
|
|
103
102
|
return { done: true, value: undefined };
|
|
104
103
|
}
|
|
105
|
-
readRecord(outbuf, readStart, firstReadLength);
|
|
104
|
+
await readRecord(outbuf, readStart, firstReadLength);
|
|
106
105
|
return { done: false, value: outbuf };
|
|
107
106
|
};
|
|
108
107
|
|
|
@@ -146,9 +145,10 @@ function makeCircBufMethods(arenaSize, header, readRecord, writeRecord) {
|
|
|
146
145
|
|
|
147
146
|
// Advance the start pointer until we have space to write the record.
|
|
148
147
|
let overlap = BigInt(record.byteLength) - capacity;
|
|
148
|
+
await null;
|
|
149
149
|
while (overlap > 0n) {
|
|
150
150
|
const startRecordLength = new Uint8Array(RECORD_HEADER_SIZE);
|
|
151
|
-
const { done } = readCircBuf(startRecordLength);
|
|
151
|
+
const { done } = await readCircBuf(startRecordLength);
|
|
152
152
|
if (done) {
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
@@ -224,20 +224,22 @@ export const makeSimpleCircularBuffer = async ({
|
|
|
224
224
|
arenaSize === hdrArenaSize ||
|
|
225
225
|
Fail`${filename} arena size mismatch; wanted ${arenaSize}, got ${hdrArenaSize}`;
|
|
226
226
|
|
|
227
|
-
/** @type {(outbuf: Uint8Array, readStart: number, firstReadLength: number) => void} */
|
|
228
|
-
const readRecord = (outbuf, readStart, firstReadLength) => {
|
|
229
|
-
const bytesRead =
|
|
227
|
+
/** @type {(outbuf: Uint8Array, readStart: number, firstReadLength: number) => Promise<void>} */
|
|
228
|
+
const readRecord = async (outbuf, readStart, firstReadLength) => {
|
|
229
|
+
const { bytesRead } = await file.read(outbuf, {
|
|
230
230
|
length: firstReadLength,
|
|
231
231
|
position: Number(readStart) + I_ARENA_START,
|
|
232
232
|
});
|
|
233
233
|
assert.equal(bytesRead, firstReadLength, 'Too few bytes read');
|
|
234
234
|
|
|
235
235
|
if (bytesRead < outbuf.byteLength) {
|
|
236
|
-
|
|
236
|
+
const length = outbuf.byteLength - firstReadLength;
|
|
237
|
+
const { bytesRead: bytesRead2 } = await file.read(outbuf, {
|
|
237
238
|
offset: firstReadLength,
|
|
238
|
-
length
|
|
239
|
+
length,
|
|
239
240
|
position: I_ARENA_START,
|
|
240
241
|
});
|
|
242
|
+
assert.equal(bytesRead2, length, 'Too few bytes read');
|
|
241
243
|
}
|
|
242
244
|
};
|
|
243
245
|
|
|
@@ -294,6 +296,7 @@ export const makeSlogSenderFromBuffer = ({ fileHandle, writeCircBuf }) => {
|
|
|
294
296
|
return Object.assign(writeJSON, {
|
|
295
297
|
forceFlush: async () => {
|
|
296
298
|
await toWrite;
|
|
299
|
+
await fileHandle.datasync();
|
|
297
300
|
},
|
|
298
301
|
shutdown: async () => {
|
|
299
302
|
const lastWritten = toWrite;
|
package/src/frcat-entrypoint.js
CHANGED
|
@@ -22,7 +22,7 @@ const main = async () => {
|
|
|
22
22
|
let offset = 0;
|
|
23
23
|
for (;;) {
|
|
24
24
|
const lenBuf = new Uint8Array(BigUint64Array.BYTES_PER_ELEMENT);
|
|
25
|
-
const { done } = readCircBuf(lenBuf, offset);
|
|
25
|
+
const { done } = await readCircBuf(lenBuf, offset);
|
|
26
26
|
if (done) {
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
@@ -30,7 +30,7 @@ const main = async () => {
|
|
|
30
30
|
const dv = new DataView(lenBuf.buffer);
|
|
31
31
|
const len = Number(dv.getBigUint64(0));
|
|
32
32
|
|
|
33
|
-
const { done: done2, value: buf } = readCircBuf(
|
|
33
|
+
const { done: done2, value: buf } = await readCircBuf(
|
|
34
34
|
new Uint8Array(len),
|
|
35
35
|
offset,
|
|
36
36
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
2
|
import tmp from 'tmp';
|
|
4
3
|
import { test } from './prepare-test-env-ava.js';
|
|
5
4
|
|
|
@@ -13,21 +12,16 @@ const bufferTests = test.macro(
|
|
|
13
12
|
/**
|
|
14
13
|
*
|
|
15
14
|
* @param {*} t
|
|
16
|
-
* @param {{makeBuffer:
|
|
15
|
+
* @param {{makeBuffer: typeof makeSimpleCircularBuffer}} input
|
|
17
16
|
*/
|
|
18
17
|
async (t, input) => {
|
|
19
18
|
const BUFFER_SIZE = 512;
|
|
20
19
|
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
fd,
|
|
24
|
-
removeCallback,
|
|
25
|
-
} = tmp.fileSync({ detachDescriptor: true });
|
|
26
|
-
t.teardown(removeCallback);
|
|
27
|
-
const fileHandle = /** @type {import('fs/promises').FileHandle} */ ({
|
|
28
|
-
close: promisify(fs.close.bind(fs, fd)),
|
|
20
|
+
const { name: tmpFile, removeCallback } = tmp.fileSync({
|
|
21
|
+
discardDescriptor: true,
|
|
29
22
|
});
|
|
30
|
-
|
|
23
|
+
t.teardown(removeCallback);
|
|
24
|
+
const { fileHandle, readCircBuf, writeCircBuf } = await input.makeBuffer({
|
|
31
25
|
circularBufferSize: BUFFER_SIZE,
|
|
32
26
|
circularBufferFilename: tmpFile,
|
|
33
27
|
});
|
|
@@ -55,11 +49,11 @@ const bufferTests = test.macro(
|
|
|
55
49
|
t.is(fs.readFileSync(tmpFile, { encoding: 'utf8' }).length, BUFFER_SIZE);
|
|
56
50
|
|
|
57
51
|
const len0 = new Uint8Array(BigUint64Array.BYTES_PER_ELEMENT);
|
|
58
|
-
const { done: done0 } = readCircBuf(len0);
|
|
52
|
+
const { done: done0 } = await readCircBuf(len0);
|
|
59
53
|
t.false(done0, 'readCircBuf should not be done');
|
|
60
54
|
const dv0 = new DataView(len0.buffer);
|
|
61
55
|
const buf0 = new Uint8Array(Number(dv0.getBigUint64(0)));
|
|
62
|
-
const { done: done0b } = readCircBuf(buf0, len0.byteLength);
|
|
56
|
+
const { done: done0b } = await readCircBuf(buf0, len0.byteLength);
|
|
63
57
|
t.false(done0b, 'readCircBuf should not be done');
|
|
64
58
|
const buf0Str = new TextDecoder().decode(buf0);
|
|
65
59
|
t.is(buf0Str, `\n{"type":"start"}`, `start compare failed`);
|
|
@@ -78,12 +72,12 @@ const bufferTests = test.macro(
|
|
|
78
72
|
let offset = 0;
|
|
79
73
|
const len1 = new Uint8Array(BigUint64Array.BYTES_PER_ELEMENT);
|
|
80
74
|
for (let i = 490; i < last; i += 1) {
|
|
81
|
-
const { done: done1 } = readCircBuf(len1, offset);
|
|
75
|
+
const { done: done1 } = await readCircBuf(len1, offset);
|
|
82
76
|
offset += len1.byteLength;
|
|
83
77
|
t.false(done1, `readCircBuf ${i} should not be done`);
|
|
84
78
|
const dv1 = new DataView(len1.buffer);
|
|
85
79
|
const buf1 = new Uint8Array(Number(dv1.getBigUint64(0)));
|
|
86
|
-
const { done: done1b } = readCircBuf(buf1, offset);
|
|
80
|
+
const { done: done1b } = await readCircBuf(buf1, offset);
|
|
87
81
|
offset += buf1.byteLength;
|
|
88
82
|
t.false(done1b, `readCircBuf ${i} should not be done`);
|
|
89
83
|
const buf1Str = new TextDecoder().decode(buf1);
|
|
@@ -94,7 +88,7 @@ const bufferTests = test.macro(
|
|
|
94
88
|
);
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
const { done: done2 } = readCircBuf(len1, offset);
|
|
91
|
+
const { done: done2 } = await readCircBuf(len1, offset);
|
|
98
92
|
t.assert(done2, `readCircBuf ${last} should be done`);
|
|
99
93
|
|
|
100
94
|
slogSender(null, 'PRE-SERIALIZED');
|