Skip to content

Commit 4cbc152

Browse files
yamadashyclaude
andcommitted
docs(metrics): Clarify batch size rationale with topFilesLength context
Explain that metrics may process only a small number of top files (topFilesLength * 10 = 50 by default) when tokenCountTree is disabled, which is why a smaller batch size of 10 is needed. Update security check comment to match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 479a086 commit 4cbc152

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/core/metrics/calculateSelectiveFileMetrics.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import type { FileMetrics } from './workers/types.js';
99
// Batch size for grouping files into worker tasks to reduce IPC overhead.
1010
// Each batch is sent as a single message to a worker thread, avoiding
1111
// per-file round-trip costs (~0.5ms each) that dominate when processing many files.
12-
// A size of 10 keeps individual worker tasks small so that workers become
13-
// available sooner, enabling overlap between file metrics and output token
14-
// counting. While smaller batches increase total IPC overhead, the cost is
15-
// distributed across available workers and offset by improved utilization.
12+
// A size of 10 keeps individual worker tasks small so that workers become available sooner,
13+
// enabling overlap between file metrics and output token counting.
14+
// When tokenCountTree is disabled, metrics only processes a small number of top files
15+
// (e.g., topFilesLength * 10 = 50 by default), so a smaller batch size avoids
16+
// a single batch monopolizing one worker.
1617
const METRICS_BATCH_SIZE = 10;
1718

1819
export const calculateSelectiveFileMetrics = async (

src/core/security/securityCheck.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export interface SuspiciousFileResult {
2323
// per-file round-trip costs that dominate when processing many files.
2424
// Security check always processes all files (~1000 in a typical repo), so a batch size of 50
2525
// already produces ~20 batches — enough to distribute well across available CPU cores.
26-
// (Unlike metrics, which may process only top N files and needs a smaller batch size of 10
27-
// to avoid a single batch monopolizing one worker.)
26+
// (Unlike metrics, which may process only a small number of top files when tokenCountTree
27+
// is disabled, and needs a smaller batch size to avoid one batch monopolizing a worker.)
2828
const BATCH_SIZE = 50;
2929

3030
export const runSecurityCheck = async (

0 commit comments

Comments
 (0)