MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getYieldInterval

Method getYieldInterval

packages/db/src/buffers/base-buffer.ts:154–162  ·  view source on GitHub ↗

* Compute how often to yield in a CPU-bound loop over `batchSize` * items: target ~20 yields per flush, clamped to a per-buffer band. * * The band lets each buffer reflect per-item cost: * - cheap loops (regex, shallow checks): min=1000, max=5000 → coarse * - heavy loops (JSON.parse +

(
    batchSize: number,
    opts: { min?: number; max?: number; targetYieldsPerFlush?: number } = {}
  )

Source from the content-addressed store, hash-verified

152 * @param opts.targetYieldsPerFlush default 20
153 */
154 protected getYieldInterval(
155 batchSize: number,
156 opts: { min?: number; max?: number; targetYieldsPerFlush?: number } = {}
157 ): number {
158 const target = opts.targetYieldsPerFlush ?? 20;
159 const min = opts.min ?? 100;
160 const max = opts.max ?? 5000;
161 return Math.max(min, Math.min(max, Math.ceil(batchSize / target)));
162 }
163
164 /**
165 * Wrap an array of already-serialized JSONEachRow lines into an

Callers 2

processBufferMethod · 0.80
processBufferMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected