Skip to content

perf(observability): ripr cannot report its own CPU time or peak memory - every efficiency claim is unfalsifiable #5213

Closed

Description

@EffortlessSteven

Problem

ripr measures wall-clock time only. It cannot report how much CPU time a run consumed, and it cannot report how much memory it held. Every efficiency claim the project makes — "fast", "bounded", "minimal working set" — is therefore unfalsifiable from evidence the product itself produces.

Verified against main at a452edaf2, classification verified_current.

What exists today

Wall clock only, via an opt-in stderr phase trace:

  • crates/ripr/src/analysis/seam_inventory.rs:342-368 emits duration_ms= lines for discover_rust_files, collect_workspace_state, cache_load, cold_compute, file_fact_cache, apply_oracle_policy, inventory_seams, evidence_for_seams, classify_seams, cache_store, total.
  • crates/ripr/src/analysis/test_grip_evidence.rs:208-214 emits per-chunk evidence progress.
  • cargo xtask repo-exposure-latency-report (xtask/src/main.rs:10411) parses those lines into target/ripr/reports/repo-exposure-latency.{json,md}.
  • cargo xtask targeted-rerun-benchmark (xtask/src/reports/targeted_rerun.rs:10-16) asserts WARM_P50_TARGET_MS = 30_000 and SPEEDUP_TARGET = 5.

Every one of these is Instant::now() / elapsed(). There is no CPU-time attribution and no memory observation anywhere.

What does not exist

A repository-wide search of crates/, xtask/ and editors/ for
peak_rss, getrusage, working_set, VmHWM, max_rss, rusage,
GetProcessMemoryInfo, WorkingSetSize returns no measurement code. The
only hits are the unrelated working_set analysis scope name in
docs/OUTPUT_SCHEMA.md and schemas/ripr/review-comments.schema.json, the
traceability corpus, and a TypeScript MEMORYSTATUSEX struct in
editors/vscode/src/lspCompatibility.ts:88-89 that measures the editor, not
ripr.

Consequences that matter to a user deciding whether to adopt the tool:

  1. "Is ripr going to OOM my 16 GB CI runner?" is unanswerable from product output. The
    project has already had runner-OOM incidents (ripr review-guidance pass dies by SIGTERM (oomd-class) on ~1700-file closures: peak memory scales with closure size #3768, ripr analysis OOMs the GitHub Actions runner on large module-extraction diffs (~2600+ lines) #1324, Diff-scoped analysis exhausts GitHub-hosted runner resources on large PRs (runner shutdown, exit 143) #1023) and repaired them by
    inspection, not by measurement.
  2. Wall time cannot attribute cost. A run that takes 300 s may be 300 s of CPU on one core,
    or 30 s of CPU spread across 10 rayon workers plus 270 s blocked on git or cargo metadata. evidence_for_seams and classify_seams_owned are currently sequential
    (analysis/test_grip_evidence.rs:202-215, analysis/seam_classification.rs:155-175)
    while rayon is already a hard dependency used in analysis/facts/build.rs:117,182 —
    only CPU time can tell a parallelization win from an I/O wait.
  3. The existing perf claims cannot be regression-guarded. A RAM budget with no observation
    is not a budget.

Non-goals

  • No new benchmark harness, criterion bench, or profiling profiler.
  • No performance change to the analysis pipeline. This issue only makes cost observable.
  • No published or public resource envelope claim in this slice.
  • No gate that fails CI on a resource number.

Acceptance

  1. ripr can observe its own process CPU time and peak resident memory, portably, with
    no unsafe (crates/ripr/Cargo.toml:107 inherits workspace unsafe_code = "forbid").
  2. Observation is opt-in and off by default, and emitted on stderr so stdout JSON stays
    byte-identical. It rides the existing RIPR_REPO_EXPOSURE_LATENCY_TRACE=1 family rather than
    inventing a parallel switch.
  3. Where a platform offers no safe observation, the report says so explicitly as a named
    unavailable/unknown state. It never prints 0, never omits the field silently, and never
    presents a partial observation as complete.
  4. cargo xtask repo-exposure-latency-report carries the observed CPU and peak-memory values
    into target/ripr/reports/repo-exposure-latency.{json,md}, with the same
    observed/unavailable distinction, and states the host it observed on.
  5. The measured numbers are attributable to the run, not to the harness: a reviewer can tell
    which process the CPU time and peak RSS belong to.
  6. Tests discriminate the real behavior:
    • a unit test that the emitted record round-trips and that the unavailable state is
      distinct from a zero measurement;
    • a test that with tracing off, no resource line is emitted and stdout is unchanged;
    • a test that the xtask report parser carries the new fields through and preserves the
      unknown state rather than defaulting it away.

Rollback

Revert the trace emission and the xtask parser change. No analysis behavior, output schema,
or classification depends on it.

Notes for implementation

  • Linux peak RSS is readable from /proc/self/status VmHWM with no dependency and no
    unsafe. Linux CPU time is readable from /proc/self/stat utime+stime (clock ticks).
  • On Windows, winsafe is already a cfg(windows) dependency with the kernel feature
    (crates/ripr/Cargo.toml:78), and process-wrap is already used for Job Object ownership.
    Prefer those reviewed safe wrappers over adding a raw FFI surface.
  • Read the observation at the end of the run, not on a timer thread.
  • Do not let the observation itself allocate materially or hold the trace string.

Activity

  1. added
    status/needs-work
    and removed
    status/needs-work
    on Oct 4, 2026
  2. EffortlessSteven commented on Oct 4, 2026

    @EffortlessSteven
    MemberAuthor

    Delivered — PR #5282, merge commit 7043d576

    All seven acceptance items are met at 7043d576, verified at the merged head.

    # Acceptance Where
    1 ripr observes its own CPU time and peak RSS, portably, no unsafe crates/ripr/src/analysis/resource_cost.rs; Linux via /proc/self/{stat,status}, Windows via winsafe's safe HPROCESS::GetProcessTimes / GetProcessMemoryInfo (psapi feature added at Cargo.toml:78-84)
    2 Opt-in, off by default, stderr only, reusing RIPR_REPO_EXPOSURE_LATENCY_TRACE analysis/resource_cost.rs is now the single owner of that env family; the two duplicate private trace-line copies were removed. tracing_off_leaves_stdout_and_stderr_byte_identical pins stdout and stderr
    3 Unavailable is an explicit named state, never 0, never silently omitted ResourceUnavailableReason; observed and unavailable are distinct serialized shapes, and both the producer's and the consumer's mirrors carry deny_unknown_fields
    4 repo-exposure-latency-report carries CPU and peak RSS, names the host, preserves unavailable xtask/src/main.rs, independent mirror types, report schema_version 0.2 -> 0.3
    5 The numbers are attributable to the run observer: "ripr_process_self" plus observer_pid, carried as data
    6 Discriminating tests incl. negative controls 6 reverted controls each observed red; 1 dishonest shape kept as a committed control so it cannot pass by rejecting everything

    One premise in this issue was wrong, and it is recorded

    Acceptance 1 asked for portability, and the implementation note suggested winsafe's kernel
    feature already covered Windows. It did not, in the way the note assumed. The first candidate
    published a false capability-absence claim — that Windows had no safe per-process counter —
    in a module doc, an enum variant, and docs/OUTPUT_SCHEMA.md.

    It was false because the search behind it was: on Windows PowerShell, src/**/*.rs passed to
    Select-String -Path is not recursive, so it read the raw extern declarations and never
    reached the safe handles/ wrappers. Both calls were already available. The issue's note is
    corrected in docs/LEARNINGS.md, which now records that a capability-absence claim needs a
    search that provably covered the tree, and that "the grep found no implementation" is not the
    same claim as "the API does not exist".

    This is worth flagging beyond this issue: the same shallow-search failure mode can manufacture a
    false absence anywhere in this repository, and the project's history of false capability claims
    makes that a recurring hazard rather than a one-off.

    Honest residuals, carried forward rather than closed as solved

    • Linux runtime numbers were never read locally — the host is Windows. The Linux #[cfg]
      blocks compile under --target x86_64-unknown-linux-gnu and hosted Linux CI builds and tests
      the crate, but the emitted Linux values have not been observed by a human.
    • ripr mcp --stdio bypasses cli::run via startup.rs and emits no receipt. Honest — no
      receipt rather than a partial one — but the long-lived MCP server's own cost is exactly what a
      user would ask about, and it is not covered.
    • The receipt is now three xtask lanes' stderr, not one. Harmless today; any future lane that
      asserts an exact stderr line set will notice.

    Closing as delivered. The residuals above are stated, not claimed as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions