Skip to content

Optimize inline parsing and rendering hot paths#177

Merged
abap34 merged 1 commit intocodex-test-fixtures-structurefrom
codex-benchmark-optimization
Apr 9, 2026
Merged

Optimize inline parsing and rendering hot paths#177
abap34 merged 1 commit intocodex-test-fixtures-structurefrom
codex-benchmark-optimization

Conversation

@abap34
Copy link
Copy Markdown
Owner

@abap34 abap34 commented Apr 9, 2026

Summary

  • replace regex-heavy inline parsing with string_view-based scanners
  • reduce AST traversal and template replacement overhead during render/summary
  • keep existing coverage green while cutting the main benchmark hot paths

Benchmark

Compared with codex-test-fixtures-structure using make bench BENCH_ARGS="--iterations 5 --json --output ...":

  • ✅ 99.5%% speed up: parse_inline_heavy_document (280.621 ms -> 1.463 ms)
  • ✅ 99.1%% speed up: parse_large_document (144.207 ms -> 1.335 ms)
  • ✅ 96.5%% speed up: render_large_document (163.139 ms -> 5.678 ms)
  • ✅ 88.5%% speed up: render_table_heavy_document (149.835 ms -> 17.299 ms)
  • ✅ 97.7%% speed up: summary_inline_heavy_document (298.085 ms -> 6.790 ms)
  • ✅ 83.3%% speed up: summary_large_document (36.147 ms -> 6.051 ms)

Validation

  • make test
  • make bench BENCH_ARGS='--iterations 5 --json --output /tmp/almo-opt-bench.json'

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

CI Summary

Check Status Details
Tests Success 16 passed / 0 failed
Benchmarks Success 21 benchmark(s) captured
Coverage Success 92.7% (1298 of 1400 lines)

Benchmark Means

Benchmark Mean (ms) Min (ms) Max (ms) Iterations
parse_small_document 0.260 0.250 0.286 5
parse_large_document 5.005 4.964 5.025 5
parse_realistic_article_document 0.361 0.351 0.381 5
parse_release_notes_document 0.319 0.315 0.328 5
parse_inline_heavy_document 5.787 5.762 5.838 5
parse_table_heavy_document 8.216 8.167 8.298 5
parse_footnote_heavy_document 7.195 7.111 7.272 5
parse_structured_document 18.465 18.328 18.748 5
parse_judge_document 0.028 0.027 0.029 5
render_small_document 0.611 0.592 0.623 5
render_large_document 11.374 11.253 11.574 5
render_realistic_article_document 0.553 0.513 0.644 5
render_release_notes_document 0.488 0.467 0.511 5
render_structured_document 22.699 22.590 22.803 5
render_table_heavy_document 27.711 27.618 27.880 5
render_footnote_heavy_document 10.178 10.086 10.329 5
render_interactive_document 0.330 0.315 0.347 5
render_judge_document 0.679 0.664 0.692 5
summary_inline_heavy_document 11.379 11.351 11.425 5
summary_realistic_article_document 0.533 0.518 0.551 5
summary_large_document 22.130 22.088 22.151 5

Benchmark Diff vs codex-test-fixtures-structure

Benchmark Base Mean (ms) PR Mean (ms) Delta (ms) Change
parse_small_document 9.712 0.260 -9.452 ✅ 97.3% speed up
parse_large_document 201.220 5.005 -196.215 ✅ 97.5% speed up
parse_realistic_article_document 22.948 0.361 -22.587 ✅ 98.4% speed up
parse_release_notes_document 7.435 0.319 -7.116 ✅ 95.7% speed up
parse_inline_heavy_document 370.992 5.787 -365.205 ✅ 98.4% speed up
parse_table_heavy_document 157.126 8.216 -148.910 ✅ 94.8% speed up
parse_footnote_heavy_document 57.471 7.195 -50.276 ✅ 87.5% speed up
parse_structured_document 48.713 18.465 -30.248 ✅ 62.1% speed up
parse_judge_document 0.028 0.028 +0.000 ➖ 0.0% change
render_small_document 18.749 0.611 -18.138 ✅ 96.7% speed up
render_large_document 227.820 11.374 -216.446 ✅ 95.0% speed up
render_realistic_article_document 35.104 0.553 -34.551 ✅ 98.4% speed up
render_release_notes_document 16.608 0.488 -16.120 ✅ 97.1% speed up
render_structured_document 67.179 22.699 -44.480 ✅ 66.2% speed up
render_table_heavy_document 217.441 27.711 -189.730 ✅ 87.3% speed up
render_footnote_heavy_document 72.725 10.178 -62.547 ✅ 86.0% speed up
render_interactive_document 12.898 0.330 -12.568 ✅ 97.4% speed up
render_judge_document 13.211 0.679 -12.532 ✅ 94.9% speed up
summary_inline_heavy_document 374.750 11.379 -363.371 ✅ 97.0% speed up
summary_realistic_article_document 31.850 0.533 -31.317 ✅ 98.3% speed up
summary_large_document 66.396 22.130 -44.266 ✅ 66.7% speed up

Benchmark dashboard: https://abap34.github.io/almo/dev/bench/?pr=177
PR preview: https://abap34.github.io/almo/dev/previews/pr-177/

@abap34 abap34 merged commit ab4ab4a into codex-test-fixtures-structure Apr 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant