Skip to content

Wave-29 C00: dhat/allocator profiling smoke - #250

Merged
KooshaPari merged 4 commits into
mainfrom
feat/sl-w29-c00-dhat
Jul 14, 2026
Merged

Wave-29 C00: dhat/allocator profiling smoke#250
KooshaPari merged 4 commits into
mainfrom
feat/sl-w29-c00-dhat

Conversation

@KooshaPari

Copy link
Copy Markdown
Owner

Summary

  • Add optional alloc-profile feature with dhat heap-profiling smoke over process_session() (8-message fixture).
  • Add scripts/alloc-profile-check.ps1 SelfCheck + docs/ops/alloc-profile.{json,md} operator contract.
  • Wire soft alloc-profile job into ops-load.yml (continue-on-error: true); hermetic cargo test --test alloc_profile on default CI graphs.

Test plan

  • pwsh ./scripts/alloc-profile-check.ps1 -SelfCheck
  • cargo test --test alloc_profile --locked
  • cargo test --test alloc_profile_dhat --features alloc-profile --locked -- --nocapture
  • Scheduled ops-load alloc-profile job on merge

Made with Cursor

Feature-gated dhat heap profiling complements the counting-allocator budget with SelfCheck script, ops docs, soft ops-load CI job, and hermetic wiring tests.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KooshaPari, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b4c3361e-0010-450c-9452-53e4872e8eb7

📥 Commits

Reviewing files that changed from the base of the PR and between 2195e06 and 4c4efde.

📒 Files selected for processing (1)
  • tests/alloc_profile_dhat.rs
📝 Walkthrough

Walkthrough

Adds an optional, feature-gated dhat allocator profiling smoke test for process_session, with JSON-configured ceilings, PowerShell validation, hermetic tests, scheduled CI execution, generated-artifact filtering, and operational documentation.

Changes

Allocator profiling smoke

Layer / File(s) Summary
Profiling contract and Cargo wiring
Cargo.toml, docs/ops/alloc-profile.json, docs/ops/alloc-profile.md
Defines the alloc-profile feature, optional dhat test target, profiling ceilings, workload metadata, execution steps, and measurement limitations.
Budget validation and test runner
scripts/alloc-profile-check.ps1, tests/alloc_profile.rs
Validates profiling configuration and ceiling overrides, supports self-check mode, and runs the hermetic and feature-gated profiling tests.
Dhat heap measurement
tests/alloc_profile_dhat.rs
Configures the dhat allocator, warms and profiles process_session, reads heap statistics, and enforces configured ceilings.
CI and operational integration
.github/workflows/ops-load.yml, .env.example, docs/ops/runbook.md, docs/ops/allocation-budget.md, docs/ops/memory-budget.md, docs/ops/observability.md, .gitignore, docs/ops/eval-manifest.json
Adds the scheduled soft smoke job, local usage guidance, related documentation references, dhat artifact exclusion, and the updated lockfile hash.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding dhat-based allocator profiling smoke tests.
Description check ✅ Passed The description is directly about the alloc-profile feature, docs, script, and CI wiring in this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sl-w29-c00-dhat
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/sl-w29-c00-dhat

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​dhat@​0.3.310010093100100

View full report

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +75 to +86
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
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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
);

Comment on lines +28 to +29

let max_bytes = value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment thread tests/alloc_profile.rs Outdated
Comment on lines +61 to +64
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}"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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}"));

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1fef9ff and 2195e06.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • .env.example
  • .github/workflows/ops-load.yml
  • .gitignore
  • Cargo.toml
  • docs/ops/alloc-profile.json
  • docs/ops/alloc-profile.md
  • docs/ops/allocation-budget.md
  • docs/ops/eval-manifest.json
  • docs/ops/memory-budget.md
  • docs/ops/observability.md
  • docs/ops/runbook.md
  • scripts/alloc-profile-check.ps1
  • tests/alloc_profile.rs
  • tests/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 on main; use branches named <type>/<topic> where <type> is feat, fix, chore, ci, or docs.
Do not directly commit to main; submit changes through a PR.
Do not use git reset --hard, git stash, or git clean in worktrees.
Do not use --no-verify or 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, and cargo fmt --all --check.

Files:

  • tests/alloc_profile_dhat.rs
  • docs/ops/runbook.md
  • docs/ops/eval-manifest.json
  • docs/ops/alloc-profile.json
  • tests/alloc_profile.rs
  • docs/ops/memory-budget.md
  • docs/ops/allocation-budget.md
  • docs/ops/alloc-profile.md
  • Cargo.toml
  • docs/ops/observability.md
  • scripts/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.rs
  • tests/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 & Integration

No action needed: cargo_lock_sha256 matches Cargo.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!

Comment thread .env.example
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.

Suggested change
- 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

@KooshaPari
KooshaPari merged commit a20a8d3 into main Jul 14, 2026
46 of 47 checks passed
KooshaPari added a commit that referenced this pull request Jul 14, 2026
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.
@KooshaPari
KooshaPari deleted the feat/sl-w29-c00-dhat branch August 12, 2026 08:58
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