-
Notifications
You must be signed in to change notification settings - Fork 1.4k
impl gc finialized #6689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl gc finialized #6689
Conversation
|
Warning Rate limit exceeded@youknowone has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 28 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces a new garbage collection bits mechanism for free-threading by adding a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @crates/vm/src/object/core.rs:
- Around line 102-125: The set_gc_finalized() implementation does a non-atomic
read-modify-write using load + store on self.0.gc_bits which can lose concurrent
updates; replace that logic with an atomic fetch_or using
self.0.gc_bits.fetch_or(GcBits::FINALIZED.bits(), Relaxed) to set the finalized
bit safely. Also, if GcBits is not part of the VM public API, reduce its
visibility from pub to pub(crate) to limit its scope.
- Around line 811-829: The current set_gc_finalized implementation does a
non-atomic load then store and can clobber concurrent GC bit updates; replace
the load+store sequence in set_gc_finalized with an atomic read-modify-write
using gc_bits.fetch_or(..., Ordering::Relaxed) to set GcBits::FINALIZED without
losing other bits (use the same Ordering::Relaxed used in gc_finalized),
referencing the GcBits bitmask and the gc_bits field on the same struct so the
operation atomically ORs the FINALIZED bit in place.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/vm/src/object/core.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/vm/src/object/core.rs
🔇 Additional comments (4)
crates/vm/src/object/core.rs (4)
472-488:gc_bitsinitialization to 0 is correct and keeps construction straightforward.
No concerns with this initialization site (assuming otherPyInnerconstructors/initializers are updated similarly, whichinit_type_hierarchyis).
859-868: Finalized-guarded__del__call is a good CPython-aligned safety net; make it rely on atomic RMW.
The control-flow looks right (mark finalized before calling__del__to prevent reentrancy/double-finalize), but it depends onset_gc_finalized()being an atomic OR (see prior comment).
1324-1347: Type bootstrap:gc_bitsincluded inpartially_init!is correct.
This keeps the “all fields explicit” invariant for the unsafe bootstrap; good catch updating bothtype_type_ptrandobject_type_ptrinitializers.
131-145: No layout validation issues found. Thegc_bitsfield addition is safe because:
PyInner<T>has#[repr(C)], ensuring stable and well-defined memory layout- All offset and size calculations use compile-time macros (
offset_of!,size_of!) that automatically adjust to struct changes; no hard-coded offsets existSIZEOF_PYOBJECT_HEADis computed viasize_of::<PyInner<()>>(), which correctly includes the new fieldgc_bitsaccess patterns use proper atomic operations (load(Relaxed)), safe for concurrent accessThe concern about implicit offset/layout assumptions is not applicable here.
daec095 to
7f1a713
Compare
|
Code has been automatically formatted The code in this PR has been formatted using git pull origin gc-finalized |
* impl gc finialized * Auto-format: cargo fmt --all --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
helps #6410
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.