Disks and durability
What is this
How fast dlboard takes in what a training script logs is mostly how fast its metadata database can commit. A commit waits until the database’s log is on disk, so the disk under the database sets the pace.
On an SSD a commit takes a millisecond or a few. On spinning disks it takes as long as the disk needs to come round, and longer when other writes are queued ahead of it: traces of a NAS with spinning disks show a quarter of a second to a full second for one commit. Each batch a run ships waits for its commit, so the batches of every run of a server queue behind that disk.
This page says what to put where, how to measure it, and what you can trade if you have no SSD.
When you’d need this
- The database lives on spinning disks (a NAS, a RAID of hard drives, a network volume).
- Traces show a batch spending most of its time in
dlboard.store.commit(see telemetry). - Pages update seconds behind training while many runs log at once.
Put the database on an SSD
The database’s log is small and written in small synchronous writes, the access pattern a spinning disk is slowest at. Artifacts are the opposite: large files written once and read back whole, which spinning disks handle well.
| What | Where |
|---|---|
Postgres’s data directory, or at least its pg_wal |
An SSD |
SQLite’s file (DLBOARD_SQLITE_LOCATION) |
An SSD, on a local filesystem |
Filesystem artifacts (DLBOARD_ARTIFACT_STORE_LOCATION) |
Spinning disks are fine, ideally not the ones the database is on |
With the bundled docker-compose.yml, the dlboard-postgres volume is the data directory.
To keep the rest on spinning disks and only the log on an SSD, the official Postgres image’s POSTGRES_INITDB_WALDIR puts pg_wal in a directory of its own when the database is first created: mount an SSD there.
Keep SQLite off network filesystems (NFS, SMB) whatever the disk: its write-ahead log needs shared memory between the processes on one machine, which a network share does not provide.
Measure it
Postgres ships pg_test_fsync, which times the kind of write a commit waits for on the disk its test file is on, so point it into the data directory (it deletes the file when done):
docker compose exec -u postgres postgres pg_test_fsync -f /var/lib/postgresql/data/pg_test_fsync.out
Look at the fdatasync line under “Compare file sync methods using one 8kB write”.
An SSD does thousands a second; a spinning disk does at most a hundred or two.
That number is how many commits a second the database can make one after another, for every run of the server together.
In a trace, a batch’s dlboard.store.commit spans say the same thing from dlboard’s side: anything over a few milliseconds is the disk.
Trading durability for speed
Without an SSD, you can let commits stop waiting for the disk. Neither setting below can corrupt the database: what it can cost is the last moments of what the server had already accepted, if the machine or the database goes down before those reach the disk. A run’s client was told those batches were stored, so it does not send them again: they are gone from the charts. Both default to the database’s own behaviour, which waits.
dlboard already skips the wait where nothing logged is at stake: the bookkeeping after each batch (an experiment’s last activity, a run’s last contact) does not wait for the disk on Postgres, and the next batch puts it right if it is lost.
Postgres
DLBOARD_POSTGRES_SYNCHRONOUS_COMMIT=off makes every dlboard connection commit without waiting for the log to reach disk.
If Postgres itself crashes, or the machine loses power, the transactions of the last wal_writer_delay three times over (0.6 s by default) can be lost; a crash of dlboard alone loses nothing.
Each transaction is still kept or lost whole.
It applies to dlboard’s connections only, not to anything else using the same Postgres.
Setting synchronous_commit in postgresql.conf or with ALTER ROLE does the same from the database’s side; dlboard’s setting, when set, wins over both.
With many runs at once, Postgres’s own commit_delay (set in postgresql.conf, by a superuser) is a gentler trade: it makes a commit wait a few hundred microseconds for others to flush with, so one disk flush serves several.
It never loses a commit, and only helps when commits really do arrive together.
SQLite
DLBOARD_SQLITE_SYNCHRONOUS=NORMAL stops a commit waiting for SQLite’s write-ahead log to reach disk; SQLite flushes it at each checkpoint instead.
A crash of dlboard loses nothing.
If the operating system crashes or the machine loses power, the last commits can be rolled back.
Left unset, SQLite’s own default (FULL) waits for every commit.