Skip to content
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

Do not move root objects #705

Closed
wants to merge 4 commits into from
Closed

Conversation

udesou
Copy link
Contributor

@udesou udesou commented Nov 25, 2022

This draft PR is an attempt to make sure that root objects should not move (at least for Immix in the current implementation). I've introduced a parameter KIND to PlanScanObjects and made it explicit in implementation of do_work_common, such that when creating process edges work, I pass TRACE_KIND_FAST which should make sure that the root objects are traced with trace_object_without_moving. I guess other plans that allow tracing/marking objects in place could use the same strategy.
A question here is whether objects would be transitively traced without moving; as far as I understand, it wouldn't, but perhaps @wenyuzhao knows the code a bit better.

let scanned_root_objects = self.roots().then(|| {
// We create an instance of E to use its `trace_object` method and its object queue.
let mut process_edges_work =
<PlanProcessEdges<E::VM, P, TRACE_KIND_FAST>>::new(vec![], false, mmtk);
Copy link
Member

Choose a reason for hiding this comment

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

This work packet is general for all the plans. TRACE_KIND_FAST is immix specific, and should not appear in general code.

@@ -869,15 +871,113 @@ impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> PlanScan
}
}

impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>> ScanObjectsWork<E::VM>
for PlanScanObjects<E, P>
impl<E: ProcessEdgesWork, P: Plan<VM = E::VM> + PlanTraceObject<E::VM>, const KIND: TraceKind>
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this const KIND: TraceKind parameter is not used.

let scanned_root_objects = self.roots().then(|| {
// We create an instance of E to use its `trace_object` method and its object queue.
let mut process_edges_work =
<PlanProcessEdges<E::VM, P, TRACE_KIND_FAST>>::new(vec![], false, mmtk);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we hard-coded TRACE_KIND_FAST instead of using the KIND type parameter in PlanScanObjects<E, P, KIND>. It is correct for Immix, but it needs to be extended to other plans, though.

<PlanProcessEdges<E::VM, P, TRACE_KIND_FAST>>::new(vec![], false, mmtk);

for object in buffer.iter().copied() {
let new_object = process_edges_work.trace_object(object);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here trace_object is a method of process_edges_work. Generally speaking the ProcessEdgesWork (along with its TraceKind if relevant) is provided by the Plan (at schedule_collection) But I think whether we pin the object is a different dimension. These pinning roots needs to pinned regardless whether it is a normal collection or a defrag collection, or whether it is a marking trace or forwarding trace. Probably it is better to add one more argument to trace_object itself, or add a different trace_object_pin method to SFT and PlanTraceObject.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In other words, TraceKind is local to a trace (should be part of TraceLocal which disappeared when we ported MMTk to Rust), while whether to pin or not is specific to this trace_object call.

@udesou udesou marked this pull request as draft November 30, 2022 00:39
@wks wks mentioned this pull request Jun 15, 2023
5 tasks
@qinsoon
Copy link
Member

qinsoon commented Jun 26, 2023

This PR basically duplicates ScanObjectsWork::do_work_common to PlanScanObjects::do_work_common, and if the objects are roots, use TRACE_KIND_FAST for them. In this case, if we create any work with RootsWorkFactory::create_process_node_roots_work, they will be traced with TRACE_KIND_FAST (which is non moving trace object in Immix).

@qinsoon
Copy link
Member

qinsoon commented Jun 26, 2023

As TRACE_KIND_FAST is internal to immix, this approach is not general. I think we can add a new method trace_object_non_moving to ProcessEdgesWork, and we call trace_object_non_moving() for root objects to ensure we do not move them.

@wks
Copy link
Collaborator

wks commented Jun 26, 2023

... we can add a new method trace_object_non_moving to ProcessEdgesWork, and we call trace_object_non_moving() for root objects to ensure we do not move them.

Yes. I agree. Currently, trait ProcessEdgesWork represents the capability of tracing objects (i.e. using SFT or PlanTraceObject to call the underlying trace_object of the space). If we are going to support read/black roots, we should augment this capability so that it can call trace_object_without_moving for each space, too. Spaces should provide trace_object_without_moving in addition to trace_object, or leave it unimplemented!() if unsuitable.

@k-sareen
Copy link
Collaborator

Superseded by #897

@k-sareen k-sareen closed this Oct 26, 2023
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.

4 participants