Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track recognizable objects used by VOM so other objects can be GC'd #3409

Merged
merged 3 commits into from
Jun 28, 2021

Conversation

FUDCo
Copy link
Contributor

@FUDCo FUDCo commented Jun 25, 2021

This was surprisingly straightforward and made the GC noticeably more aggressive, at least in the tests that it affected.

I think it needs more tests targeted at this feature specifically, but I'm not sure how to construct them, so I'm creating the PR now to see if reviewing suggests some.

Closes #3161

@FUDCo FUDCo added enhancement New feature or request SwingSet package: SwingSet labels Jun 25, 2021
@FUDCo FUDCo requested a review from warner June 25, 2021 03:19
@FUDCo FUDCo self-assigned this Jun 25, 2021
Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes recommended. Looks great, and will have a huge impact. Nice!

Please also add a "closes #3161" to the commit comment.

* Presence as a key into a makeWeakStore() instance or an instance of
* VirtualObjectAwareWeakMap or VirtualObjectAwareWeakSet. We currently never
* remove anything from the set, but eventually we'll use refcounts to figure
* out when the vref becomes unrecognizable, allowing the vat do send a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "do send". a masterful homage to my original typo :)

/** @type {Set<string>} of vrefs */
const recognizableVrefs = new Set();

// XXX this function takes a value whereas its brethren (e.g.,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, because in the places that call this, they have a vkey but that's very much not the same thing as a vref.

Maybe we should refactor virtualObjectKey to take a vref instead? So the callers would do something like:

const vref = getSlotForVal(key);
const vkey = virtualObjectKey(vref);
if (vkey) {
  addRecognizablePresence(vref);
  otherstuff(vkey);
  ..

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of virtualObjectKey is converting between an object reference and a key string with a vref as the intermediate state on the way there. If it were to take a vref instead you'd just be adding some logic that would have to be replicated in a bunch of places. The way it's factored now is right, I think, aside from the misleading parallel between the naming of addReachablePresence and addRecognizablePresence, so I think the proper approach is to address the naming directly. I'm thinking addReachablePresenceRef and addRecognizablePresenceValue.

@@ -1188,12 +1188,13 @@ test('device transfer', async t => {
function getRefCounts() {
return kvStore.get(`${kref}.refCount`); // e.g. "1,1"
}
// XXX TODO: this comment should change, but I'm not 100% sure what the new text should say
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The device should hold a reachable+recognizable reference, and vat-left (which forgot about amy) does not contribute either form of refcount, making the expected count 1,1. If deviceKeeper..."

@warner
Copy link
Member

warner commented Jun 25, 2021

Oh, actually the behavior may change when we land the #3406 branch (more drops happening), so please hold off on landing this until that change has landed and we fix any tests that break when these two great changes get together for a retirement party.

@warner
Copy link
Member

warner commented Jun 25, 2021

Oh, actually the behavior may change when we land the #3406 branch (more drops happening), so please hold off on landing this until that change has landed and we fix any tests that break when these two great changes get together for a retirement party.

That commit (8eeec28) has landed, in PR #3416. Go ahead and test.

@FUDCo FUDCo force-pushed the 3161-vom-recognizance branch from b08e6f0 to 49e8bc7 Compare June 26, 2021 07:10
@FUDCo FUDCo enabled auto-merge June 26, 2021 07:12
@FUDCo FUDCo disabled auto-merge June 26, 2021 07:30
@FUDCo FUDCo requested a review from warner June 27, 2021 06:40
@FUDCo
Copy link
Contributor Author

FUDCo commented Jun 27, 2021

Changed one of the controller tests to make it less sensitive to GC variations, at the expense of checking less precisely. Please re-review to decide if this is acceptable.

Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's a shame to have to remove those checks, but they were kind of overspecified in the face of GC engine differences.

@warner
Copy link
Member

warner commented Jun 27, 2021

Do please modify the commit comments to include a reference to the bug number, so we can track it down from the git history later.

@FUDCo FUDCo force-pushed the 3161-vom-recognizance branch from ea8b6b1 to 2b1d0d4 Compare June 27, 2021 23:42
@FUDCo FUDCo enabled auto-merge June 27, 2021 23:43
@FUDCo FUDCo force-pushed the 3161-vom-recognizance branch from 2b1d0d4 to e59150d Compare June 28, 2021 00:09
@FUDCo FUDCo force-pushed the 3161-vom-recognizance branch from e59150d to 9be7dfc Compare June 28, 2021 01:24
@FUDCo FUDCo merged commit 628ef14 into master Jun 28, 2021
@FUDCo FUDCo deleted the 3161-vom-recognizance branch June 28, 2021 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VOM should track recognizable vrefs (conservatively), inhibit syscall.retireImport
2 participants