magi-code 0.63.4

Repository-aware CLI coding agent for terminal work
Documentation
# CPU Benchmark History

Purpose: track CPU profiling runs over time for issue #48 follow-up and regression checks. Canonical workflow lives in [`docs/features/cpu-hotspot-profiling.md`](cpu-hotspot-profiling.md).

## Regenerate

```sh
python3 scripts/profile_cpu.py --repo . --all --min-seconds 3
```

Artifacts written by default:

```text
target/profiling/issue-48/profile-results.json
target/profiling/issue-48/profile-summary.md
target/profiling/issue-48/<scenario>.log
```

Default run is offline and credential-free: temp `MC_HOME`, synthetic fixtures, no `auth.json`, and credential-looking env stripped from child processes.

## Run sources

| run | generated at | commit | source | notes |
| --- | --- | --- | --- | --- |
| Issue #48 baseline | 2026-05-31T07:32:23Z | unknown | `docs/features/cpu-hotspot-profiling.md` | First captured machine baseline. |
| Pre-optimization regression | 2026-06-10T04:45:47Z | `3bc35b10` | handoff values; prior `target/profiling/issue-48/profile-results.json` overwritten by latest run | Regression snapshot before CPU work. |
| Current post-optimization | 2026-06-10T05:14:58.035329+00:00 | `3bc35b10d0f0c93d56609f71ce11192df4f84e43` | `target/profiling/issue-48/profile-results.json`; `target/profiling/issue-48/profile-summary.md` | Latest local artifact in this checkout. |

Platform for all rows: Darwin 25.5.0 arm64, Rust release profile. Current artifact uses `rustc 1.95.0 (59807616e 2026-04-14)`.

## Scenario history

Higher `iterations/sec` means better throughput for same scenario. Compare runs from same machine/profile only.

| scenario | run | elapsed ms | iterations | iterations/sec | primary metric | metric value |
| --- | --- | ---: | ---: | ---: | --- | ---: |
| startup_discovery | Issue #48 baseline | 3000 | 4401 | 1467.0 | discovered_items | 563618466 |
| startup_discovery | Pre-optimization regression | 3021 | 1663 | 550.5 | discovered_items | 212973758 |
| startup_discovery | Current post-optimization | 3000 | 2643 | 881.0 | discovered_items | 338478438 |
| provider_sse_parser | Issue #48 baseline | 3000 | 102104 | 34034.7 | events_parsed | 1735768 |
| provider_sse_parser | Pre-optimization regression | 3012 | 4253 | 1412.0 | events_parsed | 72301 |
| provider_sse_parser | Current post-optimization | 3000 | 69873 | 23291.0 | events_parsed | 1187841 |
| rendering_heavy_transcript | Issue #48 baseline | 3001 | 263 | 87.6 | rendered_units | 956268 |
| rendering_heavy_transcript | Pre-optimization regression | 3334 | 25 | 7.5 | rendered_units | 103900 |
| rendering_heavy_transcript | Current post-optimization | 3001 | 156 | 52.0 | rendered_units | 648336 |
| tui_streaming_simulation | Issue #48 baseline | 3000 | 1059 | 353.0 | state_units | 277458 |
| tui_streaming_simulation | Pre-optimization regression | 3013 | 153 | 50.8 | state_units | 41616 |
| tui_streaming_simulation | Current post-optimization | 3001 | 728 | 242.6 | state_units | 198016 |
| tool_timeout_cleanup | Issue #48 baseline | 3020 | 127 | 42.1 | cleanup_units | 254 |
| tool_timeout_cleanup | Pre-optimization regression | 3024 | 90 | 29.8 | cleanup_units | 161 |
| tool_timeout_cleanup | Current post-optimization | 3011 | 138 | 45.8 | cleanup_units | 276 |

## Current deltas

Deltas use `iterations/sec` because scenario metric units differ.

| scenario | current vs pre-optimization | current vs Issue #48 baseline |
| --- | ---: | ---: |
| startup_discovery | +60% | -40% |
| provider_sse_parser | +1549% | -32% |
| rendering_heavy_transcript | +593% | -41% |
| tui_streaming_simulation | +378% | -31% |
| tool_timeout_cleanup | +54% | +9% |

## Render pipeline history

`tui_render_pipeline` rows compare scripted Mission Control frame throughput only. Compare same machine, Rust profile, terminal area, backend mode, and scenario mix. Use `target/profiling/issue-48/tui-render-pipeline.json` for per-scenario `render_draw_ms`, `diff_ms`, `diff_cells`, `stdout_bytes`, `terminal_draw_ms`, `controlled_draw_ms`, and `frames_per_sec`; do not treat process flush time as terminal emulator paint time.

### Full 5-second TestBackend baseline

Source: reported full render-pipeline harness run via `python3 scripts/profile_cpu.py --repo . --scenario tui_render_pipeline --min-seconds 5`. Backend mode: `test` (`Ratatui TestBackend`). Run size: 855 iterations, 8170 frames.

| Scenario | FPS | Render ms (p50) | Diff ms (p50) | Diff Cells (p50) | Total Draw ms (p50) |
| --- | ---: | ---: | ---: | ---: | ---: |
| idle | 4422 | 0.047 | 0.049 | 0 | 0.099 |
| streaming | 2397 | 0.128 | 0.052 | 170 | 0.180 |
| heavy_transcript | 1210 | 0.302 | 0.051 | 0 | 0.356 |
| scroll | 1269 | 0.293 | 0.054 | 882 | 0.354 |
| modal_open | 1167 | 0.319 | 0.052 | 0 (first frame 1532) | 0.375 |
| resize 160x50 | 1669 | 0.426 | 0.111 | 7995 | 0.599 |

Key findings:

- Render CPU dominates every scenario: `render_draw_ms` accounts for roughly 71-82% of p50 frame time.
- Ratatui diff is not the bottleneck: p50 diff stays at 0.049-0.111 ms, including resize with 7995 changed cells.
- Heaviest steady scenario, `heavy_transcript`, still reaches 1210 FPS on `TestBackend`.
- Terminal I/O is unmeasured in this baseline: `TestBackend` records 0 for `stdout_bytes`, `write_ms`, and `flush_ms`.
- Real-world ceiling depends on terminal emulator write/flush/paint behavior, not process-side render alone. Manual real-TTY validation remains a follow-up.

| scenario | run | backend | frames | frames/sec | p50 render ms | p50 diff ms | p50 diff cells | p50 total draw ms | stdout bytes |
| --- | --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| tui_render_pipeline | First implementation run | test | 106 | 1752.7 | 0.236 avg | unknown | 122.8 avg | unknown | 0 |
| idle | Full 5-second baseline | test | included in 8170 | 4422 | 0.047 | 0.049 | 0 | 0.099 | 0 |
| streaming | Full 5-second baseline | test | included in 8170 | 2397 | 0.128 | 0.052 | 170 | 0.180 | 0 |
| heavy_transcript | Full 5-second baseline | test | included in 8170 | 1210 | 0.302 | 0.051 | 0 | 0.356 | 0 |
| scroll | Full 5-second baseline | test | included in 8170 | 1269 | 0.293 | 0.054 | 882 | 0.354 | 0 |
| modal_open | Full 5-second baseline | test | included in 8170 | 1167 | 0.319 | 0.052 | 0; first frame 1532 | 0.375 | 0 |
| resize 160x50 | Full 5-second baseline | test | included in 8170 | 1669 | 0.426 | 0.111 | 7995 | 0.599 | 0 |

## Update rules

1. Run command above on same machine/profile when possible.
2. Copy `generated_at`, commit, platform, Rust version, and per-scenario rows from `profile-results.json`.
3. Add new rows; do not overwrite historical rows.
4. Record missing fields as `unknown`, never inferred.
5. Treat >5% throughput drop against previous comparable run as investigation trigger.