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

Move some states from BasePlan to GlobalState #949

Merged
merged 14 commits into from
Oct 24, 2023

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Sep 8, 2023

This PR moves some states from BasePlan to a new struct GlobalState. Before this change, the states can only be accessed through Plan. Whoever needs to access those states need to acquire or store a reference to Plan, which is unnecessary. With the changes in the PR, GlobalState is stored as Arc<GlobalState>. It can be directly accessed through the MMTK instance, and can also be stored in some components, such as allocators. This change reduces the dependency on Plan.

@wks
Copy link
Collaborator

wks commented Sep 8, 2023

Nice work. This PR addressed some long-standing issues.

Issue #532: The last work item in that issue is moving GCRequester out of BasePlan. This PR will fix it.

Issue #587: That issue mentioned some fields that were accidentally added to BasePlan, but should be placed in MMTK or other global data structures. That includes initialized, options and gc_requester. This PR will fix those fields, too.

#587 (comment) also mentioned some previous static methods in JikesRVM MMTk. Those methods were in BasePlan, and this PR moves them to MMTK or GlobalState.

@qinsoon
Copy link
Member Author

qinsoon commented Sep 19, 2023

The refactoring seems to slow down the STW/GC time. I can't find an obvious reason that causes the slowdown. I will create separate PRs for a subset of changes, evaluate and merge them separately.

@qinsoon
Copy link
Member Author

qinsoon commented Oct 17, 2023

The PR does not seem to have any measurable performance difference. The following is the total time for 4 plans, SemiSpace, GenCopy, Immix and GenImmix. More details can be found in the link: plotty

SemiSpace

global-state-ss-total

GenCopy

global-state-gencopy-total

Immix

global-state-ix-total

GenImmix

global-state-genix-total

@qinsoon qinsoon marked this pull request as ready for review October 17, 2023 23:25
src/plan/global.rs Show resolved Hide resolved
// TODO: I don't know how this can be implemented when we have multiple MMTk instances.
// This function is used by space and phase to refer to the current plan.
// Possibly we should remove the use of this function, and remove this function?
fn global() -> &'static dyn Plan<VM = VM>;
Copy link
Member Author

Choose a reason for hiding this comment

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

I will update bindings for this change.

/// [`Plan`] instance that this allocator instance is associated with.
plan: &'static dyn Plan<VM = VM>,
context: Arc<AllocatorContext<VM>>,
_pad: usize,
Copy link
Member Author

Choose a reason for hiding this comment

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

I am currently use a padding field to make sure the size of the allocator types stays the same as before. I plan to remove this field, and update the bindings.

@qinsoon
Copy link
Member Author

qinsoon commented Oct 17, 2023

@wks Can you review this PR? I haven't created binding PRs for it, but I would like to get some reviews for the PR first. Updating bindings should be straightforward after that.

@qinsoon qinsoon requested a review from wks October 17, 2023 23:42
Copy link
Collaborator

@wks wks left a comment

Choose a reason for hiding this comment

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

The mmtk.h headers need to be updated to remove the modify_check functions.

src/mmtk.rs Show resolved Hide resolved
src/mmtk.rs Show resolved Hide resolved
src/mmtk.rs Show resolved Hide resolved
src/plan/global.rs Show resolved Hide resolved
src/util/alloc/allocator.rs Outdated Show resolved Hide resolved
src/util/alloc/allocator.rs Outdated Show resolved Hide resolved
src/util/alloc/free_list_allocator.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@wks wks left a comment

Choose a reason for hiding this comment

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

I have finished this pass of reviewing. Generally speaking this is a nice PR that solves some long-standing structural problems.

src/policy/immix/defrag.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@wks wks left a comment

Choose a reason for hiding this comment

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

The mmtk-core part looks good to me. Just ensure bindings are fixed as well.

@qinsoon
Copy link
Member Author

qinsoon commented Oct 19, 2023

This PR is not ready for merge. The binding PRs need to be ready, reviewed and approved before we can merge this PR.

@qinsoon
Copy link
Member Author

qinsoon commented Oct 20, 2023

binding-refs
OPENJDK_BINDING_REPO=qinsoon/mmtk-openjdk
OPENJDK_BINDING_REF=update-mmtk-core-pr-949
JIKESRVM_BINDING_REPO=qinsoon/mmtk-jikesrvm
JIKESRVM_BINDING_REF=update-mmtk-core-pr-949
V8_BINDING_REPO=qinsoon/mmtk-v8
V8_BINDING_REF=update-mmtk-core-pr-949
JULIA_BINDING_REPO=qinsoon/mmtk-julia
JULIA_BINDING_REF=update-mmtk-core-pr-949
RUBY_BINDING_REPO=qinsoon/mmtk-ruby
RUBY_BINDING_REF=update-mmtk-core-pr-949

@qinsoon qinsoon added the PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead) label Oct 22, 2023
@qinsoon qinsoon added this pull request to the merge queue Oct 24, 2023
Merged via the queue into mmtk:master with commit 57af17f Oct 24, 2023
25 of 26 checks passed
@qinsoon qinsoon deleted the refactor-global-state branch October 24, 2023 02:12
mmtkgc-bot added a commit to mmtk/mmtk-v8 that referenced this pull request Oct 24, 2023
Updates to mmtk/mmtk-core#949.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
mmtkgc-bot added a commit to mmtk/mmtk-ruby that referenced this pull request Oct 24, 2023
Updates to mmtk/mmtk-core#949

---------

Co-authored-by: mmtkgc-bot <[email protected]>
mmtkgc-bot added a commit to mmtk/mmtk-openjdk that referenced this pull request Oct 24, 2023
Updates to mmtk/mmtk-core#949.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
qinsoon added a commit to mmtk/mmtk-jikesrvm that referenced this pull request Oct 24, 2023
Updates to mmtk/mmtk-core#949.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
mmtkgc-bot added a commit to mmtk/mmtk-julia that referenced this pull request Oct 24, 2023
Updates to mmtk/mmtk-core#949.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
@wks wks mentioned this pull request Nov 22, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-testing Run binding tests for the pull request (deprecated: use PR-extended-testing instead)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants