Commit e28f0da
committed
🤖 feat: add hysteresis-based adaptive concurrency for terminal-bench
Implements adaptive concurrency control for terminal-bench using a
burst-and-resume pattern that automatically adjusts parallelism based on
system load average.
## Key Features
- **Hysteresis-based adjustment**: Double concurrency when load < threshold,
halve when load > threshold
- **Burst-and-resume pattern**: Runs terminal-bench in bursts, using native
resume capability to skip completed tasks between bursts
- **Clean container lifecycle**: No mid-task interruption, each burst
completes naturally before adjusting
- **Configurable parameters**: Max concurrency, load threshold, check interval
## Implementation
- `benchmarks/terminal_bench/adaptive_bench.py`: Main wrapper implementing
burst-and-resume logic with load monitoring
- `benchmarks/terminal_bench/adaptive_bench_test.py`: Unit tests for adaptive
logic
- `Makefile`: New `benchmark-terminal-adaptive` target
- Documentation updates in `benchmarks/terminal_bench/README.md`
## Usage
```bash
# Start with concurrency=1, scale up to 16 based on load
TB_MAX_CONCURRENT=16 make benchmark-terminal-adaptive
# Conservative: max 8, higher load threshold
TB_MAX_CONCURRENT=8 TB_LOAD_THRESHOLD=2.0 make benchmark-terminal-adaptive
# Sample 5 tasks with adaptive concurrency
TB_SAMPLE_SIZE=5 TB_MAX_CONCURRENT=8 make benchmark-terminal-adaptive
```
## How It Works
1. Start with concurrency=1
2. Run terminal-bench burst with current concurrency
3. After burst completes, check 1-minute load average
4. Adjust concurrency: double if load < threshold, halve if load > threshold
5. Update tb.lock with new concurrency
6. Resume run (skips completed tasks automatically)
7. Repeat until all tasks complete
## Tradeoffs
- ✅ Automatically finds optimal concurrency for hardware
- ✅ Prevents system overload
- ✅ Uses terminal-bench native features (resume, tb.lock)
- 1 parent 5438e2b commit e28f0da
File tree
4 files changed
+649
-1
lines changed- benchmarks/terminal_bench
4 files changed
+649
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
333 | 372 | | |
334 | 373 | | |
335 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
102 | 161 | | |
103 | 162 | | |
104 | 163 | | |
105 | 164 | | |
106 | 165 | | |
107 | 166 | | |
108 | 167 | | |
| 168 | + | |
| 169 | + | |
0 commit comments