Wave-29 C00: dhat/allocator profiling smoke - #250
Conversation
Feature-gated dhat heap profiling complements the counting-allocator budget with SelfCheck script, ops docs, soft ops-load CI job, and hermetic wiring tests.
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an optional, feature-gated ChangesAllocator profiling smoke
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CI
participant allocProfileCheck
participant allocProfileDhat
participant processSession
participant dhatHeapStats
CI->>allocProfileCheck: run self-check
CI->>allocProfileCheck: run profiling test
allocProfileCheck->>allocProfileDhat: invoke feature-gated test
allocProfileDhat->>processSession: execute warm-up and measured passes
allocProfileDhat->>dhatHeapStats: read allocation metrics
dhatHeapStats-->>allocProfileDhat: return heap statistics
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request introduces an optional dhat heap-profiling smoke test for the process_session pipeline, including configuration files, documentation, a PowerShell runner script, and integration tests. The review feedback highlights a compilation error in tests/alloc_profile_dhat.rs due to a type mismatch between usize and u64 assertions, and suggests validating the JSON schema/profiler fields in the same file for consistency. Additionally, it recommends gracefully skipping the PowerShell self-check test in tests/alloc_profile.rs if pwsh is not available on the host system.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| assert!( | ||
| stats.max_bytes <= max_bytes_ceiling as usize, | ||
| "max_bytes {} exceeds ceiling {}", | ||
| stats.max_bytes, | ||
| max_bytes_ceiling | ||
| ); | ||
| assert!( | ||
| stats.total_blocks <= total_blocks_ceiling, | ||
| "total_blocks {} exceeds ceiling {}", | ||
| stats.total_blocks, | ||
| total_blocks_ceiling | ||
| ); |
There was a problem hiding this comment.
There is a compilation error due to a type mismatch in the assertions. stats.total_blocks is of type usize (as defined in dhat::HeapStats), whereas total_blocks_ceiling is of type u64 (returned by load_profile()). Rust does not allow direct comparison between usize and u64 without explicit casting.
Additionally, casting max_bytes_ceiling to usize via as usize can cause silent truncation on 32-bit targets if the ceiling value is larger than u32::MAX.
To fix both issues safely and losslessly, cast the usize values from stats to u64 before comparing them with the u64 ceilings.
| assert!( | |
| stats.max_bytes <= max_bytes_ceiling as usize, | |
| "max_bytes {} exceeds ceiling {}", | |
| stats.max_bytes, | |
| max_bytes_ceiling | |
| ); | |
| assert!( | |
| stats.total_blocks <= total_blocks_ceiling, | |
| "total_blocks {} exceeds ceiling {}", | |
| stats.total_blocks, | |
| total_blocks_ceiling | |
| ); | |
| assert!( | |
| stats.max_bytes as u64 <= max_bytes_ceiling, | |
| "max_bytes {} exceeds ceiling ", | |
| stats.max_bytes, | |
| max_bytes_ceiling | |
| ); | |
| assert!( | |
| stats.total_blocks as u64 <= total_blocks_ceiling, | |
| "total_blocks {} exceeds ceiling ", | |
| stats.total_blocks, | |
| total_blocks_ceiling | |
| ); |
|
|
||
| let max_bytes = value |
There was a problem hiding this comment.
For robustness and consistency with tests/alloc_profile.rs, we should validate the schema and profiler fields in the loaded JSON configuration file. This prevents loading a malformed or incorrect configuration file.
assert_eq!(
value.get("schema").and_then(serde_json::Value::as_str),
Some("sessionledger.alloc-profile.v1")
);
assert_eq!(
value.get("profiler").and_then(serde_json::Value::as_str),
Some("dhat")
);
let max_bytes = value| let output = Command::new("pwsh") | ||
| .args(["-NoProfile", "-File", script.to_str().expect("utf-8 script path"), "-SelfCheck"]) | ||
| .output() | ||
| .unwrap_or_else(|error| panic!("failed to spawn pwsh for self-check: {error}")); |
There was a problem hiding this comment.
The test currently spawns pwsh directly. If a developer runs cargo test on a system where PowerShell 7 (pwsh) is not installed (e.g., a standard Linux or macOS environment), this test will panic and fail.
To improve developer experience (DX) and robustness, we can dynamically check if pwsh is available on the host system, and if not, skip the test gracefully.
let pwsh_available = Command::new("pwsh")
.arg("-Version")
.output()
.is_ok();
if !pwsh_available {
eprintln!("pwsh is not available, skipping script self-check test.");
return;
}
let output = Command::new("pwsh")
.args(["-NoProfile", "-File", script.to_str().expect("utf-8 script path"), "-SelfCheck"])
.output()
.unwrap_or_else(|error| panic!("failed to spawn pwsh for self-check: {error}"));There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.env.example:
- Line 64: Update the documented full dhat measurement command in the profiling
configuration comment to include Cargo’s --locked flag, matching
scripts/alloc-profile-check.ps1 and preventing dependency resolution changes.
In @.github/workflows/ops-load.yml:
- Line 156: Update the actions/checkout step in the workflow job to set
persist-credentials to false, preventing repository-controlled PowerShell
scripts from accessing the persisted GitHub token. Keep the existing checkout
action and version unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 78f091cb-de6f-4f38-a420-c4182ab316ec
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (14)
.env.example.github/workflows/ops-load.yml.gitignoreCargo.tomldocs/ops/alloc-profile.jsondocs/ops/alloc-profile.mddocs/ops/allocation-budget.mddocs/ops/eval-manifest.jsondocs/ops/memory-budget.mddocs/ops/observability.mddocs/ops/runbook.mdscripts/alloc-profile-check.ps1tests/alloc_profile.rstests/alloc_profile_dhat.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (11)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: race smoke + channel/cancel model · windows-latest
- GitHub Check: cargo audit
- GitHub Check: reproducible build · sl-daemon
- GitHub Check: durable schema migration scaffold
- GitHub Check: fuzz smoke (10 seconds)
- GitHub Check: session-ledger build · windows-latest
- GitHub Check: sl-daemon build · windows-latest
- GitHub Check: sl-daemon · locked offline build
- GitHub Check: visual contract · WCAG AA
- GitHub Check: sl-daemon · pinned builder image offline build
🧰 Additional context used
📓 Path-based instructions (3)
**/*
📄 CodeRabbit inference engine (AGENTS.md)
**/*: Perform feature work in a git worktree under.claude/worktrees/, never directly onmain; use branches named<type>/<topic>where<type>isfeat,fix,chore,ci, ordocs.
Do not directly commit tomain; submit changes through a PR.
Do not usegit reset --hard,git stash, orgit cleanin worktrees.
Do not use--no-verifyor bypass hooks without operator approval.
Do not add AI attribution to commit or PR metadata.
Validate changes with the repository's required build, test, lint, and formatting commands:cargo build --all-targets --locked,cargo test --all-features --locked,cargo clippy --all-targets --all-features, andcargo fmt --all --check.
Files:
tests/alloc_profile_dhat.rsdocs/ops/runbook.mddocs/ops/eval-manifest.jsondocs/ops/alloc-profile.jsontests/alloc_profile.rsdocs/ops/memory-budget.mddocs/ops/allocation-budget.mddocs/ops/alloc-profile.mdCargo.tomldocs/ops/observability.mdscripts/alloc-profile-check.ps1
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
Fix Clippy warnings; do not use
#[allow]unless accompanied by a tracking-issue comment.
Files:
tests/alloc_profile_dhat.rstests/alloc_profile.rs
Cargo.toml
📄 CodeRabbit inference engine (AGENTS.md)
Maintain the workspace Rust version at
1.85.
Files:
Cargo.toml
🪛 LanguageTool
docs/ops/alloc-profile.md
[uncategorized] ~67-~67: The official name of this software platform is spelled with a capital “H”.
Context: ...* cargo test --test alloc_profile in
[.github/workflows/ci.yml](../../.github/workfl...
(GITHUB)
[uncategorized] ~70-~70: The official name of this software platform is spelled with a capital “H”.
Context: ...ault graph).
- Scheduled soft job: [
.github/workflows/ops-load.yml](../../.github/...
(GITHUB)
docs/ops/observability.md
[uncategorized] ~26-~26: The official name of this software platform is spelled with a capital “H”.
Context: ...* once the daemon binary is built. |
| [.github/workflows/ops-load.yml](../../.github/...
(GITHUB)
[style] ~26-~26: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ion-budget.md](allocation-budget.md)). Soft alloc-profile job runs [scripts/allo...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🪛 zizmor (1.26.1)
.github/workflows/ops-load.yml
[warning] 156-156: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[info] 157-157: action functionality is already included by the runner (superfluous-actions): use rustup and/or cargo in a script step
(superfluous-actions)
🔇 Additional comments (13)
docs/ops/runbook.md (1)
156-169: LGTM!docs/ops/allocation-budget.md (1)
9-10: LGTM!docs/ops/memory-budget.md (1)
9-10: LGTM!docs/ops/observability.md (1)
26-26: LGTM!.gitignore (1)
7-7: LGTM!docs/ops/eval-manifest.json (1)
34-34: 🗄️ Data Integrity & IntegrationNo action needed:
cargo_lock_sha256matchesCargo.lock.Cargo.toml (2)
23-24: LGTM!
48-54: LGTM!docs/ops/alloc-profile.json (1)
1-16: LGTM!docs/ops/alloc-profile.md (1)
1-86: LGTM!scripts/alloc-profile-check.ps1 (1)
1-130: LGTM!tests/alloc_profile.rs (1)
1-83: LGTM!tests/alloc_profile_dhat.rs (1)
1-88: LGTM!
| # SL_ENABLE_PPROF=1 | ||
|
|
||
| # Optional L8 allocator profiling smoke (local/ops only; not a daemon env var). | ||
| # Full dhat measurement: cargo test --test alloc_profile_dhat --features alloc-profile |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Keep the documented profiling command locked.
The direct invocation omits --locked, unlike scripts/alloc-profile-check.ps1. Add it so local runs cannot silently resolve or rewrite dependencies.
-# Full dhat measurement: cargo test --test alloc_profile_dhat --features alloc-profile
+# Full dhat measurement: cargo test --test alloc_profile_dhat --features alloc-profile --locked📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Full dhat measurement: cargo test --test alloc_profile_dhat --features alloc-profile | |
| # Full dhat measurement: cargo test --test alloc_profile_dhat --features alloc-profile --locked |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.env.example at line 64, Update the documented full dhat measurement command
in the profiling configuration comment to include Cargo’s --locked flag,
matching scripts/alloc-profile-check.ps1 and preventing dependency resolution
changes.
| timeout-minutes: 15 | ||
| continue-on-error: true | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Disable checkout credential persistence.
This new job inherits actions/checkout’s persisted GitHub token and then executes repository-controlled PowerShell scripts. Add persist-credentials: false to prevent those scripts from accessing the checkout credential.
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
+ with:
+ persist-credentials: false📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 | |
| with: | |
| persist-credentials: false |
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 156-156: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/ops-load.yml at line 156, Update the actions/checkout step
in the workflow job to set persist-credentials to false, preventing
repository-controlled PowerShell scripts from accessing the persisted GitHub
token. Keep the existing checkout action and version unchanged.
Source: Linters/SAST tools
Conservative +3 from crypto inventory (C02 L22), token-burn ledger (C08 L78), and expanded Cmd+K palette (C09 L81.14). Held signing readiness, conditional OCI blocking, and soft dhat alloc-profile.
Summary
alloc-profilefeature withdhatheap-profiling smoke overprocess_session()(8-message fixture).scripts/alloc-profile-check.ps1SelfCheck +docs/ops/alloc-profile.{json,md}operator contract.alloc-profilejob intoops-load.yml(continue-on-error: true); hermeticcargo test --test alloc_profileon default CI graphs.Test plan
pwsh ./scripts/alloc-profile-check.ps1 -SelfCheckcargo test --test alloc_profile --lockedcargo test --test alloc_profile_dhat --features alloc-profile --locked -- --nocaptureops-loadalloc-profilejob on mergeMade with Cursor