Testing incremental GC is difficult and confusing
Categories
(Core :: JavaScript: GC, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox69 | --- | affected |
People
(Reporter: jonco, Unassigned)
References
(Blocks 1 open bug)
Details
Right now the best way to run a GC until we get to the sweep phase is to do the following:
gczeal(0);
gczeal(10, 0);
gcslice(1000000);
assertEq(gcstate(), "Sweep");
We should find a way that this can be expressed naturally in test code. Either gcUntilSweep() or gcUntil("Sweep") would be far better.
I know there is also similar code in jsapi-tests, which should also be improved.
Comment 1•7 years ago
|
||
The test code I'll be landing in bug 1167452 might be a path towards doing this? For something very similar, it looks like
gczeal(0);
enqueueMark("enter-weak-marking-mode");
enqueueMark("yield");
gcslice(100000);
assertEq(gcstate(), "Sweep");
(This would work, because weak marking mode happens in the sweep phase.) If this is ok, I could add another token "enter-sweep" (or perhaps rename them both to "wait-for-" or "run-until-" or "gc-until-*" or something) that would yield at the beginning of sweeping.
Having gone down this road, I should warn that "sweep" is a little ambiguous -- you may be in the sweep phase, but you may not have reached the sweep group of the object you care about yet.
It's also a little bit cryptic here, because my original idea is that you'd be doing
enqueueMark(obj1);
enqueueMark(obj2);
and I only later realized that I needed to control when things happened with respect to the progress of the incremental GC. enqueueMark("yield") reads a little funny.
Comment 2•7 years ago
|
||
Sorry, that might have been confusing. Let me give an example of how I'm using this:
enqueueMark(map);
enqueueMark("yield");
enqueueMark(keyobj);
enqueueMark("yield");
keyobj = null;
gcslice(100000);
// We are now after the first yield, the key should not yet be marked.
gcslice(100000);
// We are now after the second yield, key is marked.
map.delete(nondeterministicGetWeakMapKeys(map)[0]); // Deletion should be barriered
finishgc();
On second thought, though, a general-purpose gcuntil() is probably better than relying on the enqueueMark() stuff. enqueueMark() is stateful; you have to remember to clear it out at the end of a test, or things will accumulate and you'll get very confused.
Updated•4 years ago
|
Updated•2 years ago
|
Description
•