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

Rename edge to slot #1134

Merged
merged 26 commits into from
May 22, 2024
Merged

Rename edge to slot #1134

merged 26 commits into from
May 22, 2024

Conversation

wks
Copy link
Collaborator

@wks wks commented May 13, 2024

This commit changes the term "edge" to "slot" where it actually refers to a field of an object or a variable on the stack or in any global data structures. Notably, the trait Edge is renamed to Slot, and related types and methods are renamed, too. We still use the term "edge" to refer to edges in the object graph, regardless whether the edge is represented by a slot or by an object reference pointing to the target.

The work packet trait ProcessEdgesWork and its implementations still use the term "edge". Although it was originally designed to process slots, it can be used (and is currently actually used) in node-enqueuing tracing as well as weak reference processing, in which case it is used as a provider of the trace_object method which traces object graph edges represented as ObjectReference to the target objects.

Note: This commit only does renaming, and does not change the program logic. The behavior of the program should be exactly the same after this change.

Fixes: #687

wks added a commit to wks/mmtk-openjdk that referenced this pull request May 16, 2024
wks added a commit to wks/mmtk-jikesrvm that referenced this pull request May 17, 2024
wks added a commit to wks/mmtk-ruby that referenced this pull request May 17, 2024
wks added a commit to wks/mmtk-julia that referenced this pull request May 17, 2024
wks added a commit to wks/mmtk-v8 that referenced this pull request May 17, 2024
@wks
Copy link
Collaborator Author

wks commented May 17, 2024

binding-refs
OPENJDK_BINDING_REPO=wks/mmtk-openjdk
OPENJDK_BINDING_REF=fix/edge-to-slot
JIKESRVM_BINDING_REPO=wks/mmtk-jikesrvm
JIKESRVM_BINDING_REF=fix/edge-to-slot
V8_BINDING_REPO=wks/mmtk-v8
V8_BINDING_REF=fix/edge-to-slot
RUBY_BINDING_REPO=wks/mmtk-ruby
RUBY_BINDING_REF=fix/edge-to-slot
JULIA_BINDING_REPO=wks/mmtk-julia
JULIA_BINDING_REF=fix/edge-to-slot

@wks
Copy link
Collaborator Author

wks commented May 17, 2024

The CI test Check broken links in docs / check-broken-links-in-docs (pull_request) complained that it cannot access https://docs.mmtk.io/api/mmtk/vm/slot/trait.Slot.html. That's expected because this type is just introduced (renamed from Edge), and has not been uploaded to docs.mmtk.io, yet.

@wks wks added the PR-extended-testing Run extended tests for the pull request label May 17, 2024
@wks wks marked this pull request as ready for review May 18, 2024 04:14
@wks
Copy link
Collaborator Author

wks commented May 18, 2024

@wks wks requested a review from qinsoon May 18, 2024 04:16
Copy link
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

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

We would like to rename trait Edge to trait Slot, as trait Edge was a misuse, and it always means slots. But we can still use the term 'edge' in many other places, when we actually mean edges.

For example, things like edges: Vec<Slot> make sense. edges: Vec<ObjectReference> also makes sense. But I am okay with slots: Vec<Slot>.

However, there are a few cases I think we went too far for renaming, e.g. having ProcessEdgesWork::process_slot rather than ProcessEdgesWork::process_edge, creating the term 'slot root' in create_process_slot_root_work. Based on the premise that the goal of this PR is to make the code easier to understand, my suggestion is that we do not do renaming unless the current code/comment is actually wrong/confusing. We can discuss case by case.

src/scheduler/gc_work.rs Show resolved Hide resolved
src/scheduler/gc_work.rs Show resolved Hide resolved
/// * `edges`: A vector of edges.
fn create_process_edge_roots_work(&mut self, edges: Vec<ES>);
/// * `slots`: A vector of slots.
fn create_process_slot_roots_work(&mut self, slots: Vec<SL>);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to create a term 'slot root'.

We can just call this create_process_roots_work. create_process_roots_work vs create_process_(t)pinning_roots_work makes sense.

If you really want to emphasise that it is processing slots, you can say create_process_root_slots_work. But I feel it is unnecessary.

Copy link
Collaborator Author

@wks wks May 20, 2024

Choose a reason for hiding this comment

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

That makes sense. "slot roots" is not the opposite of "pinning roots".

  • The opposite of "slot roots" (or root slots) is "node roots" (or root nodes), and we already have ProcessRootNodes.
  • The opposite of "pinning roots" is "non-pinning roots".

There is one missing piece of the puzzle: Root nodes that can actually be moved. The current RootsWorkFactory does not allow that, but I already anticipated that (See #710), and the Android binding (which @k-sareen is developing) needs that to scan and update stack roots and global roots. But the problem is, such roots cannot be given as a list of ObjectReference or a list of Slot (as ObjectReference alone cannot update the stack slots), so it will probably not be called create_process_root_nodes_work.

But I think we should keep the word "slots" in the function name so that we emphasize that it is just one way to deliver roots to mmtk-core, and it is a list of slots, and we can distinguish it from other functions (existing or introduced in the future) that does not represent roots as Slot. create_process_root_slots_work sounds good to me. I'll use that name in this PR. In the future, however, we may refactor the RootsWorkFactory again to address #710.

Copy link
Member

Choose a reason for hiding this comment

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

The other functions like create_process_(t)pinning_roots_work focus on the semantics of pinning/tpining, rather than how the roots are passed as arguments. It still feels strange as create_process_root_slots_work cares about the arguments rather than the semantics.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a bit subtle. The fact that a root is represented as Slot implies it can be updated (using slot.store. i.e. It's not pinned), and the fact that a root is represented as an ObjectReference implies it cannot be updated (i.e. pinned). create_process_roots_work is just too general because the word "roots" covers both pinning roots and non-pinning roots.

One way to reconcile is renaming the functions for nodes, too:

old new
create_process_edge_roots_work root_slots
create_process_pinning_roots_work pinning_root_nodes
create_process_tpinning_roots_work tpinning_root_nodes

(Lets' just omit the repeating create_process_ and _work.)

In this way, we mention both the form (slots / nodes) and the semantics (unrestricted / pinning / tpinning). What do you think about this?

Copy link
Member

@qinsoon qinsoon May 20, 2024

Choose a reason for hiding this comment

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

We should minimise changes to the existing interface. The only thing that needs to be fixed here is 'edge roots', which is a clear misnomer.

If we introduced the API in this PR, what you proposed would be okay. But for existing APIs, the changes seem unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

Then I think we can just go with create_process_slot_roots_work this time.

'slot root' is a new misnomer as well. If we change from one misnomer to another misnomer, we could just not do the change at all. In that case, at least we minimise changes to the existing interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then I'll change it to create_process_root_slots_work.

Copy link
Member

Choose a reason for hiding this comment

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

Then it is back to this question.

The other functions like create_process_(t)pinning_roots_work focus on the semantics of pinning/tpining, rather than how the roots are passed as arguments. It still feels strange as create_process_root_slots_work cares about the arguments rather than the semantics.

Copy link
Collaborator Author

@wks wks May 20, 2024

Choose a reason for hiding this comment

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

Then we have two solutions. One is renaming those functions, too, as I described, which resulted in the table in this comment. The other is leaving them unchanged for now. That's not ideal, but we minimise the change, and don't introduce new misnomers.

Copy link
Member

Choose a reason for hiding this comment

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

I am okay with the latter -- just leave it unchanged before we can have a good fix for it.

tools/tracing/performance/README.md Outdated Show resolved Hide resolved
wks added 2 commits May 20, 2024 13:52
Stop using "process_edges" to refer to the work packet. The work packet
name is ProcessEdgesWork, and the method name is process_slots.
Copy link
Member

@qinsoon qinsoon left a comment

Choose a reason for hiding this comment

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

LGTM

@qinsoon
Copy link
Member

qinsoon commented May 21, 2024

I have approved this PR and related binding PRs. We will need a section for this PR in the new migration guide. Depending on the merging order, we can add the section in this PR or in #1133.

@wks wks added this pull request to the merge queue May 22, 2024
Merged via the queue into mmtk:master with commit 56b2521 May 22, 2024
22 of 24 checks passed
@wks wks deleted the fix/edge-to-slot branch May 22, 2024 02:11
mmtkgc-bot added a commit to mmtk/mmtk-v8 that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
mmtkgc-bot added a commit to mmtk/mmtk-ruby that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
mmtkgc-bot added a commit to mmtk/mmtk-openjdk that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
mmtkgc-bot added a commit to mmtk/mmtk-jikesrvm that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
mmtkgc-bot added a commit to mmtk/mmtk-julia that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
mergify bot pushed a commit to mmtk/mmtk-julia that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
(cherry picked from commit e776c41)

# Conflicts:
#	mmtk/Cargo.lock
#	mmtk/Cargo.toml
#	mmtk/src/api.rs
#	mmtk/src/julia_scanning.rs
#	mmtk/src/lib.rs
#	mmtk/src/scanning.rs
#	mmtk/src/slots.rs
qinsoon pushed a commit to qinsoon/mmtk-julia that referenced this pull request May 22, 2024
Parent PR: mmtk/mmtk-core#1134

---------

Co-authored-by: mmtkgc-bot <mmtkgc.bot@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-extended-testing Run extended tests for the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we rename the Edge trait?
2 participants