Skip to content

Conversation

@sirtimid
Copy link
Contributor

@sirtimid sirtimid commented Mar 28, 2025

Closes #452

This PR adds reliable garbage collection and finalization capabilities to the kernel, enabling deterministic testing of GC-dependent behavior. swingset-liveslots expects a gcAndFinalize function to trigger GC and finalization when possible, using Node’s V8 capabilities (similar to Agoric’s implementation).

It also implements the previously missing final garbage collection logic. 🫣

An integration test has been added (not an end-to-end test, since GC is manually triggered via the new Kernel.reapVats() method).
You can observe the syscalls by running the test with verbosity:

yarn test packages/kernel-test/src/garbage-collection.test.ts --silent=false

which yields something like:

Screenshot 2025-04-02 at 20 34 16

Lastly, vats in the kernel-test folder were moved into a dedicated subfolder for better organization.

@sirtimid sirtimid changed the title feat: Sirtimid/trigger garbage collection feat: Add garbage collection finalization capability Mar 28, 2025
@sirtimid sirtimid self-assigned this Mar 28, 2025
@sirtimid sirtimid force-pushed the sirtimid/trigger-garbage-collection branch 2 times, most recently from d19cf9e to a78930f Compare April 2, 2025 18:27
@sirtimid sirtimid marked this pull request as ready for review April 2, 2025 18:37
@sirtimid sirtimid requested a review from a team as a code owner April 2, 2025 18:37
@MetaMask MetaMask deleted a comment from socket-security bot Apr 3, 2025
@sirtimid sirtimid requested a review from FUDCo April 3, 2025 12:50
@sirtimid sirtimid force-pushed the sirtimid/trigger-garbage-collection branch from c5c60fb to 3a88830 Compare April 4, 2025 17:59
@sirtimid sirtimid force-pushed the sirtimid/trigger-garbage-collection branch from 2b8c6b3 to d1d6e38 Compare April 7, 2025 13:17
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.

Awesome work!

@sirtimid sirtimid merged commit b061659 into main Apr 8, 2025
21 checks passed
@sirtimid sirtimid deleted the sirtimid/trigger-garbage-collection branch April 8, 2025 00:07
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.

Extend gctools with a functional gcAndFinalize and write E2E GC test

3 participants