Skip to content

Commit 44306e3

Browse files
Document profiling tool in AGENTS.md
Add documentation for scripts/profile_cbmc.py and the profiling CI workflow to AGENTS.md: - profiling.yaml in the repository structure tree - profile_cbmc.py and profiling/ package in the scripts section - New 'Profiling CBMC' workflow section with usage examples, outputs, and CI integration notes - Profiling command in the Quick Reference Card Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
1 parent 2456e29 commit 44306e3

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ cbmc/
6969
│ │ ├── syntax-checks.yaml # Code style and linting
7070
│ │ ├── codeql-analysis.yml # Security analysis
7171
│ │ ├── performance.yaml # Performance benchmarking
72+
│ │ ├── profiling.yaml # Pre-solver profiling on PRs
7273
│ │ └── release-packages.yaml # Release automation
7374
│ └── dependabot.yml # Dependency update automation
7475
├── CODING_STANDARD.md # Coding conventions
@@ -214,6 +215,8 @@ Unit tests using the Catch framework:
214215

215216
- Build helpers and utilities
216217
- `cpplint.py` - Style checker
218+
- `profile_cbmc.py` - Performance profiling tool (see [Profiling CBMC](#6-profiling-cbmc))
219+
- `profiling/` - Profiling package (analysis, benchmarks, runner, utils)
217220
- `test.pl` - Regression test runner (in `regression/`)
218221
- CI/CD related scripts
219222

@@ -764,6 +767,46 @@ cd regression/cbmc
764767
make test
765768
```
766769

770+
### 6. Profiling CBMC
771+
772+
The profiling tool (`scripts/profile_cbmc.py`) profiles CBMC's pre-solver
773+
stages using `perf` and generates flamegraphs. Solver time is excluded by
774+
default so results reflect only CBMC's own code.
775+
776+
**Prerequisites:** Linux with `perf` installed.
777+
778+
```bash
779+
# Profile a single file
780+
scripts/profile_cbmc.py test.c -- --bounds-check --unwind 100
781+
782+
# Run 3 built-in benchmarks (linked_list, array_ops, structs)
783+
scripts/profile_cbmc.py --auto
784+
785+
# Extended suite (10 benchmarks) plus CSmith-generated tests
786+
scripts/profile_cbmc.py --auto-large --auto-csmith
787+
788+
# Multiple runs for statistical significance (reports mean ± stddev)
789+
scripts/profile_cbmc.py --auto --runs 3
790+
791+
# Source-level call site resolution (build a debug binary first)
792+
cmake -S . -Bbuild-debug -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_JBMC=OFF
793+
cmake --build build-debug --target cbmc -j$(nproc)
794+
scripts/profile_cbmc.py --auto --debug-binary build-debug/bin/cbmc
795+
796+
# Differential profiling: compare two git refs
797+
scripts/profile_cbmc.py --diff develop my-optimization-branch
798+
```
799+
800+
**Outputs** (in `profile-results/` by default):
801+
- `flamegraph.svg` per benchmark - Interactive flamegraph
802+
- `aggregated.svg` - Combined flamegraph across all benchmarks
803+
- `summary.txt` - Text summary with hotspot analysis and optimization suggestions
804+
- `results.json` - Machine-readable results
805+
806+
**CI integration:** The `profiling.yaml` workflow runs `--auto --runs 3` on
807+
every PR, posts the summary to the GitHub step summary, and uploads
808+
flamegraph SVGs as downloadable artifacts.
809+
767810
---
768811

769812
## Navigation Tips
@@ -894,6 +937,7 @@ To understand how data flows through CBMC:
894937
| Create GOTO binary | `goto-cc -o out.gb input.c` |
895938
| View GOTO program | `goto-instrument --show-goto-functions prog.gb` |
896939
| Run CBMC | `cbmc program.gb` or `cbmc program.c` |
940+
| Profile CBMC | `scripts/profile_cbmc.py --auto --runs 3` |
897941

898942
### Key Files to Know
899943

0 commit comments

Comments
 (0)