Skip to content

Native Mark-Sweep: block sweeping anomaly #824

Open
@chiarameiohas

Description

@chiarameiohas

Not all blocks seem to be swept in Mark-Sweep (at the end of the GC of eager-sweeping, or in between collections in lazy-sweeping).

allocated object points to an unallocated object

I am running my own GC code where we mark all referents of an allocated object (ex. object A is allocated and A->B and A->C, then B&C are the referents and will be marked).
I added an assertion that checks if we try to mark an unallocated object, and this assertion fails. This means that an allocated object points to an unallocated object (say A->B) ... this can happen only if the unallocated object (B) was freed in the previous collection and (A) was not freed (even though A was not marked). Although I didn't provide a detailed explanation of our GC algorithm, an allocated object should never point to an unallocated object. This assertion does not fail in Mark-Sweep, because any live object is also allocated, so we mark only allocated objects.

I also copied the mark bitmap to the alloc bitmap at the end of the collection, only then the assertion does not fail...which again makes me think that some blocks are not freed.
NOTE: the alloc bit of dead objects is zeroed while sweeping the block see

fn simple_sweep<VM: VMBinding>(&self) {
).

lazy sweeping sweeps more blocks than eager sweeping

Lazy-Sweeping sweeps more blocks in between collections than Eager-Sweeing at the end of a collection.
Additionally MS with eager-sweeping performs more collections than MS with lazy sweeping (I ran this multiple times to make sure it wasn't a one time wonder).

In a clean MMTK-core image (without my code) I printed how many blocks were swept: how many blocks called sweep in block.rs

pub fn sweep<VM: VMBinding>(&self) {

The logs below are from the dacapo biojava benchmark, running Mark-Sweep with a 1GB heap. I activated eager-sweeping by compiling with the eager_sweeping feature.

biojava_eager_1G.log
biojava_lazy_1G.log

Mark-Sweep with eager sweeping:

===== DaCapo evaluation-git-29a657f biojava starting =====
swept blocks 4658
swept blocks 1080
swept blocks 6241
swept blocks 2133
swept blocks 6258
swept blocks 2146
swept blocks 6264
swept blocks 2159
swept blocks 6269
swept blocks 2160
swept blocks 6289
swept blocks 2165
swept blocks 6281
swept blocks 2178
swept blocks 6291
swept blocks 2177
swept blocks 6309
swept blocks 2184
swept blocks 6305
============================ MMTk Statistics Totals ============================
GC	time.other	time.stw	total-work.time.max	total-work.count	total-work.time.total	total-work.time.min	
19	43128.16	1362.22	-inf	0	0.000	inf	

Mark-Sweep with lazy sweeping:

===== DaCapo evaluation-git-29a657f biojava starting =====
swept blocks 4430
swept blocks 7045
swept blocks 7818
swept blocks 7842
swept blocks 7838
swept blocks 7862
swept blocks 7854
swept blocks 7866
swept blocks 7860
swept blocks 7886
swept blocks 7877
swept blocks 7894
swept blocks 7892
swept blocks 7907
swept blocks 7895
============================ MMTk Statistics Totals ============================
GC	time.other	time.stw	total-work.count	total-work.time.total	total-work.time.max	total-work.time.min	
15	43686.47	1062.40	0	0.000	-inf	inf	

I am running mmtk-core with the Open-JDK binding.
MMTK-core version: 106fc71
MMTK-openjdk version: mmtk/mmtk-openjdk@57cdce3
I am using the dacapo 29a657f version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: BugP-normalPriority: Normal.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions