Repository navigation
Halve the server tests' time: keep their data in memory, and compile Argon2 optimized - #296
Merged
Merged
Conversation
…Argon2 optimized A server test starts a server of its own, on SQLite and again on PostgreSQL, creates the first administrator and tears it all down. Timing one simple test's steps showed that nearly all of its 1.85 s was that, not the test: - The server syncs its key file, its SQLite database and the checkpoint at close to the disk: about 80 ms, 255 ms and 245 ms on a real disk, and under 4 ms together in memory. - Argon2 runs unoptimized in test builds: about a third of a second for each password hashed. So: - CI runs the server's tests with TMPDIR=/dev/shm, and keeps its PostgreSQL service's data on a tmpfs. - scripts/test-server-postgres.sh uses /dev/shm for its cluster and the tests' data where there is one, unless TMPDIR is set. - The dev profile compiles argon2 and blake2 at opt-level 3. Only the server depends on them. - docs/development.md says how to run the tests that way. Nothing in the server or its tests changes.
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.
The
servercheck spends about 7.5 minutes running tests. Almost none of that is the tests themselves.Where the time went
Each test starts a server of its own, on SQLite and again on PostgreSQL, creates the first administrator, and tears it all down. Timing the steps of one simple test (
tags_are_created_renamed_recolored_and_deleted, 1.85 s) on a real disk:With the temporary directory in memory, the key, open and close steps take under 4 ms together and the SQLite migration 29 ms. The Argon2 hash is slow only because test builds don't optimize it.
What changes
TMPDIR=/dev/shm, and keeps its PostgreSQL service's data on a tmpfs.scripts/test-server-postgres.shuses/dev/shmfor its cluster and the tests' data where there is one, unlessTMPDIRis set.argon2andblake2atopt-level = 3. Only the server depends on them, so no other build changes.docs/development.mdsays how to run the tests that way.Nothing in the server or its tests changes.
Measured in CI
This PR's
serverjob against #295's, both with a warm cache:cargo teststep (3 min 09 s of it is the build, both times)The PostgreSQL service started on its tmpfs and all 46 test binaries passed on both backends.
Measured locally
The whole suite in WSL, pinned to 4 cores as a CI runner has, SQLite and PostgreSQL (PostgreSQL with
fsync=offin every run):mainAll 719 tests passed in the last run.
sign_inwent from 45 s to 4 s, and most binaries now take 2–5 s.Left for later
realtime(48 s) andmonitors(26 s) are now almost a third of the run: severalrealtimetests wait on the server's real two-second reading spacing and five-second ticks. The test build (3 min) and Clippy are untouched.