Skip to content

Record tee hot-path profiling baseline (#127) - #171

Merged
leynos merged 10 commits into
mainfrom
profiling-investigation
Jun 14, 2026
Merged

Record tee hot-path profiling baseline (#127)#171
leynos merged 10 commits into
mainfrom
profiling-investigation

Conversation

@lodyai

@lodyai lodyai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch records the first full run of the tee hot-path profiling
harness as the ADR-002 Phase 1 baseline evidence. It adds a findings
document with measured hotspot verdicts for the seven-scenario matrix,
run on commit a50a631 with perf (DWARF call graphs, 999 Hz) and
py-spy corroboration against the deterministic seed-12345 fixtures
(1.5 GiB raw). No production code changes are included.

Relates to #127: the evidence supports wiring capture-only consume
dispatch through rust_consume_stream (ADR-002 Phase 2), the work that
PR #164 annotates as deferred pending exactly this measurement. The
issue remains open; this branch supplies the evidence gate only.

Key verdicts:

  • capture double-touch (bytearray.extend plus final buffer.decode)
    is ~51% of parent CPU in tee mode — comfortably above the ADR-002
    20% acceptance threshold for Phase 2;
  • per-line observe-hook dispatch dominates the line-callback path
    (~46× slowdown), driven by per-line ExecEvent construction,
    inspect.isawaitable, and argv_with_program recomputation, not by
    line splitting or incremental decode;
  • raising _READ_SIZE from 4 KiB to 16–64 KiB is a cheap ~20% win;
  • the Rust splice pump reduces multi-stage pumping cost from ~36 s
    to ~1 s;
  • the per-chunk flush and text-sink decode hypotheses are refuted.

Two incidental findings are recorded for follow-up issues: a silent
FD-close race on the Rust pump path (OSError: [Errno 9] during
transport shutdown, exit code still 0) and a distro perf script
quirk that drops Python JIT frames from the folded stacks while
perf report resolves them.

Review walkthrough

Validation

  • make markdownlint nixie: 0 errors, all diagrams validated
  • make check-fmt: clean
  • make fmt: applied (mdformat reflowed the new document)
  • Profiling artefacts regenerable via the reproduction commands in the
    document; raw artefacts live under the gitignored dist/profiles/

Notes

The harness itself (merged in #52) needed no changes. The read-size
sweep monkeypatched cuprum._streams._READ_SIZE in a throwaway driver
rather than altering the harness; the document marks that as a
candidate ADR-002 Proposal 3 change.

Summary by Sourcery

Document tee hot-path profiling baseline measurements as ADR-002 Phase 1 evidence without changing production code.

Documentation:

  • Add a detailed tee hot-path profiling baseline document capturing environment, scenarios, hypothesis verdicts, incidental findings, and ADR-002 implications.
  • Extend the documentation index to reference the new tee hot-path profiling baseline document.

Run the full seven-scenario tee profiling matrix on commit `a50a631`
(perf with DWARF call graphs, plus py-spy corroboration) against the
seed-12345 1.5 GiB deterministic fixtures, and record the hotspot
verdicts as the ADR-002 Phase 1 baseline evidence.

Key verdicts:

- capture double-touch (`bytearray.extend` plus the final
  `buffer.decode`) is ~51% of parent CPU in tee mode, supporting
  Phase 2 capture-only dispatch through `rust_consume_stream`;
- per-line observe-hook dispatch dominates the line-callback path
  (~46x slowdown), driven by per-line `ExecEvent` construction,
  `inspect.isawaitable`, and `argv_with_program` recomputation — not
  by line splitting or incremental decode;
- raising `_READ_SIZE` from 4 KiB to 16-64 KiB is a cheap ~20% win;
- the Rust splice pump reduces multi-stage pumping cost from ~36 s to
  ~1 s, and the per-chunk flush and text-sink decode hypotheses are
  refuted.

Also note two incidental findings: an FD-close race on the Rust pump
path (`OSError: [Errno 9]` during transport shutdown) and a distro
`perf script` quirk that drops Python JIT frames from the folded
stacks while `perf report` resolves them.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Add documentation for the tee hot-path profiling baseline and a profiling-prerequisites subsection. Add an index entry linking to the new baseline document that records environment and fixture metadata, throughput metrics, six quantified hypothesis verdicts, incidental findings, ADR-002 phasing implications, and reproduction commands. Separately, update Kani testing guidance to compute toolchain paths dynamically.

Changes

Profiling Baseline Documentation

Layer / File(s) Summary
Profiling baseline index and entry
docs/contents.md
Add an index bullet in "Design and decisions" pointing to the new profiling baseline document, and insert the corresponding reference link definition mapping to the baseline file.
Profiling baseline document
docs/tee-hotpath-profiling-baseline-2026-06-12.md
Record profiling environment and fixture hashes, scenario wall-time and throughput metrics for echo/tee and callback variants, six hypothesis verdicts backed by perf leaf/call-tree evidence and py-spy drill-downs, incidental findings regarding Rust FD close races and Python JIT trampoline frames, ADR-002 phasing implications, and step-by-step reproduction commands.
Profiling prerequisites subsection
docs/developers-guide.md
Insert a subsection listing Linux-focused build and runtime settings required for symbol-quality perf call graphs, including native extension frame pointers, CPython perf map support, perf record sampling configuration, tool installation, reference to the baseline artefact, and concrete bash reproduction sequence.

Kani Testing Documentation Update

Layer / File(s) Summary
Dynamic Kani toolchain path computation
docs/developers-guide.md
Update LD_LIBRARY_PATH example to derive the installed Kani version and toolchain library directory from cargo kani --version output, replacing hard-coded home path and version string.

Possibly related PRs

  • leynos/beatcue#16: Both PRs modify docs/contents.md (this PR adds the "Tee hot-path profiling baseline" entry and reference link, whilst the retrieved PR rebuilds the documentation contents index), so their changes may directly overlap in the same file.

Poem

Profilers hum where bytes collide,
Six verdicts rise from perf's deep tide,
Fixtures logged and timelines traced,
ADR phased forward, steps embraced,
Dynamic paths let Kani bide.

🚥 Pre-merge checks | ✅ 20
✅ Passed checks (20 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Record tee hot-path profiling baseline (#127)' directly aligns with the PR's primary objective of documenting the tee hot-path profiling baseline as ADR-002 Phase 1 evidence, and includes the required issue reference (#127).
Description check ✅ Passed The description comprehensively relates to the changeset, covering the baseline profiling results, hypothesis verdicts, documentation updates, validation steps, and reproduction guidance that align with the three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Testing (Overall) ✅ Passed PR is documentation-only (no production code or behavioural changes), so no tests are required per check instructions.
User-Facing Documentation ✅ Passed PR introduces no user-facing functionality—only profiling documentation and developer build settings. Changes are confined to docs/developers-guide.md and new profiling-baseline document.
Developer Documentation ✅ Passed PR updates docs/developers-guide.md with "Profiling prerequisites and build settings" section documenting all build requirements (RUSTFLAGS, PYTHONPERFSUPPORT, perf sampling), tooling, permissions...
Module-Level Documentation ✅ Passed Pull request contains only documentation changes (three .md files); no Python modules or code modules are added or modified, making the module-level docstring check inapplicable.
Testing (Unit And Behavioural) ✅ Passed PR is documentation-only (three .md files modified); no production code changes, so testing check does not apply to this change type.
Testing (Property / Proof) ✅ Passed This PR modifies only documentation files (3 markdown files in docs/). No production code changes introduce invariants, lemmas, or proof assumptions. The baseline document records empirical profili...
Testing (Compile-Time / Ui) ✅ Passed PR is documentation-only (three markdown files: contents.md, tee-hotpath-profiling-baseline-2026-06-12.md, developers-guide.md). No production code changes. Testing check requiring compile-time try...
Unit Architecture ✅ Passed This PR contains only documentation changes (three .md files). The Unit Architecture check addresses code structure and design patterns; it does not apply to documentation-only PRs with zero produc...
Domain Architecture ✅ Passed Documentation-only PR with zero production code changes; profiling baselines and build settings properly segregated as infrastructure/operational concerns, not domain logic.
Observability ✅ Passed This PR contains only documentation changes (three .md files: contents.md, tee-hotpath-profiling-baseline-2026-06-12.md, and developers-guide.md). No production code (Python or Rust) is modified, s...
Security And Privacy ✅ Passed Documentation-only pull request with no secrets, credentials, injection risks, or sensitive data exposure. Permission guidance is explicit and safe, offering alternatives to privilege escalation. A...
Performance And Resource Use ✅ Passed PR contains only documentation additions and updates (+300 lines); zero production code changes to cuprum/, benchmarks/, or any .py/.rs files. No algorithmic, resource allocation, or I/O performanc...
Concurrency And State ✅ Passed PR contains documentation-only changes with no production code, no shared state introduction, no async/concurrency primitives, and no state transitions — concurrency check not applicable.
Architectural Complexity And Maintainability ✅ Passed Pull request is documentation-only: records profiling baseline evidence (findings document, index entry, prerequisites guide) with no production code changes, abstractions, frameworks, dependencies...
Rust Compiler Lint Integrity ✅ Passed The PR contains documentation-only changes (three .md files); no Rust source code was modified, so the Rust compiler lint integrity check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch profiling-investigation

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

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a new tee hot-path profiling baseline document as ADR-002 Phase 1 evidence and wires it into the docs index; no production code is changed.

File-Level Changes

Change Details Files
Add detailed tee hot-path profiling baseline document as ADR-002 Phase 1 evidence
  • Document profiling environment, fixtures, and artefact layout for the tee hot-path harness
  • Summarize scenario wall-times, throughput, and hypothesis verdicts from perf and py-spy data
  • Record incidental findings (Rust pump FD-close race, perf script losing Python frames) and implications for ADR-002 phasing
  • Provide reproduction commands for regenerating profiling artefacts
docs/tee-hotpath-profiling-baseline-2026-06-12.md
Register the profiling baseline document in the documentation index
  • Add tee hot-path profiling baseline entry under ADRs in the contents list
  • Link the new tee-baseline reference into the planning and validation section
docs/contents.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-delta-analysis[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot marked this pull request as ready for review June 12, 2026 15:58
sourcery-ai[bot]

This comment was marked as resolved.

Expand the ADR, PTY, FD, and JIT acronyms on first use per the
documentation style guide. Derive the 84.77 M line-callback count from
the wrap-76 fixture geometry, and document the exact inline driver used
for the `_READ_SIZE` sweep so the reported gains are reproducible.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos

leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Has this now been resolved in the latest commit?

Use codegraph analysis to determine your answer.

If this comment is now resolved, please mark it as such using the API. Otherwise, please provide an AI agent prompt for the remaining work to be done to address this comment.

## Overall Comments
- Consider briefly describing how the `echo-devnull-cb-s1` scenario’s line count (84.77 M lines) is derived or constrained so future readers can match those numbers when adjusting fixtures or callbacks.
- The `_READ_SIZE` sweep methodology (monkeypatched driver) is only sketched; adding a short note with the exact driver location or command used would make the benchmark more easily reproducible and the reported gains easier to validate.

## Individual Comments

### Comment 1
<location path="docs/tee-hotpath-profiling-baseline-2026-06-12.md" line_range="5" />
<code_context>
+
+This document records the first full run of the tee hot-path profiling harness
+(`benchmarks/`) and the hotspot verdicts it produced. It is the Phase 1
+baseline evidence called for by
+[ADR-002](adr-002-additional-rust-components.md), and it gates the Phase 2
+decision on issue [#127](https://github.com/leynos/cuprum/issues/127)
</code_context>
<issue_to_address>
**issue (review_instructions):** The acronym “ADR” in “ADR-002” is used without being expanded on first use; please spell it out (for example, “Architecture Decision Record (ADR-002)”).

To comply with the acronym rule, expand ADR the first time it appears in this document, and then keep using the short form thereafter.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Define uncommon acronyms on first use.

</details>
</issue_to_address>

### Comment 2
<location path="docs/tee-hotpath-profiling-baseline-2026-06-12.md" line_range="43" />
<code_context>
+| ----------------------------- | --------- | ----------- | -------------- |
+| `echo-devnull-nocb-s1`        | 6.80 s    | 0.88 GiB/s  | baseline       |
+| `echo-textblackhole-nocb-s1`  | 5.63 s    | 1.07 GiB/s  | text branch    |
+| `echo-pty-nocb-s1`            | 33.02 s   | 0.18 GiB/s  | PTY sink       |
+| `tee-devnull-nocb-s1`         | 14.45 s   | 0.42 GiB/s  | capture + echo |
+| `echo-devnull-cb-s1`          | 312.11 s  | 0.019 GiB/s | 84.77 M lines  |
</code_context>
<issue_to_address>
**issue (review_instructions):** The acronym “PTY” is introduced here without expansion; it should be defined (for example, “pseudoterminal (PTY)”) on first use.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Define uncommon acronyms on first use.

</details>
</issue_to_address>

### Comment 3
<location path="docs/tee-hotpath-profiling-baseline-2026-06-12.md" line_range="139" />
<code_context>
+
+## Incidental findings
+
+- **FD-close race on the Rust pump path.** The
+  `echo-devnull-nocb-s4-rust` run logged repeated
+  `OSError: [Errno 9] Bad file descriptor` from
</code_context>
<issue_to_address>
**issue (review_instructions):** The abbreviation “FD” (file descriptor) is used without being defined on first use; please expand it when first introduced.

Consider rephrasing the heading to something like “File-descriptor (FD) close race on the Rust pump path.” After the expansion, the shorter FD form can be used elsewhere.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Define uncommon acronyms on first use.

</details>
</issue_to_address>

### Comment 4
<location path="docs/tee-hotpath-profiling-baseline-2026-06-12.md" line_range="146" />
<code_context>
+  the file-descriptor ownership risk recorded in ADR-002 and is adjacent to
+  issues #124/#125. The run still completed with exit code 0, so the failure is
+  currently silent. Worth an issue.
+- **`perf script` drops Python JIT frames on this distro.** Distro perf
+  6.12 resolves `py::` trampoline symbols in `perf report` but not in
+  `perf script`, so the generated `stacks.folded` and `summary.json` contain no
</code_context>
<issue_to_address>
**issue (review_instructions):** The acronym “JIT” is used without expansion; it should be defined (for example, “just-in-time (JIT)”) the first time it appears.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Define uncommon acronyms on first use.

</details>
</issue_to_address>

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Read the current state of the profiling baseline document to check acronym expansions
cat docs/tee-hotpath-profiling-baseline-2026-06-12.md

Length of output: 11473


🏁 Script executed:

#!/bin/bash
# List review comments by coderabbitai on PR `#171` to find comment IDs to resolve
gh api repos/leynos/cuprum/pulls/171/reviews \
  --jq '.[] | select(.user.login == "coderabbitai") | {id: .id, state: .state, submitted_at: .submitted_at}'

Length of output: 491


🏁 Script executed:

#!/bin/bash
# Try the review comments (inline comments) endpoint
gh api repos/leynos/cuprum/pulls/171/comments \
  --jq '.[] | select(.user.login == "coderabbitai") | {id: .id, path: .path, line: .line, body: (.body | .[0:80])}'

Length of output: 471


🏁 Script executed:

#!/bin/bash
# Try GraphQL to find review thread comments by coderabbitai
gh api graphql -f query='
{
  repository(owner: "leynos", name: "cuprum") {
    pullRequest(number: 171) {
      reviewThreads(first: 50) {
        nodes {
          id
          isResolved
          comments(first: 5) {
            nodes {
              author { login }
              body
              databaseId
            }
          }
        }
      }
    }
  }
}' | jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.comments.nodes[0].author.login == "coderabbitai") | {threadId: .id, isResolved: .isResolved, body: (.comments.nodes[0].body | .[0:100])}'

Length of output: 893


🏁 Script executed:

#!/bin/bash
# Check all review threads on PR `#171`, regardless of author
gh api graphql -f query='
{
  repository(owner: "leynos", name: "cuprum") {
    pullRequest(number: 171) {
      reviewThreads(first: 50) {
        nodes {
          id
          isResolved
          comments(first: 3) {
            nodes {
              author { login }
              body
              databaseId
            }
          }
        }
      }
    }
  }
}' | jq '.data.repository.pullRequest.reviewThreads.nodes[] | {threadId: .id, isResolved: .isResolved, author: .comments.nodes[0].author.login, body: (.comments.nodes[0].body | .[0:120])}'

Length of output: 1575



@leynos: All four individual comments are already resolved — both in the GitHub thread state and in the document itself. Here is the verification from the latest commit of docs/tee-hotpath-profiling-baseline-2026-06-12.md:

Acronym Status Evidence in file
ADR ✅ Resolved Line 5: "Architectural Decision Record (ADR) 002 ([ADR-002]…)"
PTY ✅ Resolved Paragraph below the scenario table: "echoes into a pseudo-terminal (PTY) sink"
FD ✅ Resolved Incidental findings heading: "File-descriptor (FD) close race on the Rust pump path."
JIT ✅ Resolved Second bullet: "perf script drops Python just-in-time (JIT) trampoline frames on this distro"

The two overall comments are also addressed: the 84.77 M line count is now derived explicitly in prose (2,175,740,011 bytes ÷ 77-byte lines × 3 repeats = 84,769,092 invocations), and the exact _READ_SIZE driver command is reproduced in full under Hypothesis 1.

All four threads were already marked resolved on GitHub (by sourcery-ai, which raised them), so no API action is needed on my part.

@coderabbitai coderabbitai Bot added the Roadmap label Jun 12, 2026

@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 `@docs/contents.md`:
- Around line 34-35: The profiling baseline list item "[Tee hot-path profiling
baseline (2026-06-12)][tee-baseline]" currently sits under decision records but
should be moved into the "Planning and validation references" section; locate
the entry in docs/contents.md and cut/paste that list item into the "Planning
and validation references" (or similarly named validation references) subsection
so benchmark artefacts live with validation materials rather than the decision
index.

In `@docs/tee-hotpath-profiling-baseline-2026-06-12.md`:
- Around line 12-21: Add short Markdown captions under each table in the file:
the environment table (the block starting with the Git commit / CPU / Kernel
rows), the scenario results table(s), and the hypothesis-verdict table(s). For
each table insert a one-line caption immediately below the table using the
pattern from the docs style guide (e.g., "Table: Environment used for
profiling", "Table: Scenario results", "Table: Hypothesis and verdict"), so the
page passes the docs lint rule requiring captions; apply the same change to the
other table occurrences mentioned (the blocks around lines ~39-47 and ~132-138).
🪄 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 Plus

Run ID: 4b092fe8-dd83-487a-8809-54287767d968

📥 Commits

Reviewing files that changed from the base of the PR and between a50a631 and 63da1c3.

📒 Files selected for processing (2)
  • docs/contents.md
  • docs/tee-hotpath-profiling-baseline-2026-06-12.md

Comment thread docs/contents.md Outdated
Comment thread docs/tee-hotpath-profiling-baseline-2026-06-12.md
@leynos

leynos commented Jun 13, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

Move the tee profiling baseline index entry from "Design and decisions"
to "Planning and validation references", since it is a benchmark
artefact rather than a decision record.

Add captions to all four tables in the baseline document per the
documentation style guide rule requiring a caption on every table.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@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: 1

🤖 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 `@docs/tee-hotpath-profiling-baseline-2026-06-12.md`:
- Around line 54-57: The prose describing wrap-76's line geometry is wrong:
update the sentence about the wrap-76 fixture so it explicitly states there are
28,256,363 full lines of 76 characters plus newline and a final partial line of
60 bytes (so each repeat emits 28,256,364 lines and three repeats yield
84,769,092 callbacks), replacing the current claim that all 28,256,364 lines are
full 76-char+newline lines; refer to the "wrap-76" fixture and the numeric
totals in the existing sentence and adjust wording and the split accordingly.
🪄 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 Plus

Run ID: b45200e0-8689-4b8c-a76b-e72430cfcf16

📥 Commits

Reviewing files that changed from the base of the PR and between a50a631 and d128d9f.

📒 Files selected for processing (2)
  • docs/contents.md
  • docs/tee-hotpath-profiling-baseline-2026-06-12.md

Comment thread docs/tee-hotpath-profiling-baseline-2026-06-12.md Outdated
Add a "Profiling prerequisites and build settings" subsection covering
the tooling the baseline document depends on: frame-pointer Rust builds
(`RUSTFLAGS="-C force-frame-pointers=yes"`), `PYTHONPERFSUPPORT=1`, the
`perf record -F 999 -g --call-graph dwarf,16384` sampling defaults, and
the required `perf`/`inferno`/`py-spy` tools. Link the baseline document
and give the harness reproduction entrypoint.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@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 `@docs/developers-guide.md`:
- Around line 134-155: Update the prereq build instruction that currently reads
"RUSTFLAGS=\"-C force-frame-pointers=yes\" before `maturin develop --release`"
so it exactly mirrors the recorded command by including the crate manifest path
and the uv wrapper — i.e. ensure the step specifies `RUSTFLAGS="-C
force-frame-pointers=yes"` and then runs `uv run maturin develop --release
--manifest-path rust/cuprum-rust/Cargo.toml` (keep the `uv run` wrapper as shown
in the reproduction block) so readers running from the repo root use the correct
crate.
- Around line 130-143: Add a short prerequisite line that states the required
perf permission level for the documented record command: specify that the
baseline was captured with perf_event_paranoid=2 and show the sysctl command to
set it (sysctl -w kernel.perf_event_paranoid=2), or alternatively note that perf
must be run as root or the user granted CAP_SYS_ADMIN; place this immediately
after the "Install `perf`..." bullet and reference the recorded command `perf
record -F 999 -g --call-graph dwarf,16384` so readers know this prerequisite
applies to that sampling invocation and provide the equivalent sampling/config
option guidance for hardened hosts.
🪄 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 Plus

Run ID: 86003ba6-2770-4cde-adeb-e16311d517b4

📥 Commits

Reviewing files that changed from the base of the PR and between d128d9f and 8f35b61.

📒 Files selected for processing (1)
  • docs/developers-guide.md

Comment thread docs/developers-guide.md
Comment thread docs/developers-guide.md
Record the `perf_event_paranoid` level the harness needs alongside the
sampling command. The baseline ran at `perf_event_paranoid=2` (enough
for user-space call graphs; kernel frames stay unresolved), with notes
on checking the current level, lowering it for the session, or granting
`CAP_PERFMON`.
@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Fix the wrap-76 fixture description: the 2,175,740,011 output bytes are
28,256,363 full 76-character lines plus a newline followed by a final
60-byte partial line with no trailing newline, not 28,256,364 full
lines. Each repeat still emits 28,256,364 lines, so three repeats yield
84,769,092 callbacks.

Align the developers' guide frame-pointer build bullet with the
reproduction block so it uses
`uv run maturin develop --release --manifest-path rust/cuprum-rust/Cargo.toml`
from the repository root.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning docs/developers-guide.md’s new profiling prerequisites section omits required perf permission details (no perf_event_paranoid/permission guidance), while baseline doc records perf_event_paranoid=2. Update docs/developers-guide.md ‘Profiling prerequisites and build settings’ to state the required perf permission level (e.g., perf_event_paranoid=2 or equivalent CAP) alongside the perf record command.

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added Issue and removed Roadmap labels Jun 14, 2026
coderabbitai[bot]

This comment was marked as resolved.

Replace the hardcoded `.venv/bin/python` in the read-size sweep snippet
with `uv run python` to match the portable entrypoint used elsewhere in
the document.

Document the py-spy corroboration step so the parent-only folded
captures under `dist/profiles/pyspy/` can be regenerated. py-spy must
attach to the worker interpreter directly (not `uv run` or the writer
subprocess), so resolve the venv interpreter portably via
`sys.executable` rather than a hardcoded path.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

The Kani `LD_LIBRARY_PATH` example used a hardcoded personal home
directory (`/home/leynos/.kani/...`), exposing a username. Replace it
with `$HOME` and derive the version directory from `cargo kani
--version` so the command works on any installation.

The path predates this branch on `origin/main`; this commit fixes it
while the surrounding profiling documentation is in flight.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

docs/tee-hotpath-profiling-baseline-2026-06-12.md (2)

75-86: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Make the sweep driver portable.
Use the same uv run python entrypoint as the rest of the document instead of .venv/bin/python; this snippet currently depends on a worktree-local virtualenv path and will fail on fresh clones or alternative venv layouts. As per coding guidelines, keep documentation examples reproducible and repository-agnostic.

♻️ Proposed fix
-.venv/bin/python -c "
+uv run python -c "
🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/tee-hotpath-profiling-baseline-2026-06-12.md around lines 75 - 86, The
bash snippet uses a hardcoded virtualenv path (.venv/bin/python) which is not
portable across different environments and will fail on fresh clones or
alternative venv layouts. Replace .venv/bin/python with uv run python to match
the portable entrypoint pattern used throughout the rest of the document,
ensuring the sweep driver script executes consistently regardless of the user's
specific virtualenv setup.

Source: Coding guidelines
209-226: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
Add the py-spy replay step.
The reproduction section only shows fixture generation and the perf run, so the py-spy corroboration mentioned earlier cannot be regenerated from this page alone. Document the exact py-spy invocation that produced the folded captures under dist/profiles/pyspy/, or state explicitly that those artefacts are archival only. As per coding guidelines, keep baseline documents fully reproducible.

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/tee-hotpath-profiling-baseline-2026-06-12.md around lines 209 - 226,
The Reproduction section is incomplete and does not include the py-spy profiling
step that was mentioned earlier in the document for generating the folded
captures. Either add the exact py-spy invocation command (with all necessary
flags and parameters) that produces the artifacts under dist/profiles/pyspy/, or
explicitly state that those artifacts are archival only and cannot be
regenerated from this page. This will ensure the baseline document is fully
reproducible as per coding guidelines.

Source: Coding guidelines

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check lines 70-95 for the sweep driver snippet
echo "=== Lines 70-95 ==="
sed -n '70,95p' docs/tee-hotpath-profiling-baseline-2026-06-12.md

echo ""
echo "=== Lines 200-253 (reproduction section) ==="
sed -n '200,253p' docs/tee-hotpath-profiling-baseline-2026-06-12.md

echo ""
echo "=== Search for .venv/bin/python ==="
grep -n '\.venv/bin/python' docs/tee-hotpath-profiling-baseline-2026-06-12.md || echo "No .venv/bin/python found"

echo ""
echo "=== Search for py-spy invocation ==="
grep -n 'py-spy\|pyspy' docs/tee-hotpath-profiling-baseline-2026-06-12.md

Length of output: 5199



@leynos: Both issues are resolved in the latest commit.

Location Issue Status Evidence
Lines 75–86 .venv/bin/pythonuv run python ✅ Resolved No occurrence of .venv/bin/python remains; the sweep driver now reads uv run python -c "…"
Lines 209–226 py-spy replay step missing from Reproduction section ✅ Resolved A full py-spy block (lines 228–252) now resolves the venv interpreter portably via sys.executable, issues two py-spy record invocations for tee-devnull-nocb-s1 and echo-devnull-cb-s1, and finalises with summarize_folded.py

No further work is required.

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

♻️ Duplicate comments (1)
docs/developers-guide.md (1)

145-152: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the writable sysctl form here.

sysctl kernel.perf_event_paranoid=2 only reads the value; it does not change
the kernel setting. Replace it with sudo sysctl -w kernel.perf_event_paranoid=2
so the documented fallback actually works.

🔧 Proposed fix
-  lower it for the session (`sudo sysctl kernel.perf_event_paranoid=2`, or a
+  lower it for the session (`sudo sysctl -w kernel.perf_event_paranoid=2`, or a

Run this read-only check to confirm the local sysctl build exposes the write
flag before publishing the example:

#!/bin/bash
set -euo pipefail
sysctl --help | grep -E -- '(^|[[:space:]])-w([[:space:]]|,|$)'
🤖 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 `@docs/developers-guide.md` around lines 145 - 152, The documentation for
lowering perf_event_paranoid contains an incomplete sysctl command that only
reads the current value but does not modify it. In the section describing the
fallback option to lower perf_event_paranoid for the session, update the command
from `sudo sysctl kernel.perf_event_paranoid=2` to `sudo sysctl -w
kernel.perf_event_paranoid=2` by adding the `-w` flag so the documented command
actually writes and applies the kernel setting change.
🤖 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.

Duplicate comments:
In `@docs/developers-guide.md`:
- Around line 145-152: The documentation for lowering perf_event_paranoid
contains an incomplete sysctl command that only reads the current value but does
not modify it. In the section describing the fallback option to lower
perf_event_paranoid for the session, update the command from `sudo sysctl
kernel.perf_event_paranoid=2` to `sudo sysctl -w kernel.perf_event_paranoid=2`
by adding the `-w` flag so the documented command actually writes and applies
the kernel setting change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1f66dd09-e4bf-425e-905c-88be0190155c

📥 Commits

Reviewing files that changed from the base of the PR and between 72dd8c0 and 7881a4b.

📒 Files selected for processing (2)
  • docs/developers-guide.md
  • docs/tee-hotpath-profiling-baseline-2026-06-12.md

Add the `-w` flag to the documented `sudo sysctl kernel.perf_event_paranoid=2`
fallback so the command explicitly writes the kernel setting.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]

This comment was marked as resolved.

State the perf remediation precisely: `sysctl -w` changes a host-level
kernel setting (not a session-local one), and `CAP_PERFMON` is granted
to the `perf` binary (for example with `setcap`), not to an invocation.

Prefix the Kani example with `cd rust` so it resolves the `cuprum-rust`
package from the Rust workspace when run from the repository root, as
every Makefile cargo target already does.
@leynos

leynos commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

docs/developers-guide.md (2)

145-152: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
State the perf permission workaround precisely.
sysctl -w changes the host kernel setting, not a session-local one, and CAP_PERFMON applies to the perf binary rather than an invocation. Rephrase this bullet so readers know exactly which remediation to apply and what it affects.

🛠️ Proposed fix
-  lower it for the session (`sudo sysctl -w kernel.perf_event_paranoid=2`, or a
-  lower value such as `1` or `-1` to resolve kernel frames too) or grant
-  `CAP_PERFMON` to the `perf` invocation.
+  lower it on the host (`sudo sysctl -w kernel.perf_event_paranoid=2`, or a
+  lower value such as `1` or `-1` if kernel frames are also required), or
+  grant `CAP_PERFMON` to the `perf` binary.

Based on the benchmark prerequisites and profiler invocation notes, the remediation path needs to be stated as a host-level setting change or a binary capability grant.

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/developers-guide.md around lines 145 - 152, The perf permission
workaround documentation in the developers-guide.md file contains two
inaccuracies that need correction. First, remove the phrase "for the session"
when describing the sysctl command since sysctl -w applies a host-level kernel
setting change, not a temporary session-local one. Second, clarify that
CAP_PERFMON is a capability granted to the perf binary itself via tools like
setcap, not applied to individual perf invocations. Rephrase this bullet point
to clearly distinguish between these two remediation approaches: one as a
persistent host-level kernel setting change (using sysctl) and the other as
granting a binary capability to the perf executable, so readers understand
exactly which approach to use and what scope it affects.

491-500: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win
Run the Kani example from the Rust workspace.
cargo kani --package cuprum-rust needs the rust/ workspace context. Add the workspace directory to the command so the example works when copied from the repository root.

🛠️ Proposed fix
-LD_LIBRARY_PATH="$HOME/.kani/kani-$(cargo kani --version | awk '{print $2}')/toolchain/lib" \
-  cargo kani --package cuprum-rust
+cd rust && \
+LD_LIBRARY_PATH="$HOME/.kani/kani-$(cargo kani --version | awk '{print $2}')/toolchain/lib" \
+  cargo kani --package cuprum-rust

Based on the repository layout and Rust testing guidance, the example needs the rust/ workspace context.

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/developers-guide.md around lines 491 - 500, The Kani example command in
the developers-guide.md file needs to be updated to include the workspace
context so it works when copied and executed from the repository root. Modify
the cargo kani command that currently shows cargo kani --package cuprum-rust
to navigate to or explicitly reference the rust/ workspace directory, ensuring
the example functions correctly regardless of where it is executed from within
the repository. This could be done by prefixing with a directory change (e.g.,
cd rust/ &&) or by using Cargo's manifest path option to specify the workspace
location.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check lines 140-160 for the perf permission workaround
echo "=== Lines 140-160 (perf permission section) ==="
sed -n '140,160p' docs/developers-guide.md

echo ""
echo "=== Lines 485-505 (Kani example section) ==="
sed -n '485,505p' docs/developers-guide.md

echo ""
echo "=== Search for 'for the session' ==="
grep -n 'for the session' docs/developers-guide.md || echo "No match"

echo ""
echo "=== Search for 'CAP_PERFMON' ==="
grep -n 'CAP_PERFMON' docs/developers-guide.md || echo "No match"

echo ""
echo "=== Search for 'cd rust' or 'rust/' near cargo kani ==="
grep -n 'cd rust\|rust/\|cargo kani' docs/developers-guide.md || echo "No match"

Length of output: 3632



@leynos: Both issues are resolved in the latest commit.

Location Issue Status Evidence
Lines 145–152 "for the session" phrasing ✅ Resolved Replaced with "lower it on the host"; CAP_PERFMON now explicitly targets the perf binary with setcap noted as the mechanism
Lines 491–500 Missing cd rust workspace context ✅ Resolved Command now reads cd rust && \ LD_LIBRARY_PATH=… cargo kani --package cuprum-rust

No further work is required.

@leynos
leynos merged commit 692124c into main Jun 14, 2026
18 checks passed
@leynos
leynos deleted the profiling-investigation branch June 14, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants