Add GC levels to the test suite, and a valgrind docker image - #725
Open
flavorjones wants to merge 4 commits into
Open
Add GC levels to the test suite, and a valgrind docker image#725flavorjones wants to merge 4 commits into
flavorjones wants to merge 4 commits into
Conversation
The test suite ran only with the default GC behavior. Some classes of memory bugs need a GC cycle, GC compaction, or GC stress mode before they show themselves, and there was no way to ask for any of that while running the tests. `SQLITE3_TEST_GC_LEVEL`, ported from nokogiri's `NOKOGIRI_TEST_GC_LEVEL`, will choose how hard the suite leans on the GC. `normal` will keep the current behavior, `minor` and `major` will run a GC cycle after every test, `compact` and `verify` will also compact the heap and check the references afterwards, and `stress` will run every test with `GC.stress` set. The chosen level will apply to every test in the suite, and a level that the platform cannot support will fall back to `normal`. One test that measures throughput will be skipped under valgrind and under GC stress mode, where the environment is too slow to meet its bar. `CONTRIBUTING.md` will document the levels in a new section on debugging memory issues.
Running the test suite under valgrind required valgrind on the host system, and not every developer can install it. The `docker:dev` rake tasks will build an image that contains valgrind, then run the test suite in a container against the working copy. The image is a development tool, so it is not part of the gem package.
flavorjones
force-pushed
the
memory-stress
branch
from
August 6, 2026 23:16
7a390ac to
15c4258
Compare
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.
Two tools for tracking down memory bugs.
SQLITE3_TEST_GC_LEVELchooses how hard the test suite leans on the GC:normal,minor,major,compact,verify, orstress. It's a port of nokogiri'sNOKOGIRI_TEST_GC_LEVEL. On my machinecompactandverifyadd about two seconds to a 1.6 second run, andstresstakes 257 seconds.The
docker:devrake tasks build an image containing valgrind and run the suite in a container, for anyone who can't install valgrind on the host.CONTRIBUTING.mddocuments both in a new section on debugging memory issues.test_busy_handler_timeout_releases_gvlasserts a thread throughput floor, so it's skipped under valgrind and GC stress, where the environment is too slow to reach it.Nothing here runs in CI yet.