# Performance Implications of max-tools and max-git-procs Settings in Open Code Review

> Optimize Open Code Review performance by understanding max-tools and max-git-procs. Learn how these settings impact LLM analysis and Git operations for faster scans and reduced latency.

- Repository: [Alibaba/open-code-review](https://github.com/alibaba/open-code-review)
- Tags: performance
- Published: 2026-08-06

---

**Both flags control resource utilization and latency during repository scans, where `--max-tools` governs LLM analysis depth per file and `--max-git-procs` limits concurrent Git operations.**

The **Alibaba Open Code Review** (OCR) CLI exposes these two critical tuning parameters that directly impact scan duration, API costs, and system resource consumption. Understanding the performance implications of max-tools and max-git-procs settings allows teams to balance thorough code analysis against CI/CD pipeline speed.

## How max-tools Affects LLM Latency and Cost

The `--max-tools` flag sets the maximum number of **tool-call rounds per file**, with each round triggering a separate LLM (LLM-OCR) request.

Higher values initiate more LLM invocations, resulting in longer latency and higher API costs, but yielding deeper analysis with more context and suggestions. Conversely, lower values produce faster scans and reduced costs, though the review may terminate before reaching full analytical depth. Note that OCR enforces a **minimum of 10 rounds**, so values below this threshold have no effect.

## How max-git-procs Impacts Repository Discovery

The `--max-git-procs` parameter controls the maximum number of **concurrent Git subprocesses** used to obtain file diffs and list changed files.

Increasing this value spawns more parallel Git commands during the discovery phase, significantly speeding up preparation for large repositories. The trade-off includes increased CPU usage, higher file-descriptor consumption, and potential filesystem contention. Lower values reduce the CPU and memory footprint but can create bottlenecks when many files have changed.

## Calculating Total Scan Time

The overall scan time follows this approximate formula according to the Alibaba Open Code Review source code:

```

total time ≈ time to collect git information (affected by max‑git‑procs)
           + Σ per‑file LLM latency (affected by max‑tools)

```

Tuning these values requires balancing speed, resource usage, and review thoroughness. For most projects, the defaults work sufficiently; increase them only when optimizing for faster scans (raise `max-git-procs`) or deeper analysis (raise `max-tools`).

## Configuration Examples

You can configure these settings via the command line or programmatically through the OCR plugin.

### CLI Usage

Run a comprehensive review with deeper per-file analysis and increased Git concurrency:

```bash
ocr-review --max-tools 30 --max-git-procs 8

```

Execute a quick preview while limiting Git operations:

```bash
ocr-review --preview --max-git-procs 4

```

### Programmatic Usage

When using the TypeScript plugin, pass the values to the `ocr_review` tool:

```typescript
import { OpenCodeReviewPlugin } from "opencode";

const client = /* … */;
const worktree = /* … */;

await OpenCodeReviewPlugin({ client, worktree }).then(plugin => {
  const result = plugin.tool.ocr_review.execute(
    {
      // other args …
      maxTools: 25,          // deeper tool‑call budget per file
      maxGitProcesses: 6,   // more parallel git work
    },
    { worktree, directory: "/my/repo" }
  );
  console.log(await result);
});

```

## Source Implementation Details

According to the source code in `alibaba/open-code-review`, these flags are defined in the OCR plugin's argument schema. The `reviewArgs` object in [`plugins/open-code-review/opencode/open-code-review.ts`](https://github.com/alibaba/open-code-review/blob/main/plugins/open-code-review/opencode/open-code-review.ts) (lines 85-89) specifies the flag descriptions and constraints. The values are passed to the OCR binary via `pushValue` calls at lines 95-96, which inject user-provided values into the argument list passed to the OCR process.

## Summary

- **`--max-tools`** controls LLM invocation depth per file, directly impacting API costs and analysis thoroughness with a minimum threshold of 10 rounds.
- **`--max-git-procs`** limits parallel Git subprocesses for repository discovery, trading CPU and file-descriptor usage against preparation speed.
- Total scan time comprises Git collection time plus cumulative per-file LLM latency.
- Both settings are configurable via CLI flags or the TypeScript plugin's `maxTools` and `maxGitProcesses` parameters.

## Frequently Asked Questions

### What is the minimum value for max-tools?

OCR enforces a **minimum of 10 tool-call rounds** per file. Setting `--max-tools` below 10 has no effect, as the system automatically clamps to this floor to ensure minimal analysis depth.

### How does max-git-procs affect memory usage?

Higher values for `--max-git-procs` increase the number of concurrent Git subprocesses, which raises the **CPU and file-descriptor footprint** while reducing the time required to collect repository information. Lower values decrease resource consumption but may bottleneck the discovery phase in large repositories.

### Can I use these settings in preview mode?

Yes. The `--max-git-procs` setting functions independently of LLM calls, making it useful for `ocr-review --preview` to control resource usage during file discovery even when skipping AI analysis entirely.

### Where are these settings defined in the source code?

The flags are defined in the `reviewArgs` schema within [`plugins/open-code-review/opencode/open-code-review.ts`](https://github.com/alibaba/open-code-review/blob/main/plugins/open-code-review/opencode/open-code-review.ts) at lines 85-89, with values passed to the binary via `pushValue` calls at lines 95-96 according to the Alibaba Open Code Review implementation.