Overview
The GitHub Achievement CLI executes operations concurrently to improve performance while respecting rate limits. Concurrency control determines how many operations can run simultaneously.Default Concurrency
The CLI uses conservative defaults to ensure stability:With 2 concurrent operations, you can process achievements roughly twice as fast while staying well within GitHub’s rate limits.
How Concurrent Execution Works
The CLI uses a worker pool pattern to manage concurrent operations:Worker Pool Implementation
Fromsrc/utils/timing.ts:264-301:
How It Works
- Creates worker pool with N workers (N = concurrency level)
- Each worker pulls tasks from the queue and executes them
- Tasks complete independently - fast tasks don’t wait for slow ones
- Results are ordered by original index, regardless of completion order
- Progress updates fire after each task completes
The actual concurrency may be lower than the setting if there are fewer tasks than workers. For example, with 3 tasks and concurrency of 5, only 3 workers are created.
Achievement Execution Flow
Fromsrc/achievements/base.ts:119-182, here’s how concurrency integrates with rate limiting:
Execution Order
Configuration Options
Environment Variables
You can configure concurrency through your.env file:
BATCH_SIZE vs Concurrency
These are different concepts:| Setting | Purpose | Example |
|---|---|---|
| Concurrency | How many operations run simultaneously | 2 = two PRs being created at once |
| BATCH_SIZE | How many items to process before reporting progress | 5 = update UI every 5 operations |
BATCH_SIZE is primarily used for batch processing and progress reporting, not for controlling parallelism. Use the concurrency setting to control how many operations run at once..env.example:48-49:
Programmatic Configuration
If using the CLI as a library:Impact on Performance
Speed Comparison
| Concurrency | Operations/Min | Time for 48 Ops | Time for 128 Ops |
|---|---|---|---|
| 1 | ~15 | ~3.2 minutes | ~8.5 minutes |
| 2 (default) | ~30 | ~1.6 minutes | ~4.3 minutes |
| 3 | ~45 | ~1.1 minutes | ~2.9 minutes |
| 5 | ~75 | ~38 seconds | ~1.7 minutes |
Performance Factors
- Network latency - Higher latency benefits more from concurrency
- Operation complexity - Simple operations scale better
- GitHub API response time - Varies by load and region
- Rate limiting - Ultimately the bottleneck at high concurrency
Memory Usage
Each concurrent operation maintains:- HTTP connection to GitHub API
- Operation state in memory
- Progress tracking data
- Error handling context
When to Adjust Concurrency
Increase Concurrency When:
✅ You have a stable, fast internet connection ✅ You’re running small achievements (< 50 operations) ✅ You’re not encountering rate limit errors ✅ You want faster execution and can monitor for issues Recommended: Concurrency of 3-5Decrease Concurrency When:
⚠️ You’re seeing frequent rate limit errors (HTTP 429) ⚠️ You have an unstable internet connection ⚠️ Running very large achievements (500+ operations) ⚠️ GitHub API is responding slowly Recommended: Concurrency of 1Keep Default When:
👍 First time running the CLI 👍 Unsure about your network conditions 👍 Want the best balance of speed and stability Recommended: Concurrency of 2 (default)Error Handling with Concurrency
The CLI handles errors gracefully in concurrent execution:Failed operations don’t stop other operations. If operation #5 fails, operations #6, #7, etc. continue running. The CLI reports all errors at the end.
Best Practices
Recommended Settings by Use Case
Conservative (most stable)Monitoring Performance
The CLI logs concurrency information:- Frequent rate limit waits → Decrease concurrency
- Low active count → Network issues or GitHub API slow
- Errors → Check logs and reduce concurrency
Advanced: Rate Limiter Integration
Concurrency works hand-in-hand with rate limiting:- Concurrency limit: No more than N active operations
- Rate limit: No more than M operations per minute
See Also
- Rate Limiting - Understanding API rate limits
- Configuration - All environment variables
- Achievements Guide - What each achievement does