fix(gc): stop the from-space scan reporting dead relocation stubs as offenders - #7182
Conversation
📝 WalkthroughWalkthroughThe from-space scanner now skips forwarded owners because they are dead relocation stubs. It counts skipped owners in ChangesFrom-space scan instrumentation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
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 `@crates/perry-runtime/src/gc/fromspace_scan.rs`:
- Around line 25-29: Update the documentation around scan_object to distinguish
the two skip paths: from-space owners return before the forwarded-owner check
and are not included in fwd_owners_skipped, while that counter only tracks
owners skipped because they carry GC_FLAG_FORWARDED.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b88f6f48-8251-433d-a1be-a37a39deb076
📒 Files selected for processing (3)
changelog.d/7182-fromspace-scan-forwarded-owners.mdcrates/perry-runtime/src/gc/fromspace_scan.rscrates/perry-runtime/src/gc/tests/fromspace_scan.rs
| //! its dead peers. So are owners carrying `GC_FLAG_FORWARDED` — a relocation | ||
| //! stub is dead for the same reason, one step further on, and unlike a | ||
| //! from-space object it can sit in old-gen where the space check does not reach | ||
| //! it. Both skips are counted (`fwd_owners_skipped=`) so a suppressed | ||
| //! population can never read as a fixed one. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the scan-count description.
Lines 25-29 say both skip populations are counted by fwd_owners_skipped. scan_object returns for is_from_space(owner_space) before it evaluates GC_FLAG_FORWARDED. The counter only represents owners skipped by the forwarded-owner predicate. State that distinction.
🤖 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 `@crates/perry-runtime/src/gc/fromspace_scan.rs` around lines 25 - 29, Update
the documentation around scan_object to distinguish the two skip paths:
from-space owners return before the forwarded-owner check and are not included
in fwd_owners_skipped, while that counter only tracks owners skipped because
they carry GC_FLAG_FORWARDED.
Summary
PERRY_GC_FROMSPACE_SCANskips owners that are themselves in from-space — they are about to be reclaimed, so a dead object legitimately still points at its dead peers. It did not skip owners carryingGC_FLAG_FORWARDED, which are dead for exactly the same reason one step further on, and which — unlike a from-space object — can sit in old-gen where the space check never reaches them. Old-gen defrag and array growth both leave such stubs behind, so every one of them was reported as an offender.Measured on a Perry-compiled zod workload, these were the single largest population in the residue after #7179: all at
2^k - 1element indices of repeatedly-grown arrays (the last element written before each capacity doubling), i.e. the stale copy of a growing array, reported once per growth generation. #7154's triage has been reading these counts.The skip is counted, not silent
A filter that shrinks the offender count without saying so reads exactly like progress, which is the failure mode this instrument exists to prevent (#6942, #7024). The count is in the report line so a suppressed population can never be mistaken for a fixed one.
Test
fromspace_scan_skips_but_counts_forwarded_owners_7154asserts both directions, in one test, against the same planted reference:forwarded_owners_skippedmoved.Sabotage (predicate removed): FAILED — "a FORWARDED owner is a dead relocation stub — its stale payload must not be reported as a missing rewrite". Green with the fix.
cargo test -p perry-runtime --lib gc::tests::fromspace_scan: 4 passed, 0 failed.Instrument only — no collector behaviour changes.
Refs #7154.
Summary by CodeRabbit
Bug Fixes
Tests