Skip to content

Conversation

qinsoon
Copy link
Member

@qinsoon qinsoon commented Oct 29, 2024

This PR adds an alternative allocation functions alloc_with_options. The attached AllocationOptions change the allocation behavior, such as avoiding GCs and allowing overcommit.

Our current alloc functions assume they are GC safe points and will trigger GCs internally. A runtime may have different assumptions. We see GHC has allocateMightFail (https://gitlab.haskell.org/ghc/ghc/-/blob/90746a591919fc51a0ec9dec58d8f1c8397040e3/rts/sm/Storage.c?page=2#L1089). Also Julia assumes perm alloc will not trigger a GC (mmtk/mmtk-julia#172).
Having a variant of alloc that is not GC safepoints could be generally useful.

@qinsoon qinsoon marked this pull request as ready for review October 30, 2024 02:37
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 changed parts of the doc comments of alloc, alloc_no_gc, alloc_slow and alloc_slow_no_gc. Particularly, I rewrote the comment of alloc to make it more ordered.

@qinsoon
Copy link
Member Author

qinsoon commented Oct 30, 2024

I changed the documentation based on the suggestions.

/// normally without panicking or throwing exceptions, this function will return zero.
///
/// This function in most cases returns a valid memory address.
/// This function may return a zero address iif 1. MMTk attempts at least one GC,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// This function may return a zero address iif 1. MMTk attempts at least one GC,
/// This function may return a zero address if 1. MMTk attempts at least one GC,

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this paragraph should be removed.

@qinsoon qinsoon added the PR-extended-testing Run extended tests for the pull request label Oct 31, 2024
qinsoon and others added 2 commits November 1, 2024 15:01
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.

LGTM

@qinsoon
Copy link
Member Author

qinsoon commented Nov 1, 2024

I’m awaiting feedback from @JunmingZhao42 and Ben before merging this PR, as they requested this feature.

@qinsoon qinsoon changed the title Add alloc_no_gc Add alloc_with_options Feb 5, 2025
@wks
Copy link
Collaborator

wks commented May 9, 2025

I think this PR still looks good now.

@qinsoon qinsoon added this pull request to the merge queue May 9, 2025
Merged via the queue into mmtk:master with commit 8b32d04 May 9, 2025
31 of 33 checks passed
@qinsoon qinsoon deleted the alloc-no-gc branch May 9, 2025 06:42
qinsoon added a commit to qinsoon/mmtk-core that referenced this pull request Jun 3, 2025
commit 8a6cac2
Author: Yi Lin <qinsoon@gmail.com>
Date:   Wed May 21 05:36:29 2025 +0000

    Implement SpaceInspector for all policies

commit 10883f4
Author: Yi Lin <qinsoon@gmail.com>
Date:   Thu May 15 04:38:07 2025 +0000

    Introduce SpaceInspector and RegionInspector

commit c5ead72
Author: Yi Lin <qinsoon@gmail.com>
Date:   Mon May 12 12:42:14 2025 +1200

    Choose Non-moving Policy based on features (mmtk#1308)

    This PR uses an Immix space as the default non moving space, and adds
    two features to use mark sweep or immortal as the non moving space.
    * `Mutator` now includes 2 Immix allocators (one for Immix as the
    default space, and the other for Immix as the non moving space).
    * Call prepare/release/end_of_gc for the non moving space.
    * Add `common_prepare_func` and `common_release_func` for mutators.

commit 8b32d04
Author: Yi Lin <qinsoon@gmail.com>
Date:   Fri May 9 17:41:07 2025 +1200

    Add alloc_with_options (mmtk#1218)

    This PR adds an alternative allocation functions `alloc_with_options`.
    The attached `AllocationOptions` change the allocation behavior, such as
    avoiding GCs and allowing overcommit.

    Our current `alloc` functions assume they are GC safe points and will
    trigger GCs internally. A runtime may have different assumptions. We see
    GHC has `allocateMightFail`
    (https://gitlab.haskell.org/ghc/ghc/-/blob/90746a591919fc51a0ec9dec58d8f1c8397040e3/rts/sm/Storage.c?page=2#L1089).
    Also Julia assumes perm alloc will not trigger a GC
    (mmtk/mmtk-julia#172).
    Having a variant of `alloc` that is not GC safepoints could be generally
    useful.

    ---------

    Co-authored-by: Kunshan Wang <wks1986@gmail.com>
    Co-authored-by: Ben Gamari <ben@smart-cactus.org>

commit df7a1f1
Author: Yi Lin <qinsoon@gmail.com>
Date:   Thu May 8 15:31:41 2025 +1200

    Remove V8 tests from extended tests (mmtk#1313)

    This PR removes V8 tests from our extended tests for mmtk-core. The V8
    version we use in the binding is outdated, and the required environments
    are no longer supported by Github runners. See the discussion in [#ANU
    Research > The V8 binding is beyond repair @
    💬](https://mmtk.zulipchat.com/#narrow/channel/262677-ANU-Research/topic/The.20V8.20binding.20is.20beyond.20repair/near/509115086).
# for free to join this conversation on GitHub. Already have an account? # 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.

4 participants