GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — [RFC] GC: Both Stop-the-World and On-the-fly · Issue #4158 · RustPython/RustPython Open Labels RFCRequest for commentsRequest for comments DescriptionDraft PR: #4180 SummaryI propose we implement a cycle collector for our rustPython RefCount garbage collection system based on Bacon etc.'s work in this two paper:
Detailed ExplanationThe synchronous cycle collector is easier to impl, I suggest we implement a synchronous verison of cycle collector for proof of Concept, then modfiy it to a On-the-Fly version. Synchronous Cycle CollectionThe algo in "Concurrent Cycle Collection in Reference Counted Systems" is O(N + E) wrost-case time for collection at most. For an object T in its' header there need fields denoted buffered(T), color(T),and RC(T). Where:
Pseudocode and ExplanationIn this section I just ref to paper because it explain much better than me, the basic idea is to first scan for possible cycles, then check for actual cycles:
There is also concurrent cycle collection, but that is not the main point today. Because the on-the-fly version is better both in performance and ease to implement. Efficient On-the-Fly Cycle CollectionThe basic idea is to use a "sliding view" method(which is a bit like "Copy on write"), and create a stable snapshot by adding a "LogPointer" to record the original status of object to create a virtual snapshot of the heap for cycle collection.
Data StructWe can use work in #2908 for object layout, and add two new feature: #![cfg(feature = "gc")] struct PyGcObject { header: PyGcHeader, obj: PyObject, //or directly use PyInner<Erased> } struct PyGcHeader { ref_cnt: RefCount, color: Color, #[cfg(feature = "on_the_fly_cc")] log_ptr: Option<LogPointer> // for on-the-fly dirty bit and pointer } And add a pub trait GcTrace { /// call tracer_fn for every GcOjbect owned by a dyn GcTrace Object /// # API Contract /// must make sure that every owned object is called with tracer_fn, or garbage collect won't act correctly. fn trace(&self, tracer_fn: &mut TracerFn); } /// A `TracerFn` is a callback function that is invoked for each `PyGcObjectRef` owned /// by an instance of something. pub type TracerFn<'a> = dyn FnMut(&mut PyGcObjectRef) + 'a; Drawbacks, Rationale, and AlternativesAlternative: impl #2908's CPython GC. Reacted by Jeong, YunWon, dennis zhuang, Lei, HUANG, Ning Sun, LFC, zyy17 and fanninpm Activity
MetadataMetadataAssigneesLabelsRFCRequest for commentsRequest for comments TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |