Skip to content

perf(gc): use canonical layout bit in runtime class-field guards - #8076

Merged
proggeramlug merged 2 commits into
mainfrom
perf/5094-canonical-layout-next
Aug 14, 2026
Merged

perf(gc): use canonical layout bit in runtime class-field guards#8076
proggeramlug merged 2 commits into
mainfrom
perf/5094-canonical-layout-next

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • use the canonical typed-layout header bit for raw-f64 class-field get/set guards after the exact class, keys, and slot bounds are proven
  • retain the independent descriptor-map lookup under PERRY_VERIFY_TYPED_INTACT
  • add regression counters proving normal get/set guard paths perform zero descriptor queries

Refs #5094.

Performance

With PERRY_DISABLE_CLASS_FIELD_INLINE=1 to force every access through the runtime guard, 09_method_calls improved from a 649 ms median to 425 ms across 10 interleaved runs on a busy arm64 macOS host (1.53x, 34% faster). Output was identical. Normal inline mode is unchanged.

Validation

  • 2,314 release perry-runtime tests passed; 4 ignored
  • class-field raw-f64 downgrade matched Node with the runtime guard forced
  • forced evacuation stress: 6 copying minors, 15,771 moved objects, output matched Node
  • full mark-sweep output matched Node
  • PERRY_VERIFY_TYPED_INTACT output matched Node
  • cargo fmt check, diff check, and file-size check passed

No version bump.

Summary by CodeRabbit

  • Performance
    • Reduced overhead for class-field access by avoiding repeated metadata lookups during normal operation.
  • Reliability
    • Strengthened runtime validation for numeric class-field layouts, including safer handling of invalid or downgraded values.
    • Preserved additional verification checks in diagnostic configurations.
  • Documentation
    • Added a changelog entry describing the improved runtime safeguards and streamlined class-field access behavior.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bbbb68bb-34de-42ea-b8f0-6fe6b9501eaf

📥 Commits

Reviewing files that changed from the base of the PR and between 601a02d and b18d497.

📒 Files selected for processing (4)
  • changelog.d/8076-class-field-runtime-layout-guard.md
  • crates/perry-runtime/src/gc/layout.rs
  • crates/perry-runtime/src/typed_feedback/guards.rs
  • crates/perry-runtime/src/typed_feedback/tests.rs

📝 Walkthrough

Walkthrough

The runtime now validates raw-f64 class-field layouts through canonical typed-layout metadata. Normal guards use the per-object typed-intact bit, while verification mode checks the side table. Tests measure descriptor-query activity.

Changes

Raw-f64 class-field layout guards

Layer / File(s) Summary
Shared layout contract integration
crates/perry-runtime/src/typed_feedback/guards.rs
Class-field get, fast-get, and set guards use a shared raw-f64 layout contract. Normal execution uses the typed-intact bit. Verification mode checks the side-table slot and preserves the mismatch abort.
Descriptor-query observability and validation
crates/perry-runtime/src/gc/layout.rs, crates/perry-runtime/src/typed_feedback/tests.rs, changelog.d/8076-class-field-runtime-layout-guard.md
Test-only counters track typed raw-f64 descriptor queries. Tests verify zero queries for successful, downgraded, and rejected guard cases. The changelog records the runtime guard changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to b18d4

The PR optimizes runtime class-field guards while preserving behavior and adds regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related issues

  • PerryTS/perry issue 5094 — Removes per-access TLS descriptor lookups from the typed raw-f64 class-field guard path.

Possibly related PRs

  • PerryTS/perry#7423 — Adds sloppy-mode code generation for the related raw-f64 class-field inline store and guard path.
  • PerryTS/perry#7686 — Modifies typed class-field layout and slot handling in a related runtime path.
  • PerryTS/perry#7698 — Modifies typed class-field layout validation in related runtime and code-generation paths.

Suggested reviewers: thehypnoo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main runtime optimization for class-field guards.
Description check ✅ Passed The description covers the change, related issue, performance impact, validation results, and version policy, despite using different section headings.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/5094-canonical-layout-next

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.

@proggeramlug
proggeramlug marked this pull request as ready for review August 14, 2026 05:56
@proggeramlug
proggeramlug merged commit 78d0afa into main Aug 14, 2026
38 of 58 checks passed
@proggeramlug
proggeramlug deleted the perf/5094-canonical-layout-next branch August 14, 2026 07:35
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