@rljson/fs-agent 0.0.58 → 0.0.59

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.
@@ -176,6 +176,20 @@ export declare const TREE_FETCH_CONCURRENCY = 64;
176
176
  * which is the cheap half of the trade.
177
177
  */
178
178
  export declare const RESTORED_BLOB_MEMORY_MAX = 50000;
179
+ /**
180
+ * How many tree children a restore works on at once.
181
+ *
182
+ * A restore's cost is dominated by `getBlob`, and a blob this node does not
183
+ * already hold is a socket round trip. Walking the tree strictly sequentially
184
+ * makes the whole restore `files × RTT` — invisible on localhost, and about
185
+ * sixteen files a second on the lab, where a 1 200-file folder then takes
186
+ * minutes and reads as a stalled node.
187
+ *
188
+ * Sixteen rather than sixty-four: blobs carry file CONTENT, so the ceiling is
189
+ * memory in flight rather than request count, and a folder of large files at
190
+ * high concurrency is how a client runs out of heap.
191
+ */
192
+ export declare const RESTORE_FETCH_CONCURRENCY = 16;
179
193
  /**
180
194
  * What an agent concluded about an inbound ref.
181
195
  *
package/dist/fs-agent.js CHANGED
@@ -1079,6 +1079,7 @@ const AGENT_STATE_FILE = ".fsagent-state.json";
1079
1079
  const REFUSAL_ANSWER_COOLDOWN_MS = 5e3;
1080
1080
  const TREE_FETCH_CONCURRENCY = 64;
1081
1081
  const RESTORED_BLOB_MEMORY_MAX = 5e4;
1082
+ const RESTORE_FETCH_CONCURRENCY = 16;
1082
1083
  const VERDICT_REASON = {
1083
1084
  "own-echo": "is this agent's own last advertisement echoed back",
1084
1085
  stale: "is not the newest its sender has advertised"
@@ -1637,9 +1638,26 @@ ${err.stack}` : String(err);
1637
1638
  const dirPath = meta.relativePath === "." ? targetPath : join(targetPath, meta.relativePath);
1638
1639
  await mkdir(dirPath, { recursive: true });
1639
1640
  if (treeNode.children && Array.isArray(treeNode.children)) {
1640
- for (const childHash of treeNode.children) {
1641
- await this._restoreTree(childHash, trees, targetPath, isOwnRoot);
1642
- }
1641
+ const children = [...treeNode.children];
1642
+ let next = 0;
1643
+ const worker = async () => {
1644
+ for (; ; ) {
1645
+ const index = next++;
1646
+ if (index >= children.length) return;
1647
+ await this._restoreTree(
1648
+ children[index],
1649
+ trees,
1650
+ targetPath,
1651
+ isOwnRoot
1652
+ );
1653
+ }
1654
+ };
1655
+ await Promise.all(
1656
+ Array.from(
1657
+ { length: Math.min(RESTORE_FETCH_CONCURRENCY, children.length) },
1658
+ worker
1659
+ )
1660
+ );
1643
1661
  }
1644
1662
  }
1645
1663
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/fs-agent",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "description": "Rljson fs-agent description",
5
5
  "homepage": "https://github.com/rljson/fs-agent",
6
6
  "bugs": "https://github.com/rljson/fs-agent/issues",