Skip to content

Commit 46a0a7b

Browse files
yamadashyclaude
andcommitted
perf(core): Remove metrics worker cap to avoid regression on low-core machines
CI benchmarks showed macOS (3 vCPU) regressed by ~6-7% with the processConcurrency-1 cap, while Ubuntu/Windows (4 vCPU) improved. On 3 cores, capping metrics from 3→2 workers is a 33% parallelism reduction that outweighs contention savings. The main improvement comes from capping security at 2 workers, which is sufficient since the security pool uses coarse batches (50 files) and finishes quickly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aff7aa9 commit 46a0a7b

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

src/core/metrics/calculateMetrics.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import type { RepomixConfigMerged } from '../../config/configSchema.js';
2-
import {
3-
getProcessConcurrency,
4-
getWorkerThreadCount,
5-
initTaskRunner,
6-
type TaskRunner,
7-
} from '../../shared/processConcurrency.js';
2+
import { getWorkerThreadCount, initTaskRunner, type TaskRunner } from '../../shared/processConcurrency.js';
83
import type { RepomixProgressCallback } from '../../shared/types.js';
94
import type { ProcessedFile } from '../file/fileTypes.js';
105
import type { GitDiffResult } from '../git/gitDiffHandle.js';
@@ -39,18 +34,13 @@ export interface MetricsTaskRunnerWithWarmup {
3934
* output generation).
4035
*/
4136
export const createMetricsTaskRunner = (numOfTasks: number, encoding: TokenEncoding): MetricsTaskRunnerWithWarmup => {
42-
// Cap metrics workers at (processConcurrency - 1) to leave CPU headroom for the
43-
// security worker pool that runs concurrently during the pipeline overlap phase.
44-
const maxMetricsWorkers = Math.max(1, getProcessConcurrency() - 1);
45-
4637
const taskRunner = initTaskRunner<TokenCountTask, number>({
4738
numOfTasks,
4839
workerType: 'calculateMetrics',
4940
runtime: 'worker_threads',
50-
maxWorkerThreads: maxMetricsWorkers,
5141
});
5242

53-
const { maxThreads } = getWorkerThreadCount(numOfTasks, maxMetricsWorkers);
43+
const { maxThreads } = getWorkerThreadCount(numOfTasks);
5444
const warmupPromise = Promise.all(
5545
Array.from({ length: maxThreads }, () => taskRunner.run({ content: '', encoding }).catch(() => 0)),
5646
);

0 commit comments

Comments
 (0)