Skip to content

Commit 5cebe7f

Browse files
committed
Add a feature immix_stress_copying
1 parent 0c4f9c3 commit 5cebe7f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ immix_non_moving = []
133133
# if `immix_non_moving` is in use.
134134
sticky_immix_non_moving_nursery = []
135135

136-
136+
# Turn on stress copying for Immix. This is a debug feature to test copying for Immix plans.
137+
immix_stress_copying = []
137138
# Reduce block size for ImmixSpace. This mitigates fragmentation when defrag is disabled.
138139
immix_smaller_block = []
139140
# Zero the unmarked lines after a GC cycle in immix. This helps debug untraced objects.

src/policy/immix/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub const BLOCK_ONLY: bool = false;
1717
/// Do we allow Immix to do defragmentation?
1818
pub const DEFRAG: bool = !cfg!(feature = "immix_non_moving"); // defrag if we are allowed to move.
1919

20-
// STRESS COPYING: Set the following options so that Immix will copy as many objects as possible.
20+
// STRESS COPYING: Set the feature 'immix_stress_copying' so that Immix will copy as many objects as possible.
2121
// Useful for debugging copying GC if you cannot use SemiSpace.
2222
//
2323
// | constant | when | value | comment |
@@ -32,15 +32,19 @@ pub const DEFRAG: bool = !cfg!(feature = "immix_non_moving"); // defrag if we ar
3232
// | `DEFRAG_HEADROOM_PERCENT` | stress | `50` | Reserve enough headroom to copy all objects. 50% is like SemiSpace. |
3333

3434
/// Make every GC a defragment GC. (for debugging)
35-
pub const STRESS_DEFRAG: bool = false;
35+
pub const STRESS_DEFRAG: bool = cfg!(feature = "immix_stress_copying");
3636

3737
/// Mark every allocated block as defragmentation source before GC. (for debugging)
38-
pub const DEFRAG_EVERY_BLOCK: bool = false;
38+
pub const DEFRAG_EVERY_BLOCK: bool = cfg!(feature = "immix_stress_copying");
3939

4040
/// Percentage of heap size reserved for defragmentation.
4141
/// According to [this paper](https://doi.org/10.1145/1375581.1375586), Immix works well with
4242
/// headroom between 1% to 3% of the heap size.
43-
pub const DEFRAG_HEADROOM_PERCENT: usize = 2;
43+
pub const DEFRAG_HEADROOM_PERCENT: usize = if cfg!(feature = "immix_stress_copying") {
44+
50
45+
} else {
46+
2
47+
};
4448

4549
/// If Immix is used as a nursery space, do we prefer copy?
4650
pub const PREFER_COPY_ON_NURSERY_GC: bool =

0 commit comments

Comments
 (0)