Skip to content

Only update reference if the object is actually moved? #574

Closed
@qinsoon

Description

@qinsoon

In the line in ProcessEdgesWork,

let new_object = self.trace_object(object);
if Self::OVERWRITE_REFERENCE {
unsafe { slot.store(new_object) };
}

we check a constant OVERWRITE_REFERENCE and write back the reference returned by trace_object(). OVERWRITE_REFERENCE
is defined per ProcessEdgesWork, which is currently per plan. In a copying plan, OVERWRITE_REFERENCE is true, and we always update references.

However, this means there are a few cases where we update references but we do not have to:

  • an object is in a non-copying space: e.g. objects in immortal or large object space in a copying plan
  • an object is in a copying space but in a particular trace, the policy is not moving objects: e.g. objects in an immix space in a non-defrag GC (non-moving), or objects in the mature immix space in generational immix for a non-defrag GC (nursery is still copying, but objects in mature space is non-moving for that GC).

We may want to check if this introduces any measurable overhead.

There could be different solutions if this brings any overhead:

  • Per policy per trace work packet. So OVERWRITE_REFERENCE is defined per policy per trace.
  • Check if new_object is the same as object before write. (conditional vs memory write).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions