Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guestEntryreplacesmain.main, so once it returns the guest process exits and the OS reclaims the entire address space regardless of GC state. A synchronousruntime.GC()here does a full stop-the-world mark/sweep whose only product is freed heap that is about to be discarded anyway — it adds teardown latency on everyRunwithout an observable benefit.The deterministic cleanup this seems aimed at is already handled inside
runGuest:defer unix.Close(3)and the deferredunmap()(munmap) run duringrunGuest's return, before control reaches this line. I confirmed there are noruntime.SetFinalizerregistrations in the productionstate/reflectxpackages, so GC won't trigger any observable finalizer cleanup either.The comment is also slightly inaccurate:
runGuestdoesn't explicitly "release its state graph" — the graph is a stack local that simply becomes unreachable on return; only the input mapping is explicitly released (viaunmap()).Suggestion: remove the
runtime.GC()call, or — if it's retained for a specific measured reason (e.g., heap-profile hygiene for tooling) — document that concrete reason and consider gating it so it doesn't run on the hot path.