Skip to main content

โš™๏ธ 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

CI/CD SystemRecommended MAX_CONCURRENCYNotes
GitHub Actions2โ€“4Default is 4. Reduce to 2 if memory usage exceeds 5 GB.
Jenkins2โ€“4Depends on agent resources. Use 2 for shared runners.
CircleCI2โ€“3Recommended for medium CPU containers.
Local runs1โ€“4Use 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 usage
    • MAX_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_CONCURRENCY to 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