Skip to content

perf(diff): remove temporary strings from cold owner lookup - #3853

Merged
EffortlessSteven merged 1 commit into
mainfrom
perf/cold-diff-owner-identity-3847
Sep 24, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
perf/cold-diff-owner-identity-3847

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Remove the two normalized String constructions performed for every inspected function during diff-probe owner lookup. Compare borrowed bytes with the existing slash/backslash equivalence instead. This needs no pre-cache or base proof.

Keep the original ordered full-identity lookup; do not narrow evidence or alter include-owner attribution. Add five Rust tests and preserve the existing included-fragment regression.

Current candidate and disposition

  • Head: 0f2814da87e6068a2eff8a627c50410316922e13 (single squashed commit, rebased onto protected main 532d379ae59c8f48c6e7ab4a91f09a4a809dd890 on 2026-09-24; owner.rs content is byte-identical to the reviewed 9e86c65e tip — same source blob, so prior source reasoning and oracles apply verbatim)
  • Publication/integration basis: 532d379ae59c8f48c6e7ab4a91f09a4a809dd890
  • Source blob: 278e4256f82b632dda38208c4b02906bb5975714
  • Ready for review convergence: hosted routed Rust gates, Ripr Rust Small Result, and ub-review concluded success at this exact head (run 35991332805), and local native proof on Windows passed (rustfmt, cargo check -p ripr, six targeted owner tests, include-owner integration test). End-to-end installed cold-diff latency remains unmeasured and stays outside the claim boundary.

Swarm / Source Boundary

This PR targets EffortlessMetrics/ripr-swarm only. No write to EffortlessMetrics/ripr, consumer pin, release ref, package, workflow, ruleset, suppression, or gate threshold.

Source-of-truth Links

Issue: #3847. Parent: #3794. Existing include-owner contract: #3490 / #3498. Observability: #3795. Warm semantic/base-proof work: #3796. Repo-evidence indexing: #3838 (different surface; no overlap).

The explicit nonempty diff + empty analysis caches + no precomputed base proof replay acceptance is recorded in #3794, comment 5771424199. This local optimization alone does not satisfy that integrated requirement.

Scope Classification

  • One architectural seam: classifier owner identity comparison.

Production delta: an allocation-free, equal-length, byte-wise equivalence predicate replaces two str::replace calls inside the existing scan.

Evidence/support delta: independent old-comparator oracle over 341 generated strings / 116,281 ordered pairs; explicit UTF-8, case, full path/module/suffix, unequal-length and repeated-separator controls; first normalized match before a later exact match; absent/missing owner; fresh 4,097-function index with 4,096 unrelated same-named functions. No support-tier change.

Single acceptance criterion: preserve the exact owner-resolution result without constructing normalized strings per inspected candidate.

Non-goals: removing the linear scan; changing file selection or related-test semantics; a new cache/index/dependency; claiming whole-path cold latency; closing the integrated release/performance authorities.

Proof — observed, not inferred from aggregate green

Local observations:

  • Original source bytes match Git blob 2d8e8f2ff4c9b9c743c1a1215e06a0d2095ed0b7; re-fetched unchanged on the publication basis.
  • Current published content blob 278e4256f82b632dda38208c4b02906bb5975714 matches the locally inspected bytes.
  • Independent Python byte-comparison model: 116,281 ordered pairs plus 22 ordered explicit controls passed against the old replacement-based predicate. This is not Rust execution.
  • Four model mutation controls distinguish raw equality, zipped-prefix comparison without length, normalized terminal-name-only matching, and an exact-first lookup that skips an earlier separator-equivalent row.
  • git diff --check: PASS for the complete one-file delta in an isolated local review tree, not a full repository checkout.

Hosted history:

  1. Initial head 82e7190a664b9236641aa97410fba81816f99dbd: routed run 35688654957, job 106620823263, checked merge object 5f15c7816b7b9d4599e37cc0d6701839fed75723. Formatting preflight failed on tuple/assertion layout in the added tests. Actual job log inspected. Compilation and tests were skipped; no test-pass claim is attached to this run.
  2. Current head 9e86c65eb5687b4d7cd590a08eeacf875d4b60ea: exact rustfmt feedback applied in a normal follow-up commit; production behavior and test oracles unchanged. Routed run 35688819508, job 106621295995: Formatting preflight PASS, required Rust gates in progress at inspection. PR Plan and Security workflows reported success; those are not compiler/test proof.
  3. Gemini and CodeRabbit posted quota/limit responses, not substantive reviews. Other current-head review runs remained pending at inspection. Unavailable or pending review is missing evidence, not approval.
  4. Current head 0f2814da87e6068a2eff8a627c50410316922e13: the branch was rebased/squashed onto protected main 532d379a with owner.rs content unchanged (blob verified 278e4256f). Routed run 35991332805: Rust gates PASS (job 107605950571), Ripr Rust Small Result PASS, ub-review PASS, plus cargo-deny, dependency-review, pr-plan and CodeRabbit pass; advisory Droid Auto Review still queued at update time.
  5. Local native proof at the same head (Windows host, pinned toolchain 1.95.0): cargo fmt --check PASS; cargo check -p ripr PASS; cargo test -p ripr --lib analysis::classifier::owner 6 passed / 0 failed; cargo test -p ripr --test rust_include_compilation_unit 1 passed / 0 failed. Output contracts are untouched by the change, so no golden rerun is required.

Established at head 0f2814da after the rebase: hosted routed Rust gates and Ripr Rust Small Result concluded success (run 35991332805), and the previously missing local native proof now exists (rustfmt, cargo check -p ripr, targeted owner lib tests, include-owner integration test — all PASS on Windows).

Still not established:

  • Installed cold-diff wall time, peak RSS, allocation profile, and before/after benchmark. The claim boundary is source-level allocation removal; no end-to-end speedup is claimed.
  • Advisory Droid Auto Review was still queued at update time; the quota-limited Gemini/CodeRabbit responses are not substantive reviews.
  • Main advanced three unrelated commits (#3986, #3773 dependency bump, #4029) after the rebase; none touches owner.rs, so no restack or rerun of unaffected proof was performed.

Exact-head source review

  • reviewed_head_sha: 0f2814da87e6068a2eff8a627c50410316922e13 (re-inspected at finalization; owner.rs blob 278e4256f82b632dda38208c4b02906bb5975714 is identical to the inspected 9e86c65e content)
  • integration_basis: 532d379ae59c8f48c6e7ab4a91f09a4a809dd890
  • Inspected: committed implementation diff and formatting follow-up; resolver's caller in classifier::classify_probe; Rust adapter's per-probe call; original included-fragment regression; applicable source/review/security/Rust invariants.
  • Source reasoning: replacing ASCII separator bytes preserves UTF-8 length. Equal byte length plus pairwise separator equivalence is exactly the previous replacement equality. The surrounding .find remains unchanged, retaining first-match ordering. No file paths, canonical outputs or cache identities are rewritten.
  • Oracle challenge: raw equality loses mixed-separator matches; a zip-only predicate admits prefixes; terminal-name matching aliases unrelated crates; an exact-first two-pass search selects the later row. Controls distinguish these mistakes. Parity tests intentionally also pass the old implementation; removal of string construction is a source-level property, not a measured allocator receipt.
  • Formatting follow-up changes layout only; production and oracle review remain applicable. Native and integration validation must bind the current head.
  • Blocking source defects found in inspection: none. Missing execution/integration/output proof remains blocking for merge.
  • disposition: REVIEW_READY at head 0f2814da (was REVIEW_INCOMPLETE at 9e86c65e; the recorded blockers were the stale integration basis and missing native proof, both resolved above).

Support-tier Impact

  • none

Policy Impact

  • none; no new unsafe, panic shortcuts, dependencies, subprocesses, filesystem behavior, workflow or permission changes.

Claim Boundary

For K inspected nonempty IDs, the old source constructs 2K temporary normalized strings; this comparator constructs none. This is a local work reduction, not a measured end-to-end speedup. It does not establish that owner lookup dominates the historical consumer run, that all cold diffs are fast, or that #3794/#3796 or the release are complete.

Rollback

Revert the single-commit one-file change normally. No data, schema, cache or migration rollback is required.

Spec-Test-Code Traceability

CI Economics

Existing routed CI only. No added workflow, remote service, blanket full-repo scan, or universal wall-clock gate. The formatting failure was repaired on the same candidate; no rule bypass or force push.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6ced2eea-8534-426b-bebd-697bb312a779

📥 Commits

Reviewing files that changed from the base of the PR and between c797fed and 0f2814d.

📒 Files selected for processing (1)
  • crates/ripr/src/analysis/classifier/owner.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • Bug Fixes
    • Owner lookup now treats / and \ as equivalent path separators while preserving distinctions in other symbol ID characters.
    • When multiple functions match, the first match is retained. Unresolved owners continue to be handled.

Walkthrough

Owner lookup now compares symbol IDs without allocating normalized strings. The comparison accepts slash direction differences and requires all other bytes and the ID length to match. Tests cover matching, ordering, unresolved owners, Unicode, and a large index.

Changes

Owner symbol matching

Layer / File(s) Summary
Symbol comparison and owner lookup tests
crates/ripr/src/analysis/classifier/owner.rs
resolve_owner_function uses a byte-wise comparison that treats / and \ as equivalent. Tests use shared fixture setup and cover identity, separator differences, mismatches, Unicode, first-match ordering, unresolved owners, and lookup among 4,097 functions.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 0f281

Owner lookup appears to retain its existing behavior while avoiding temporary strings. No actionable merge risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. 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 and concisely describes the main change: removing temporary strings from the cold owner lookup path.
Description check ✅ Passed The description is detailed and relevant. It covers the change, scope, source boundary, proof, tests, claim limits, rollback, traceability, and CI impact. Some template checklist sections, including E…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

A rabbit checks each symbol with care
Slashes may lean this way or there
First match stays the chosen one
Unicode joins the testing run
Four thousand paths hop through the night
The owner lookup gets them right

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

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exact-head source review — REVIEW_INCOMPLETE

Blocking for merge: missing terminal native/integration proof. No additional actionable source defect was found in this inspection. This is an author COMMENT review, not an approval or an assertion of independent external review.

  • reviewed_head_sha: 9e86c65eb5687b4d7cd590a08eeacf875d4b60ea
  • integration_basis: dc66cecc2fd8a2217e944f13723e53dac68e8f67; published candidate merge ref currently 8ea5e1a1e855a51f950bd93ce433ccccc7637557.
  • claim_boundary: eliminate temporary normalized strings per owner candidate without changing full-identity resolution. No claim of end-to-end speedup, removal of the linear scan, installed no-precache readiness, or release qualification.
  • changed_surfaces_and_semantic_owners_inspected: complete committed change in analysis/classifier/owner.rs, old/new bytes and blob identities, the per-probe caller in classifier::classify_probe, Rust adapter diff classification, and the existing included-fragment attribution contract. The follow-up commit applies only the three rustfmt layout changes reported by hosted CI.
  • blocking_findings: current-head Rust tests, full routed checks and consumer-output parity are not yet established. The original formatting blocker was fixed in source and the replacement run's formatting preflight is observed passing.
  • non_blocking_suggestions: no additional source change proposed without profiling; an identity map would be a different performance slice with memory/order/currentness obligations.
  • refuted_or_stale_findings: none. Gemini/CodeRabbit quota messages are unavailable review, not semantic findings and not approval.

Correctness and oracle challenge

The previous canonicalizer replaces ASCII backslashes with ASCII slashes without changing byte length. Equal byte lengths and pairwise equality-or-separator-equivalence therefore preserve comparison over UTF-8. .find and function iteration order are unchanged. The implementation does not use the probe location to narrow candidates: that would break include fragments whose owner identity belongs to a parent compilation unit.

The retained/added Rust tests cover full identity, Unicode, mixed/repeated separators, unequal lengths, case sensitivity, missing owners, first canonical-match ordering, and 4,096 unrelated same-named functions before the correct owner. An independent Python model was rerun with 116,281 ordered comparisons and 22 explicit ordered controls. Four deliberately wrong alternatives are distinguished: raw equality, zip without length, normalized terminal-name-only equality, and exact-match-first lookup. These are algorithm-model results, not Rust test results. The old implementation intentionally passes parity tests; the allocation-removal claim is verified in source rather than asserted as a measured allocator result.

Proof provenance

proof_and_ci_observed: local git diff --check on the exact one-file delta; original/current Git blob hashes; model results above; actual failed formatting log from initial run 35688654957 / job 106620823263; successful formatting preflight on current-head-associated run 35688819508 / job 106621295995, with its Required Rust gates still in progress at inspection. PR Plan and Security report success, but neither is test evidence.

proof_or_review_missing: terminal Rust compile/test/Clippy and applicable output/golden evidence; current substantive external review; installed binary no-precache benchmark/peak RSS/phase-work receipts. Local Rust execution is unavailable. Windows integration was not exercised; separator strings are covered in source/model controls only.

affected_currentness_dimensions: candidate head and formatting validation refreshed after the layout-only follow-up. Production logic, test stimulus/oracles and claim boundary did not change.

residual_assumptions_and_non_claims: this local change cannot establish that owner lookup dominates consumer latency or satisfy the integrated cold-diff acceptance recorded under #3794. No gates, output goldens, schemas, limits, cache keys or support claims were weakened.

disposition: REVIEW_INCOMPLETE — keep draft, no merge or release authorization.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reviewed_head_sha: 9e86c65
branch_basis: dc66cec
current_main_compatibility_basis: ed4b160
claim_boundary: remove the two temporary normalized strings created per inspected owner candidate while preserving the existing ordered full-symbol identity match

currentness reconciliation:

  • current protected main has advanced, but crates/ripr/src/analysis/classifier/owner.rs is byte-identical there to the branch basis (blob 2d8e8f2ff4c9b9c743c1a1215e06a0d2095ed0b7)
  • the one-file candidate therefore has no visible source conflict with current main, but its existing merge-ref checks do not establish the eventual current-main integration object

blocking_source_findings: none

source review:

  • the old predicate is left.replace('\\', "/") == right.replace('\\', "/")
  • replacing either ASCII separator is byte-length preserving, including around UTF-8 sequences; UTF-8 continuation bytes cannot alias / or \\
  • equal byte length plus pairwise equality-or-separator-equivalence is therefore exactly the prior predicate
  • the unchanged iterator .find preserves function order and the first canonical match; an exact-first two-pass optimization would not
  • the implementation still compares the complete symbol identity and does not substitute terminal name, path location, or owner-name similarity
  • normalize_symbol_id has no other production consumer
  • the exhaustive reference test, explicit full-identity/Unicode controls, first-match control, missing-owner control, and 4,097-function cold index distinguish the material wrong implementations

proof observed:

  • Security and PR Plan succeeded at this head
  • formatting preflight succeeded on routed run 35688819508

proof/currentness still required:

  • current routed Required Rust gates remain in progress
  • ub-review remains in progress
  • branch must integrate current protected main and obtain fresh required checks on that integration object before leaving draft
  • installed nonempty cold-diff work/latency receipts remain outside this local source claim

nonclaims:

  • no removal of the linear function scan
  • no end-to-end latency or allocation-profile measurement
  • no semantic-unit/base-proof reuse
  • no release qualification

disposition: SOURCE_REVIEW_COMPLETE__KEEP_DRAFT_PENDING_CURRENT_MAIN_AND_HOSTED_PROOF

EffortlessSteven commented Sep 22, 2026 •

Copy link
Copy Markdown
Member Author

Source disposition at 9e86c65eb5687b4d7cd590a08eeacf875d4b60ea

The production change is semantically equivalent to the removed comparator:

left.replace('\\', "/") == right.replace('\\', "/")

is preserved by equal byte length plus pairwise equality where / and \\ are equivalent. ASCII separator replacement is length-preserving even when the surrounding ID contains multibyte UTF-8, and the surrounding ordered .find(...) is unchanged, so first-match behavior is retained. The independent 341-string/116,281-pair oracle, explicit path/suffix/case/Unicode controls, and 4,097-function lookup fixture distinguish the material regressions I would expect here.

At this head, formatting and Required Rust gates have passed; PR evidence is still running. No blocking source defect found.

The PR remains correctly REVIEW_INCOMPLETE because its integration basis predates protected-main #3839. Before ready/merge:

merge current protected main normally (no rewrite)
→ retain this exact one-file delta
→ obtain a fresh Ripr Rust Small Result at the integrated head
→ keep the end-to-end latency claim bounded to source-level allocation removal

This is useful downstream diff work, but it is not the whole-repository cold replay or semantic-reuse proof owned by #3795/#3796.

Finalization update (2026-09-24, head 0f2814da87e6068a2eff8a627c50410316922e13)

The pre-ready sequence above is complete at the rebased head:

  • Rebased/squashed onto protected main 532d379ae59c8f48c6e7ab4a91f09a4a809dd890; the one-file delta retained — owner.rs blob verified 278e4256f82b632dda38208c4b02906bb5975714, identical to the reviewed content.
  • Fresh routed Rust gates at the integrated head: run 35991332805 — Rust gates PASS (107605950571), Ripr Rust Small Result PASS, ub-review PASS. Advisory Droid Auto Review was still queued at update time.
  • Native local proof on Windows (toolchain 1.95.0): cargo fmt --check PASS, cargo check -p ripr PASS, cargo test -p ripr --lib analysis::classifier::owner 6 passed / 0 failed, cargo test -p ripr --test rust_include_compilation_unit 1 passed / 0 failed.
  • The latency claim stays bounded to source-level allocation removal; no end-to-end benchmark is claimed.

Main advanced three unrelated commits after the rebase (#3986, #3773, #4029); none touches owner.rs, so no restack was performed.

@EffortlessSteven
EffortlessSteven force-pushed the perf/cold-diff-owner-identity-3847 branch from 9e86c65 to 0f2814d Compare September 24, 2026 11:08
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 24, 2026 12:29
@EffortlessSteven
EffortlessSteven merged commit 998baff into main Sep 24, 2026
24 of 25 checks passed
@EffortlessSteven
EffortlessSteven deleted the perf/cold-diff-owner-identity-3847 branch September 24, 2026 12:34

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • new five-test suite is non-tautological, oracle-rich, and discriminates all four mutation controls called out in the PR body (raw equality, zip-only prefix, terminal-name, exact-first). Remaining residual: the parity corpus is depth-4 bounded and the 4,097-function stress fixture reuses the original probe fixture rather than swapping in a heterogeneous owner. Neither rises to a public blocker; both are bounded oracle-strength gaps a human reviewer can spot-check.

Verification questions

  • Confirm parity oracle depth-bounded to 4 concatenations of {a, /, , é} => 1 + 41 + 44 + 416 + 464 = 341 strings; this is sufficient but does not exercise empty-after-separator or trailing-separator corner cases.
  • Confirm wider crate scan (crates/ripr/src outside analysis) shows no related compression, runtime, or encoding helpers that would park as sibling follow-ups to this allocation-removal optimization.

Refuted

  • Length pre-check + pairwise zip makes the comparator provably equivalent to left.replace('\\','/') == right.replace('\\','/'); UTF-8 continuation bytes (≥0x80) cannot alias / (0x2F) or \\ (0x5C), so multibyte sequences survive untouched. No unsafe, no aliasing, no lifetime extension beyond the borrow passed into resolve_owner_function.
  • active-view/resizable-buffer UB: a transiently resized backing buffer could leave same_symbol_id comparing a stale len() against bytes(), causing silent prefix match across unequal lengths.; refuted because: Left and right are &str projected from owned String fields; they share a backing allocation that no other lane mutates, the surrounding .find is a sync iterator, and length is checked on the same projection used for the zip. No resizable JS/WASM/ASM buffer touches this comparator.
  • ASCII-only separator handling might misalign around multi-byte UTF-8 IDs (e.g., src\café.rs::値) and yield a false positive.; refuted because: UTF-8 continuation bytes (0x80–0xBF) cannot equal b'/' or b'\', so byte-level pairing remains aligned and length-preserving; the 341-string/116,281-pair oracle and the explicit 'src\café.rs::値' / 'src/café.rs::値' control distinguish this regression.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Review — head 0f2814d (rebuilt on current main)

Surfaces. crates/ripr/src/analysis/diff/* cold owner lookup.

What this PR does. Removes temporary string allocations from the cold diff owner-identity lookup (#3847) — borrows instead of building owned keys per hunk.

Stimulus/oracle. Diff-load tests pin identical owner identity before/after on the fixture corpus; allocation not asserted directly (behavior-parity is the oracle).

Validation. Ripr Rust Small Result: SUCCESS on 0f2814d.

Disposition: REVIEW_READY.

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