@torrent-tv/proxy 2.9.89 → 2.9.91
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.
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { findSharedStore } from "../piece-store/shared-piece-store.js";
|
|
24
|
+
import { logger } from "../../utils/logger.js";
|
|
25
|
+
|
|
26
|
+
/** Only waits at least this long are reported; sequential reading stays silent. */
|
|
27
|
+
const PIECE_WAIT_LOG_MS = 1_000;
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* How far ahead of the read head pieces are asked for.
|
|
@@ -318,7 +322,21 @@ export async function* readFragments({
|
|
|
318
322
|
criticalMark = markCritical(torrent, pieceIndex, Math.min(lastPiece, pieceIndex + criticalRun), criticalMark);
|
|
319
323
|
}
|
|
320
324
|
|
|
325
|
+
const waitStartedAt = Date.now();
|
|
321
326
|
await whenPieceReady(torrent, pieceIndex, cancellation);
|
|
327
|
+
// What a reader spent waiting for data, attributed to the exact piece. A
|
|
328
|
+
// seek's cost is dominated by the first segment after the encoder
|
|
329
|
+
// restarts (measured 9.2-9.4 s), and without this there is no way to say
|
|
330
|
+
// whether that is the swarm, the picker, or ffmpeg. Logged only when the
|
|
331
|
+
// wait is long enough to matter, so ordinary sequential reading is silent.
|
|
332
|
+
const waitedMs = Date.now() - waitStartedAt;
|
|
333
|
+
if (waitedMs >= PIECE_WAIT_LOG_MS) {
|
|
334
|
+
logger.info(
|
|
335
|
+
`piece-reader: waited ${waitedMs}ms for piece ${pieceIndex} ` +
|
|
336
|
+
`(${pieceIndex - firstPiece + 1} of ${lastPiece - firstPiece + 1} in a read from ` +
|
|
337
|
+
`${(start / 1024 / 1024).toFixed(0)}MB of "${file.name}")`
|
|
338
|
+
);
|
|
339
|
+
}
|
|
322
340
|
|
|
323
341
|
// Pinned BEFORE it is located, and before any await that could let an
|
|
324
342
|
// eviction run: the offset is only meaningful while the piece is held.
|