racket / db

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default test configuration consumes huge amounts of memory

jackfirth opened this issue · comments

Running the tests/db/all-tests on a 15-inch 2012 macbook pro inside a Debian-based Docker container consumes over a gigabyte of memory. Is this expected behavior?

Steps to reproduce with the latest Racket snapshot version:

  1. Install a (very) recent version of Docker (including Docker Compose)
  2. Checkout the samth/docker-racket-build repository
  3. Run these commands from your checkout's root directory:
docker-compose build racket-x86
docker-compose build racket-x86-test
docker-compose run racket-x86-test racket -W "error debug@GC" -l tests/db/all-tests

For me, the sqlite, memory tests get up to about 850MB and the sqlite, memory, places = #t tests get to about 1.2 GB. Note that the latter goes very high and then drops back to a low number halfway through.

Unsurprisingly, the issue is text data in the sql-types tests. Here are GCs just in that test, with places = #f:

ttc: (quote (text))
GC: 0:MAJ @ 34,363K(+76,308K)[+5,976K]; free 25K(+23,350K) 56ms @ 1592
GC: 0:min @ 43,400K(+53,831K)[+5,984K]; free 9,045K(-9,045K) 0ms @ 1656
GC: 0:min @ 73,458K(+62,845K)[+5,984K]; free 31K(-31K) 0ms @ 1664
GC: 0:MAJ @ 83,196K(+63,155K)[+5,984K]; free 9,793K(-9,793K) 40ms @ 1696
GC: 0:min @ 112,473K(+73,222K)[+5,984K]; free 8K(-8K) 0ms @ 1756
GC: 0:min @ 503,097K(+73,510K)[+5,984K]; free 4K(-4K) 0ms @ 1808
GC: 0:MAJ @ 503,095K(+73,512K)[+5,984K]; free 78,130K(-68,194K) 56ms @ 1904
GC: 0:min @ 522,621K(+141,986K)[+5,984K]; free 97,656K(-97,656K) 0ms @ 2044
GC: 0:min @ 425,007K(+239,600K)[+5,984K]; free 41K(-41K) 0ms @ 2196
GC: 0:MAJ @ 815,601K(+239,646K)[+5,984K]; free 781,268K(+186,683K) 40ms @ 2396

(The last MAJ GC is explicitly invoked.)

And the answer is, unsurprisingly, that it creates a string of size 1e8 and tests that it round-trips via the database. Places appear to involve one extra copy of that string.

@rmculpepper How important is that test? Could it be half as large? Is the 1e7 test right before it sufficient?

@jackfirth How bad is the memory use here? Do we need to fix this?

@samth It's not a blocker for the docker release testing work. It's an annoyance and if it got worse Travis CI might complain, but I don't think this needs to be fixed anytime soon.

A test-memory config option akin to the test-timeout option could be a way to allow tests to specify high memory needs to test runners so they can figure out not to do things like run a bunch of memory-hungry tests in parallel.

I've disabled the test. 1e7 ought to be enough for anyone...

(IIRC, the 1e8 test is interesting primarily on mysql, since at the protocol level it involves "messages" split over multiple "packets", or something like that. But the test also relies on configuring the server to allow results that large, so it was fragile.)