@songsid/agend 2.0.8-beta.3 → 2.0.8-beta.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.
@@ -3186,9 +3186,11 @@ When users create specialized instances, suggest these configurations:
3186
3186
  this.topicArchiver.stop();
3187
3187
  this.scheduler?.shutdown();
3188
3188
  // Stop instances in parallel batches to avoid long sequential waits.
3189
- // Concurrency limited to avoid overwhelming the tmux server.
3190
- const STOP_CONCURRENCY = 5;
3189
+ // Concurrency scales with fleet size larger fleets tolerate more parallel
3190
+ // tmux ops, while small fleets stay conservative to avoid overwhelming the
3191
+ // tmux server.
3191
3192
  const entries = [...this.daemons.entries()];
3193
+ const STOP_CONCURRENCY = entries.length > 30 ? 15 : entries.length >= 10 ? 10 : 5;
3192
3194
  for (const [name] of entries)
3193
3195
  this.ipcStoppingInstances.add(name);
3194
3196
  for (let i = 0; i < entries.length; i += STOP_CONCURRENCY) {
@@ -3203,9 +3205,9 @@ When users create specialized instances, suggest these configurations:
3203
3205
  this.daemons.delete(name);
3204
3206
  }));
3205
3207
  }
3206
- for (const [, ipc] of this.instanceIpcClients) {
3207
- await ipc.close();
3208
- }
3208
+ // Close IPC clients in parallel — serial close over a large fleet adds
3209
+ // noticeable latency.
3210
+ await Promise.all([...this.instanceIpcClients.values()].map(ipc => Promise.resolve(ipc.close()).catch(() => { })));
3209
3211
  this.instanceIpcClients.clear();
3210
3212
  this.ipcStoppingInstances.clear();
3211
3213
  for (const [, w] of this.worlds) {