test: unflake the garbage collection tests - #1115
Merged
Merged
Conversation
`reapAndSettle` reaped once and ran a fixed three cranks before the test asserted, so it failed whenever the engine had not collected the dropped presence by the time `bringOutYourDead` ran. Reap until the kernel has recorded the drop instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The same fixed reap-then-three-cranks pattern gated the dropImports and retireImports assertions, so hoist `reapAndSettle` and use it there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Give `reapAndSettle` an options bag, wait on the full expected ref count rather than one field, and raise the `bringOutYourDead` test's timeout to 60s, which two 10-attempt reap loops can otherwise exhaust on a slow runner. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
rekmarks-consensys-1
force-pushed
the
rekm/unflake-gc-tests
branch
from
September 18, 2026 17:07
63eadb2 to
ef8aff1
Compare
sirtimid
approved these changes
Sep 18, 2026
Contributor
Coverage Report
File CoverageNo changed files found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Garbage Collection > an object shared by two importers > survives until both importers let goflakes in CI:The test reaped the importer vat once, ran a fixed three cranks, and then asserted. Whether an importer reports
dropImports/retireImportsduringbringOutYourDeaddepends on the engine having actually collected the dropped presence by that moment, and one round ofgc()does not guarantee that — a stale stack slot is enough to keep the presence alive for a pass. When it survived, the kernel still listed the importer.reapAndSettlenow takes anisSettledpredicate and re-reaps, up toMAX_REAP_ATTEMPTSrounds ofCRANKS_PER_REAPcranks, returning as soon as the kernel has recorded the drop.describeand applied it to thedropImportsandretireImportsassertions inshould trigger GC syscalls through bringOutYourDead, which used the same fixed pattern.Assertions are unchanged, so a genuine failure still reports the same diff rather than a timeout. Worst case adds ~30s to tests with 60s and 40s timeouts; the happy path is unaffected.
Instrumenting five local runs of the pre-change file showed the second importer needing three reap rounds in two of them and one to two rounds otherwise, so a single reap is measurably not enough. Six runs of the file after the change passed, and the package lints clean. Both were run before the rebase onto the better-sqlite3 13 bump on main; CI covers the post-rebase state.
🤖 Generated with Claude Code
Note
Low Risk
Test-only changes to timing and synchronization; no production kernel or GC behavior is modified.
Overview
Deflakes kernel garbage-collection tests by replacing a single
reapVatsplus three fixed cranks with a sharedreapAndSettlehelper that retries (up to 10 rounds, 3 cranks each) until anisSettledpredicate matches kernel state.The helper is hoisted to the top-level
Garbage Collectionsuite and wired intoshould trigger GC syscalls through bringOutYourDead(drop/retire import ref counts) andsurvives until both importers let go(importer list / ref counts). That test’s duplicate local helper is removed. The bringOutYourDead case timeout rises from 40s to 60s to cover worst-case retries; final assertions are unchanged.Reviewed by Cursor Bugbot for commit ef8aff1. Bugbot is set up for automated code reviews on this repo. Configure here.