@torrent-tv/proxy 2.9.4 → 2.9.5

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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.9.5
2
+
3
+ - **Fix**: Segment files are now read with a 4 MB `highWaterMark` (`hls-session-manager.js` `getFileStream`) so the body is delivered in few, large chunks. On a busy ARM host the in-process WebTorrent hashing starves the Node event loop in bursts while the first segments are served; reading in fewer iterations cuts the time lost between chunks (the first segment previously transferred in ~79 × 43 KB reads spaced ~610 ms apart).
4
+
1
5
  ## 2.9.4
2
6
 
3
7
  - **Chore**: Temporary `[net-debug]` instrumentation in `data-channel-handler.js` now splits transfer timing into `fetchMs` (waiting for the local route, incl. ffmpeg segment finalization), `ttfbMs` (time to first body chunk), `sendMs` (channel send duration) and `chunks`, to locate where early-segment latency is spent (transport vs segment production).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.9.4",
3
+ "version": "2.9.5",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -33,6 +33,11 @@ const DEFAULT_SESSION_TTL_MS = 120 * 1000;
33
33
  const DEFAULT_STARTUP_WAIT_MS = 5_000;
34
34
  const MICROSECONDS_PER_SECOND = 1_000_000;
35
35
  const PROGRESS_LOG_INTERVAL_MS = 5_000;
36
+ // Read segment files in large blocks so the body is delivered to the data
37
+ // channel in few, big chunks. On a busy ARM host the in-process WebTorrent
38
+ // hashing starves the event loop in bursts, so fewer read iterations means
39
+ // far less time lost between chunks while serving the first segments.
40
+ const SEGMENT_READ_HIGH_WATER_MARK = 4 * 1024 * 1024;
36
41
 
37
42
  /**
38
43
  * Resolve after a given number of milliseconds.
@@ -899,9 +904,12 @@ export class HlsSessionManager {
899
904
  const filePath = path.join(session.dirPath, fileName);
900
905
  try {
901
906
  await access(filePath);
907
+ const isPlaylist = fileName === PLAYLIST_FILE_NAME;
902
908
  return {
903
909
  kind: "file",
904
- stream: createReadStream(filePath),
910
+ stream: isPlaylist
911
+ ? createReadStream(filePath)
912
+ : createReadStream(filePath, { highWaterMark: SEGMENT_READ_HIGH_WATER_MARK }),
905
913
  contentType:
906
914
  fileName === PLAYLIST_FILE_NAME
907
915
  ? "application/vnd.apple.mpegurl"