Skip to content

Commit b1f0fac

Browse files
authored
Add an option to disable concurrent marking for concurrent immix (#1460)
1 parent cbfe1b0 commit b1f0fac

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/plan/concurrent/immix/global.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl<VM: VMBinding> Plan for ConcurrentImmix<VM> {
7575
return true;
7676
}
7777

78+
// Check stw for final mark
7879
let concurrent_marking_in_progress = self.concurrent_marking_in_progress();
79-
8080
if concurrent_marking_in_progress
8181
&& self.common.base.scheduler.work_buckets[WorkBucketStage::Concurrent].is_drained()
8282
{
@@ -86,6 +86,13 @@ impl<VM: VMBinding> Plan for ConcurrentImmix<VM> {
8686
return true;
8787
}
8888

89+
// Check stw for initial mark
90+
91+
// If concurrent marking is disbled, no need to check further.
92+
if self.concurrent_marking_is_disabled() {
93+
return false;
94+
}
95+
8996
let threshold = self.get_total_pages() >> 1;
9097
let used_pages_after_last_gc = self.common.base.global_state.get_used_pages_after_last_gc();
9198
let used_pages_now = self.get_used_pages();
@@ -99,6 +106,7 @@ impl<VM: VMBinding> Plan for ConcurrentImmix<VM> {
99106
debug_assert_ne!(self.previous_pause(), Some(Pause::InitialMark));
100107
return true;
101108
}
109+
102110
false
103111
}
104112

@@ -294,6 +302,10 @@ impl<VM: VMBinding> Plan for ConcurrentImmix<VM> {
294302

295303
impl<VM: VMBinding> ConcurrentImmix<VM> {
296304
pub fn new(args: CreateGeneralPlanArgs<VM>) -> Self {
305+
if *args.options.concurrent_immix_disable_concurrent_marking {
306+
warn!("Option 'concurrent_immix_disable_concurrent_marking' is set to true. Concurrent marking is disabled for ConcurrentImmix. This will make ConcurrentImmix behave exactly like full heap Immix.");
307+
}
308+
297309
let spec = crate::util::metadata::extract_side_metadata(&[
298310
*VM::VMObjectModel::GLOBAL_LOG_BIT_SPEC,
299311
]);
@@ -436,6 +448,13 @@ impl<VM: VMBinding> ConcurrentImmix<VM> {
436448
fn previous_pause(&self) -> Option<Pause> {
437449
self.previous_pause.load(Ordering::SeqCst)
438450
}
451+
452+
fn concurrent_marking_is_disabled(&self) -> bool {
453+
*self
454+
.base()
455+
.options
456+
.concurrent_immix_disable_concurrent_marking
457+
}
439458
}
440459

441460
impl<VM: VMBinding> ConcurrentPlan for ConcurrentImmix<VM> {

src/util/options.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,9 @@ options! {
964964
/// Percentage of heap size reserved for defragmentation.
965965
/// According to [this paper](https://doi.org/10.1145/1375581.1375586), Immix works well with
966966
/// headroom between 1% to 3% of the heap size.
967-
immix_defrag_headroom_percent: usize [|v: &usize| *v <= 50] = 2
967+
immix_defrag_headroom_percent: usize [|v: &usize| *v <= 50] = 2,
968+
/// Disable concurrent marking in ConcurrentImmix. Setting this to true will make ConcurrentImmix behave exactly like full heap Immix. This option is only intended for debugging.
969+
concurrent_immix_disable_concurrent_marking: bool [always_valid] = false
968970
}
969971

970972
#[cfg(test)]

0 commit comments

Comments
 (0)