batch-cluster
    Preparing search index...

    Function findStreamFlushMillis

    • Find the minimum reliable streamFlushMillis value for the given child process on the current hardware.

      Returns the minimum streamFlushMillis value that produced zero noTaskData events across all confirmation trials. Because the confirmation phase already tests the worst case observed during discovery, the returned value is a near-ceiling, not a mean — similar in spirit to how TCP's RTO (RFC 6298) is SRTT + 4*RTTVAR rather than a flat multiplier. Callers needing additional headroom for transient load spikes should add a small additive constant (e.g. result + 5), since OS scheduling jitter is an additive phenomenon independent of the baseline value.

      Type Parameters

      • T

      Parameters

      Returns Promise<number>

      import { findStreamFlushMillis, Task } from "batch-cluster";

      const minReliable = await findStreamFlushMillis({
      processFactory: () => spawn("perl", [exiftoolPath, "-stay_open", "True", "-@", "-"]),
      versionCommand: "-ver\n-execute\n",
      pass: "{ready}",
      fail: "{ready}",
      exitCommand: "-stay_open\nFalse\n",
      taskFactory: (i) => {
      const cmds = ["-json\n/clean.jpg\n-execute\n", "-validate\n/warn.jpg\n-execute\n"];
      return new Task(cmds[i % cmds.length], (stdout) => stdout);
      },
      });
      const streamFlushMillis = minReliable + 5; // additive headroom for load spikes