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

enable gc() in xsnap #2682

Closed
warner opened this issue Mar 19, 2021 · 0 comments · Fixed by #2683
Closed

enable gc() in xsnap #2682

warner opened this issue Mar 19, 2021 · 0 comments · Fixed by #2683
Assignees
Labels
enhancement New feature or request SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Mar 19, 2021

What is the Problem Being Solved?

To support #2615 , specifically the second half of #2660, we need to give liveslots access to a platform-level gc() function that forces a garbage collection.

Description of the Design

On Node.js, this involves calling node --enable-gc, and we'll have to figure out some way to make sure it gets invoked that way. For xsnap (our XS runner), we need to uncomment a few lines that are currently disabled.

This changes the snapshot format: it adds a new "callback" (host-provided C function) to the start-compartment global, which must be recognized during serialization (and attached to something during reload). So we should do this sooner rather than later.

Security Considerations

We wouldn't want to expose this to user-level code (not that they could do much with it other than slowing down performance), but SES should filter it out from the globals in all but the start compartment. We should probably have a test to ensure it doesn't appear on a child compartment global by mistake.

Test Plan

A unit test that invokes it and makes sure it doesn't crash. Other #2615 unit tests will probably depend upon this gc() actually doing something.

@warner warner added enhancement New feature or request SwingSet package: SwingSet labels Mar 19, 2021
@warner warner self-assigned this Mar 19, 2021
warner added a commit that referenced this issue Mar 19, 2021
Modify xsnap.c to add a `gc()` function to the globals of the
initial ("start") Compartment. This function should trigger an immediate,
synchronous, full GC sweep. As a non-standard global, the `gc()` function
will be filtered out of the globals in all child Compartments by SES as
usual.

Note that this changes the snapshot format: heap snapshots written before
this change cannot be read by code after this change. This happens because
`gc()` (which is implemented in C) is a new "callback" (a C function made
available to JS code), which is an "exit" from the reference graph. It must
be recognized during serialization, and re-attached during reload, and xsnap
cannot handle loading snapshots with a different set of exits, even purely
additive changes.

closes #2682
refs #2660
refs #2615
warner added a commit that referenced this issue Mar 19, 2021
Modify xsnap.c to add a `gc()` function to the globals of the
initial ("start") Compartment. This function should trigger an immediate,
synchronous, full GC sweep. As a non-standard global, the `gc()` function
will be filtered out of the globals in all child Compartments by SES as
usual.

Note that this changes the snapshot format: heap snapshots written before
this change cannot be read by code after this change. This happens because
`gc()` (which is implemented in C) is a new "callback" (a C function made
available to JS code), which is an "exit" from the reference graph. It must
be recognized during serialization, and re-attached during reload, and xsnap
cannot handle loading snapshots with a different set of exits, even purely
additive changes.

closes #2682
refs #2660
refs #2615
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 a pull request may close this issue.

1 participant