โ๏ธ Concurrency and Performance
All Early AI agents support configurable concurrency through the MAX_CONCURRENCY parameter.
This setting determines how many AI-powered test generation tasks run in parallel during execution.
Adjusting concurrency allows you to balance between speed, resource usage, and cost.
๐ What MAX_CONCURRENCY Controlsโ
The MAX_CONCURRENCY option defines the number of concurrent test generation workers that run at the same time.
Each worker processes a separate function or file in your repository.
- Increasing concurrency speeds up generation but increases memory and CPU usage.
- Lowering concurrency makes the process slower but more stable on limited runners.
Example usage:
export MAX_CONCURRENCY=4
early generate-commit
Or using a flag:
early generate-folder --max-concurrency 2
๐งฉ Recommended Valuesโ
| CI/CD System | Recommended MAX_CONCURRENCY | Notes |
|---|---|---|
| GitHub Actions | 2โ4 | Default is 4. Reduce to 2 if memory usage exceeds 5 GB. |
| Jenkins | 2โ4 | Depends on agent resources. Use 2 for shared runners. |
| CircleCI | 2โ3 | Recommended for medium CPU containers. |
| Local runs | 1โ4 | Use 1 for debugging or limited laptops. |
โ ๏ธ Increasing concurrency beyond 4 provides diminishing returns and can lead to OOM (Out of Memory) errors.
๐ง How It Interacts with Memory and CPUโ
- Each worker uses its own AI model session and memory buffer.
- With higher concurrency, memory and CPU consumption increase roughly linearly.
- For example:
MAX_CONCURRENCY=1โ ~1.2 GB RAM usageMAX_CONCURRENCY=4โ ~4โ5 GB RAM usage
If your runner crashes with:
FATAL ERROR: Ineffective mark-compacts near heap limit
Allocation failed - JavaScript heap out of memory
Increase Node.js memory allocation using:
export NODE_OPTIONS="--max-old-space-size=5120"
More info: Memory Tuning โ
๐งช Example Configurationsโ
GitHub Actionsโ
env:
MAX_CONCURRENCY: 3
NODE_OPTIONS: --max-old-space-size=5120
Jenkinsโ
environment {
MAX_CONCURRENCY = 2
NODE_OPTIONS = '--max-old-space-size=5120'
}
Both environments will safely limit concurrency and memory usage to prevent pipeline instability.
๐ฐ Rate Limiting and Cost Optimizationโ
- Each concurrent task consumes model tokens (input + output).
- Higher concurrency can increase cost if your plan has usage-based billing.
- If you run frequent builds (e.g., hourly or nightly), consider lowering
MAX_CONCURRENCYto 2โ3 for efficiency. - To reduce compute time without increasing concurrency:
- Exclude large, non-critical folders
- Use incremental runs (only changed code)
- Schedule Repo CLI runs during off-hours