Skip to content

Add GC levels to the test suite, and a valgrind docker image - #725

Open
flavorjones wants to merge 4 commits into
mainfrom
memory-stress
Open

Add GC levels to the test suite, and a valgrind docker image#725
flavorjones wants to merge 4 commits into
mainfrom
memory-stress

Conversation

@flavorjones

Copy link
Copy Markdown
Member

Two tools for tracking down memory bugs.

SQLITE3_TEST_GC_LEVEL chooses how hard the test suite leans on the GC: normal, minor, major, compact, verify, or stress. It's a port of nokogiri's NOKOGIRI_TEST_GC_LEVEL. On my machine compact and verify add about two seconds to a 1.6 second run, and stress takes 257 seconds.

The docker:dev rake tasks build an image containing valgrind and run the suite in a container, for anyone who can't install valgrind on the host.

CONTRIBUTING.md documents both in a new section on debugging memory issues.

test_busy_handler_timeout_releases_gvl asserts 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.

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.
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.

1 participant