Skip to content

Conversation

@sirtimid
Copy link
Contributor

Closes #494

This PR implements a pin and an unpin method for vat root objects, that external code (tests, control panel) can call to keep a vat or arbitrary kernel object alive to ensure that references are counted.

A small reorganize of the kernel store methods was required and I added some tests that were missing.

@sirtimid sirtimid requested a review from a team as a code owner April 28, 2025 16:31
FUDCo
FUDCo previously approved these changes Apr 28, 2025
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

This looks very good but I do have one question raised below. I'm approving so you can go ahead and land the PR if your take on the question is to go with things as they are here, but please do at least give the matter some thought before pressing the big green button.

Comment on lines 31 to 37
const pinList = getPinnedObjects();
const pinned = new Set(pinList);
if (!pinned.has(kref)) {
incrementRefCount(kref, 'pin');
pinned.add(kref);
ctx.kv.set('pinnedObjects', [...pinned].sort().join(','));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is how SwingSet does it, but I think it's worth asking ourselves if we really want pinning to be boolean or not. In the implementation here, if two different, unrelated parts of the code each call pinObject (for their own reasons) it will still only get pinned once, and then if each later calls unpinObject, the object will be unpinned by the first call and subject to GC even though the second chunk of code might not yet be ready for that GC to happen.

This is probably an academic question since the primary use cases for pinning are tests and bootstrap vats, where in both cases pinning tends to be monotonic anyway, but I'd like us to at least think about the question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, your comment is valid, even more since SwingSet doesn't have an unpinObject method. Change done 582537a

Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

Ship it!

@sirtimid sirtimid enabled auto-merge (squash) April 29, 2025 19:02
@sirtimid sirtimid merged commit 8383fc3 into main Apr 29, 2025
21 checks passed
@sirtimid sirtimid deleted the sirtimid/pinned-vat-root branch April 29, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kernel: Add removable bootstrap keep‑alive pin

3 participants