Reintorduce gc_disable/enable API#1457
Draft
qinsoon wants to merge 2 commits into
Draft
Conversation
…g gap Bindings previously had to implement VMCollection::is_collection_enabled() and synchronize enabling/disabling collection across threads themselves. Replace that callback with disable_collection()/enable_collection()/ is_collection_enabled() on MMTK, backed by a nestable, lock-guarded counter in GCTrigger so a GC is never requested while collection is disabled. Also add wait_for_no_collection_in_progress(), which blocks until no GC is pending, mid-pause, or (for concurrent plans, via the existing ConcurrentPlan::concurrent_work_in_progress() hook) concurrently marking. Bindings that need a hard guarantee that no GC touches memory during some unsafe window (e.g. adopting a foreign thread, or recovering from a fatal signal) should call disable_collection() followed by wait_for_no_collection_in_progress(), the MMTk-native equivalent of waiting for an in-flight GC to finish. Without it, a collection that is already mid-cycle when collection is disabled is not affected until it completes, and for concurrent plans that includes the whole concurrent marking phase, not just a stop-the-world pause. Co-authored-by: Claude <noreply@anthropic.com>
79b14b1 to
3180d70
Compare
Poll with a yield instead of a fixed sleep between checks, so the calling thread gives up its timeslice without imposing a fixed latency floor on how quickly it notices the collection has finished. Add a regression test: one thread triggers a GC and blocks in block_for_gc (simulating an in-progress collection), while a second thread calls disable_collection() followed by wait_for_no_collection_in_progress() and must remain blocked until the first thread's GC finishes. Also fix two benchmarks (mock_bench/alloc.rs, mock_bench/internal_pointer.rs) that configured the now-removed MockVM::is_collection_enabled field to keep GC out of the way; they now call memory_manager::disable_collection() directly. Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.