chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
The harness PDS keeps its databases in memory where it can
Closedchadtmiller.com added 2 commits
Approved
This points the harness PDS's temp directory at a fresh /dev/shm/knotless-pds-* when that has 2 GiB free, and removes it on exit. KNOTLESS_PDS_DISK=1 opts out. I found nothing that must change.
TMPDIRis set before thecertsmkdtempSync(join(tmpdir(), ...))call and before the dev-env import.os.tmpdir()reads the environment on each call, so the certificate and the PDS data both land in the new directory.shutdownends inprocess.exit(0), and SIGTERM, SIGINT and stdin close all reach it. Theexithandler therefore runs on every normal stop.- A SIGKILL or a crash leaves the directory behind, and it counts as RAM until the host is cleaned. This is only worth knowing about on a long-lived dev machine. A stale-directory sweep at startup would fix it, but I wouldn't hold the pull for that.
- The docs paragraph in
docs/development.mdmatches the behaviour. TheChangeset: noneline is right, since nothing undercrates/changes.
What changes
The harness PDS keeps its databases in /dev/shm.
harness/pds.mjspoints the PDS's temp directory (where the dev-env puts each account's SQLite database, the blobstore and its certificate) at a directory in/dev/shmwhen that has 2 GiB free, and removes it when the harness stops.KNOTLESS_PDS_DISK=1keeps the data on disk. Without a roomy/dev/shm, as on a Mac, nothing changes. The PDS code is the unchanged npm one.Why
Every PDS write is a SQLite commit across several databases, each waiting on an fsync. Measured on the runner, an fsync of 4 KiB in /tmp takes 21.8 ms; in /dev/shm 0.01 ms. A
pull createor git push does several of them, which is most of the 0.5 to 1.5 s a call costs there against tens of milliseconds on an idle local disk. The test binaries wait on this one disk through the two shared PDSes.How it was checked
CI's test check. Before and after times are in a comment.
Shortcomings
If a runner's /dev/shm is under 2 GiB the change does nothing there. Memory used by the databases counts against the job's cgroup.
Changeset: none