MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolvePoolSize

Method resolvePoolSize

src/resolution/resolver-pool.ts:164–189  ·  view source on GitHub ↗

* Pool size from CPU headroom, memory headroom, and the explicit override. * Pure — every input injected — so the whole matrix is unit-testable. * * CPU term: `availableParallelism` (cpuset/affinity-honest — `os.cpus()` * enumerates the host's CPUs and sized SIX workers inside a 2-CPU cp

(opts: {
    explicit?: string;
    availableParallelism: number;
    memoryBudget: number;
    dbSizeBytes: number;
    /** The workers the work is worth; left out, as many as the machine can carry. */
    worth?: number;
  })

Source from the content-addressed store, hash-verified

162 * cost — callers get null and stay sequential.
163 */
164 static resolvePoolSize(opts: {
165 explicit?: string;
166 availableParallelism: number;
167 memoryBudget: number;
168 dbSizeBytes: number;
169 /** The workers the work is worth; left out, as many as the machine can carry. */
170 worth?: number;
171 }): number | null {
172 if (opts.explicit !== undefined && opts.explicit !== '') {
173 const n = Number.parseInt(opts.explicit, 10);
174 if (Number.isFinite(n)) {
175 if (n <= 0) return null;
176 return Math.min(n, 16);
177 }
178 }
179 // No floor: at ap=2 the pool LOSES to sequential outright — measured on
180 // the kernel-scale 2-cpuset envelope: resolution 853s sequential vs
181 // 1,150s pooled-6-on-2 (§7a.1), and synthesis is Amdahl-bound by its
182 // dominant pass (cFnPtrEdges 306s of 358s) so pooling it bought nothing.
183 // ap−1 < 2 ⇒ sequential is the fast path, not a fallback.
184 const cpuCap = Math.min(opts.availableParallelism - 1, MAX_RESOLVE_WORKERS);
185 const perWorker = Math.min(Math.max(opts.dbSizeBytes * 0.2, 256 * 1024 * 1024), 1.5 * 1024 * 1024 * 1024);
186 const memCap = Math.floor((opts.memoryBudget * 0.7) / perWorker);
187 const size = Math.min(cpuCap, memCap);
188 return size >= 2 ? Math.min(size, Math.max(2, opts.worth ?? size)) : null;
189 }
190
191 /**
192 * Create a pool when the compiled worker exists (absent when running from

Callers 2

tryCreateMethod · 0.80
sizeFunction · 0.80

Calls

no outgoing calls

Tested by 1

sizeFunction · 0.64