@torrent-tv/proxy 2.64.8 → 2.64.9
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/CHANGELOG.md +1290 -1285
- package/bin/cli.js +533 -520
- package/package.json +1 -1
- package/services/memory-report.js +106 -1
- package/services/piece-store/shared-piece-store.js +47 -2
- package/services/torrent-worker/client.js +33 -0
- package/services/torrent-worker/worker.js +765 -750
- package/test/memory-budget.test.js +72 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
|
|
4
|
-
import { describeMemory, readingIsWorthWriting } from "../services/memory-report.js";
|
|
4
|
+
import { describeMemory, readingIsWorthWriting, summariseMappings } from "../services/memory-report.js";
|
|
5
5
|
import {
|
|
6
6
|
budgetForNewStore,
|
|
7
7
|
SharedPieceStore,
|
|
@@ -216,3 +216,74 @@ test("a reading is written when it moved, or when the silence has gone on long e
|
|
|
216
216
|
"no quiet interval means every reading is written, which is the process scope"
|
|
217
217
|
);
|
|
218
218
|
});
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The shape of the anonymous memory, not only its size. Three shapes, three
|
|
222
|
+
* different diagnoses of the same number — see `summariseMappings`.
|
|
223
|
+
*/
|
|
224
|
+
const SMAPS = [
|
|
225
|
+
"aaaad4000000-aaaad4c00000 r-xp 00000000 fe:01 1234 /usr/local/bin/node",
|
|
226
|
+
"Size: 12288 kB",
|
|
227
|
+
"Rss: 12000 kB",
|
|
228
|
+
"aaaae0000000-aaaae4000000 rw-p 00000000 00:00 0 [heap]",
|
|
229
|
+
"Size: 65536 kB",
|
|
230
|
+
"Rss: 40960 kB",
|
|
231
|
+
"ffff80000000-ffff80400000 rw-p 00000000 00:00 0 ",
|
|
232
|
+
"Size: 4096 kB",
|
|
233
|
+
"Rss: 4096 kB",
|
|
234
|
+
"ffff81000000-ffff81400000 rw-p 00000000 00:00 0 ",
|
|
235
|
+
"Size: 4096 kB",
|
|
236
|
+
"Rss: 4096 kB",
|
|
237
|
+
"ffff82000000-ffff82100000 rw-p 00000000 00:00 0 ",
|
|
238
|
+
"Size: 1024 kB",
|
|
239
|
+
"Rss: 512 kB",
|
|
240
|
+
"ffff83000000-ffff84000000 rw-p 00000000 00:00 0 ",
|
|
241
|
+
"Size: 16384 kB",
|
|
242
|
+
"Rss: 0 kB",
|
|
243
|
+
""
|
|
244
|
+
].join("\n");
|
|
245
|
+
|
|
246
|
+
test("the mappings are grouped by the shape that names the cause", () => {
|
|
247
|
+
const summary = summariseMappings(SMAPS);
|
|
248
|
+
assert.equal(summary.heapBytes, 40960 * 1024, "the allocator's break-managed arena stands alone");
|
|
249
|
+
assert.equal(summary.largeCount, 2, "two anonymous mappings of four megabytes");
|
|
250
|
+
assert.equal(summary.largeBytes, 8192 * 1024);
|
|
251
|
+
assert.equal(summary.largestBytes, 4096 * 1024);
|
|
252
|
+
assert.equal(summary.smallCount, 1);
|
|
253
|
+
assert.equal(summary.smallBytes, 512 * 1024);
|
|
254
|
+
assert.equal(summary.fileBytes, 12000 * 1024, "the executable is not a leak");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test("a mapping that is reserved but untouched costs nothing and is not counted", () => {
|
|
258
|
+
// The 16 MB mapping above has Rss 0: address space, not memory. Counting it
|
|
259
|
+
// would put tens of gigabytes of V8's reservations into the reading.
|
|
260
|
+
assert.equal(summariseMappings(SMAPS).largeCount, 2);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("no /proc, or nothing readable, is answered with zeroes rather than a throw", () => {
|
|
264
|
+
const empty = summariseMappings("");
|
|
265
|
+
assert.equal(empty.heapBytes, 0);
|
|
266
|
+
assert.equal(empty.largeCount, 0);
|
|
267
|
+
assert.deepEqual(summariseMappings(null), empty);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("the mapping shape is said in the line, and left out when it is not known", () => {
|
|
271
|
+
const withShape = describeMemory({
|
|
272
|
+
process: { rss: 900 * MEGABYTE, heapUsed: 27 * MEGABYTE, heapTotal: 30 * MEGABYTE, external: 6 * MEGABYTE, arrayBuffers: 2 * MEGABYTE },
|
|
273
|
+
availableBytes: 800 * MEGABYTE,
|
|
274
|
+
availableMeasured: true,
|
|
275
|
+
anonymousBytes: 870 * MEGABYTE,
|
|
276
|
+
mappings: summariseMappings(SMAPS),
|
|
277
|
+
stores: []
|
|
278
|
+
});
|
|
279
|
+
assert.match(withShape, /mappings=\[heap 40MB, 2 anon ≥2MB = 8MB \(largest 4MB\), 1 anon <2MB = 1MB, files 12MB\]/);
|
|
280
|
+
|
|
281
|
+
const withoutShape = describeMemory({
|
|
282
|
+
process: { rss: 900 * MEGABYTE, heapUsed: 27 * MEGABYTE, heapTotal: 30 * MEGABYTE, external: 6 * MEGABYTE, arrayBuffers: 2 * MEGABYTE },
|
|
283
|
+
availableBytes: 800 * MEGABYTE,
|
|
284
|
+
availableMeasured: true,
|
|
285
|
+
anonymousBytes: 870 * MEGABYTE,
|
|
286
|
+
stores: []
|
|
287
|
+
});
|
|
288
|
+
assert.ok(!withoutShape.includes("mappings="), "an unread breakdown is absent, not zeroed");
|
|
289
|
+
});
|