Where the disk goes

This page measures where a Bongo node’s disk goes, per component, per message and per account, and sets the storage targets for the work that follows from it (smaller indexes, a smaller fixed cost per account, compact message bodies, a file layout that holds at scale). It is written from runs of loadgen storage; every figure below names the command that produced it.

Nothing here changes the server. The tool is in scripts/loadgen and uses the bulk loader, so it needs no running node.

How it is measured

loadgen storage loads fresh scratch data directories with the bulk loader (docs/load-testing.md, section 6), one per shape, walks each directory and classifies every file.

Why the bulk loader and not a running dev node. The dev role keeps its Raft log in a temporary directory and its snapshots in memory, so its layout is not the one a server has; and delivering a hundred thousand messages over SMTP takes too long to repeat. The bulk loader writes through the server’s own apply code (the FSM, the delivery stage, the SQLite and Bleve indexers), into the server role’s layout: pebble/, blobs/, metadata/users/{id}.db and metadata/system.db, search/users/{id}/ and search/gal/. That is what this page means by a fresh node.

Shapes. Five directories are loaded, each from the same plan (--seed 1, the default size mix of 2 KB to 1 MB, half of the messages large enough to carry one of eight pooled attachments):

Shape What it holds Why
baseline No accounts The cost of the node itself
empty Accounts with no mail The fixed cost of an account: (empty - baseline) / accounts
single Accounts with exactly one message What an account’s first message adds to an empty one: (single - empty) / accounts
small Many accounts, few messages each (5,000 x 10 at full scale) Per-account costs dominate
large Few accounts, many messages each (50 x 2,000 at full scale) Per-message costs dominate

The marginal cost of a message in a shape is what is left after the baseline and every account’s fixed cost, divided by the messages. One account alone would be lost in the noise (Pebble tables are shared), so the fixed cost is always measured over many and divided.

Classes. Every path is classified by where it sits in the data directory: blobs (the fan-out directories count with the files), pebble, sqlite_user (the main file), sqlite_user_wal and sqlite_user_shm, sqlite_system, bleve_user, bleve_gal, spool, raft_snapshots, markers and other. Nothing is dropped, so the classes always sum to the total. For every file the walk records the apparent size and the allocated size (blocks times 512, what du counts), and files and directories (inodes are files plus directories). It does not follow symlinks, and a file with several hard links counts once, by device and inode.

Three walks of each shape. open is taken after the index worker has drained and before the stores close, so the SQLite -wal and -shm files exist: it is the state a running server is in. closed is after the clean close, which checkpoints the WAL away; this is “as left”. compacted is after Pebble was reopened, flushed and compacted over its whole range. Pebble as left is dominated by its write-ahead log and level 0 tables; the compacted figure is where it settles, and is the one the targets are set from.

Raft log and spool. The loader applies every command at Raft index 0, so it writes no Raft log, and a walk would truthfully show none. A server writes one log entry per command, in the same Pebble database (key prefix _raft/log/). The tool therefore records the loader’s commands to a side file and replays them as log entries 1 to n through the server’s own RaftStore into a scratch Pebble directory, and measures that. The spool holds mail only while it is in flight (accepted but not yet delivered), so it is empty after a load and reads zero.

Compression estimate. Every blob is read, compressed in memory with the standard library’s compress/flate (default level) and with zstd (github.com/klauspost/compress/zstd, default level), decompressed and compared. Compressed sizes are also rounded up to whole blocks, because a 2 KB blob still takes 4 KB: that is the saving a disk would see. Speeds are per thread, from the time each call took. Nothing is written back.

Bleve comparison. The documents the FSM handed to the indexer for the first accounts of the large shape are captured while the load runs, and the tool builds throwaway indexes from them under variants of the server’s mapping: the current one, body Store off, term vectors off, and body and subject Store off with term vectors off (the likely end state of the index work). The mapping is read back from a loaded index, not copied, so the server’s mapping is not touched. Each variant is built batched (as the loader writes) and one document at a time (as the server writes), and its size is taken as closed and again after the index was reopened and left to finish its merges (“settled”). The comparison uses the settled size: scorch merges segments in the background, so a size taken at the moment of closing depends on which merges happened to be running.

Commands

The quick scale (100 empty accounts, 100 of one message, 200 of 10 messages, 5 of 200 messages), which took 3 minutes 45 seconds on the machine below:

make storage-report SCALE=quick OUT=storage-quick.json

which runs:

go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-out storage-quick.json

The run recorded as “medium” below uses the quick scale with larger shapes (1,000 empty accounts, 1,000 of one message, 1,000 of 10 messages, 10 of 1,000 messages) and 4 workers; it took 21 minutes:

go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-small-users 1000 --storage-small-messages 10 \
  --storage-large-users 10 --storage-large-messages 1000 --storage-empty-users 1000 \
  --storage-single-users 1000 --storage-workers 4 \
  --storage-out storage-medium.json --storage-summary storage-medium.txt

The full scale (5,000 accounts of 10 messages, 50 accounts of 2,000, 1,000 empty accounts, 1,000 of one message):

make storage-report SCALE=full OUT=storage-full.json

At the default plan a message costs 6 to 8 times its raw size on disk (section “Per message”), so the full scale would write about 27 GiB for the small shape and about 45 GiB for the large one (the per-message figures times 50,000 and 100,000 messages; this is an estimate, not a measurement) and takes hours. The tool refuses to start when the free space is below ten times the planned raw mail of the largest shape, and removes each shape’s directory after measuring it. The full scale was not run for this page: on the machine below, with 58 GiB free, the tool refuses it:

loadgen: storage: not enough free space: 57.85 GiB available, 71.77 GiB needed (10 times the planned raw mail)

Run it on a machine with the space (see “Not yet measured”).

To say it plainly: the full-scale run (5,000 x 10 and 50 x 2,000) has not been run. It needs about 72 GiB free. Every target on this page is set from the medium run on APFS (macOS); a full-scale run on Linux ext4 is a follow-up, and its figures replace these when it is done.

Memory. The recorded runs used 4 workers, the default of --storage-workers. More workers raise the memory the load needs and make SQLite contention likelier: the large shape needed retries on SQLITE_BUSY (the tool repeats a load with half the workers when that happens), and one load of the large shape at 8 workers was killed, most likely for lack of memory, on the 64 GiB machine below. The peak memory of a full-scale run has not been measured; plan for a machine with at least the memory of the one below, keep the default 4 workers, and watch the process’s resident size during the large shape.

Flags worth knowing, all with the storage- prefix: --storage-scale, --storage-*-users and --storage-*-messages to override a shape, --storage-work-dir, --storage-keep, --storage-bleve-users (accounts whose documents feed the Bleve comparison, default 2, 0 skips it), --storage-machine and --storage-filesystem to record what the tool cannot detect. The plan flags are those of seed and bulk; --users and --messages-per-user are refused, because the shapes set them. --body-text defaults to words here (see “Caveats”). The JSON report is the machine-readable form (schema_version 1); the summary is the same figures as fixed-width tables.

Machine and version

   
Bongo a build of the v0.18.0 tree (git describe: v0.18.0-dirty, the storage tool being the difference); the measurement uses the server’s own store code, unchanged
Go go1.27.4 darwin/arm64
Machine Apple M3 Max, 16 CPUs, 64 GiB memory
Operating system macOS (Darwin 27.2.0)
File system APFS, 4096-byte blocks (statfs)
Load other jobs may have run on the machine during both runs, so load rates are indicative only; sizes do not depend on it

APFS is not what a Linux server uses. It allocates nothing for a directory (every “fan-out directories take 0 B” below is APFS), syncs with F_FULLFSYNC, and may differ from ext4 or XFS in how it rounds small files. Linux ext4 figures are still to come for everything that depends on the file system: block rounding, directory blocks and inode use.

Two runs are recorded. The “quick” run is make storage-report SCALE=quick above; the “medium” run is the second command. Figures are from the medium run unless a sentence says quick. The quick run agrees with it within a few percent (the single-message shape differs more: 100 accounts draw a different sample of message sizes than 1,000 do). Sizes are allocated bytes (what the disk holds), taken after Pebble was compacted, unless they say “as left”.

Figures

Fixed cost of an account

Per account Medium (1,000 accounts) Quick (100 accounts)
With no mail, as left 1.44 KiB 2.28 KiB
With no mail, compacted 0.74 KiB 1.32 KiB
Per-user files of an account with no mail 0 0
First message added to an account with no mail 1.02 MiB, 5.0 files, 7.3 inodes 1.18 MiB, 5.1 files, 7.9 inodes

An account with no mail owns no SQLite file and no Bleve index: both are made when its first message arrives. Its whole cost is its Pebble keys (a profile, five mailbox records and an address record, 0.58 KiB before compression) and its share of two shared files (system.db 0.34 KiB, the GAL index 0.22 KiB). The first guess of the targets, under 100 KB, is therefore already met by more than a factor of 100.

The first message is where an account becomes expensive. Of the 1.02 MiB it adds in the medium run (a message of 79.5 KiB on average), 836 KiB is its Bleve index (3 files and 2 directories), 128 KiB is its SQLite file (1 file; the cost is the same whatever the message), 79 KiB is the message’s blob and 0.2 KiB its Pebble keys. Two fixed costs inside that, measured on their own in the same runs:

  • One per-user Bleve index under the current mapping is 260 KiB in 2 files with no document in it, and 264 KiB in 3 files with a single one-line message.
  • One per-user SQLite file is 128 KiB at its first message, and grows by about 0.8 KiB for each message after (9.36 MiB for 10 accounts of 1,000 messages).

So an account with any mail pays about 390 KiB before the mail itself is counted, and 7.3 inodes.

Per message

Shape Single (1,000 x 1) Small (1,000 x 10) Large (10 x 1,000)
Messages 1,000 10,000 10,000
Raw mail (before trace headers) 79.5 MiB 703.2 MiB 739.0 MiB
Disk (less the empty node) 1.00 GiB 5.42 GiB 4.56 GiB
Disk per message 1044.8 KiB 567.9 KiB 477.6 KiB
Disk per account 1.02 MiB 5.55 MiB 462.5 MiB
Disk to raw mail 12.83x 7.89x 6.31x
Files per message 5.01 1.40 1.01
Inodes per message 7.26 1.63 1.03
Files per account 5.0 14.0 1005.6
Inodes per account 7.3 16.3 1033.2

Command: the medium run. As left, before Pebble is compacted, the same figures are within 0.1% (568.2, 478.0 and 1045.9 KiB per message). “Raw mail” is the sum of the generated message sizes, before the trace headers the delivery stage adds; the ratio is disk over that. The quick run gave 555.3 KiB and 7.92x for 200 x 10, 497.3 KiB and 6.31x for 5 x 200, and 1205.1 KiB and 11.33x for 100 x 1. One earlier quick run of the large shape gave 7.05x: the Bleve indexes of a load are left with whatever merges were unfinished when the loader closed them, so the as-left size of that class moves by up to about 12% from run to run. The settled sizes in the Bleve comparison below do not.

Where a message’s disk goes (marginal cost: the shape less the empty node and less every account’s fixed cost, per message, compacted):

Per message Small Large
Bleve index (per-user) 484.4 KiB 402.5 KiB
Blobs 70.4 KiB 73.9 KiB
SQLite (per-user) 12.8 KiB 0.96 KiB
Pebble 0.21 KiB 0.21 KiB
Raft log (replayed, not in the walk) 0.35 KiB 0.29 KiB
Raw message (for reference) 72.0 KiB 75.7 KiB

The Bleve index is 85% of the disk of a message in both shapes, and the blobs about 13%. The SQLite figure of the small shape is the account’s 128 KiB spread over its 10 messages. The Raft log is not part of the node’s directory in a steady state (see below), so it is not in the total.

The classes of the whole directory, closed, in the medium run:

Class Small: files Small: allocated Large: files Large: allocated
blobs 10,008 (+258 dirs) 687.15 MiB 10,008 (+258 dirs) 721.60 MiB
pebble 9 5.87 MiB (2.26 compacted) 9 5.95 MiB (2.06 compacted)
sqlite_user 1,000 125.00 MiB 10 9.36 MiB
sqlite_user_wal and _shm 0 0 0 0
sqlite_system 1 384 KiB 1 48 KiB
bleve_user 3,000 (+2,002 dirs) 4.62 GiB 36 (+22 dirs) 3.84 GiB
bleve_gal 3 736 KiB 3 264 KiB
spool, raft_snapshots 0 0 0 0
total 14,022 files, 2,265 dirs 5.42 GiB 10,068 files, 285 dirs 4.56 GiB

SQLite with and without the WAL. With the stores open (the state a running server is in) the per-user databases of the small shape are 94.00 MiB of main files plus 226.94 MiB of -wal and 8.00 MiB of -shm: 328.94 MiB, against 125.00 MiB after the clean close checkpointed the WAL away. That is about 227 KiB of WAL for each open database after 10 messages; the large shape’s 10 databases hold 45.12 MiB of WAL, about 4.5 MiB each after 1,000 messages. The WAL goes at close, but nothing bounds it while the database is open.

Pebble

Pebble holds the metadata. Its logical content (key plus value bytes, before compression) in the small shape is 4.91 MiB in 27,000 keys; on disk it is 5.87 MiB as left (the write-ahead log and level 0 tables) and 2.26 MiB compacted.

Key class (small shape) Logical size
/user/{id}/mail/ (message metadata) 3295.2 KiB (337 B a message)
/user/{id}/mailbox/.../msg/ 1142.6 KiB (117 B a message)
/user/{id}/mailbox/.../meta, mailboxid 369.1 KiB (0.37 KiB an account)
/user/{id}/profile 128.9 KiB (132 B an account)
/system/address/ 94.7 KiB
total 5030.6 KiB

Pebble costs 0.21 KiB a message once compacted, and the as-left figure is 2.6 times that because of the write-ahead log, which is why the targets use the compacted one.

Raft log, snapshots and spool

The bulk loader writes no Raft log, so the figures here come from replaying the commands it applied (the medium run, through the server’s RaftStore):

  Per account created (empty shape) Per message, account creation included (small) Per message (large)
Entries 7 1.70 1.01
Payload 0.63 KiB 494 B 431 B
On disk as left 1.5 KiB 793 B 608 B
On disk compacted 0.41 KiB 349 B 293 B

The log is bounded in steady state, and the bound was measured by the soak in “Storage stays bounded (US-S4)” below. The server takes a snapshot every cluster.raft.snapshot_threshold entries (default 8,192, checked every snapshot_interval, default 120 s), and cluster.raft.trailing_logs entries are kept after it. The default for trailing_logs is unset, which leaves hashicorp/raft’s own 10,240 (raft.DefaultConfig). compactLogs in raft v1.8.0 removes entries up to the lesser of the snapshot index and the last index less TrailingLogs, so the log holds between trailing_logs and trailing_logs + snapshot_threshold entries: 10,240 to 18,432 at the defaults. The soak saw 10,240 to 17,671 entries at the defaults and 568 to 1,461 with snapshot_threshold 1,024 and trailing_logs 512 (bound 512 to 1,536). The comment on TrailingLogs and the startup warning in applyRaftTuning said the log never truncates when trailing_logs is not below snapshot_threshold; they are corrected.

A Raft snapshot is a full copy of Pebble, not a link to it: FSM.Snapshot takes a Pebble checkpoint into a temporary directory under os.TempDir, and fsmSnapshot.Persist writes that checkpoint as one tar file, raft-snapshots/<id>/state.bin, write-ahead log included, then removes the temporary directory. The loader writes none, so the figures above do not include them. The soak measured them: two finished snapshots on disk (raft keeps two), 13.1 MiB for the two at most in the medium run.

The spool holds mail only while it is in flight (accepted and not yet delivered). It is empty after every load, and reads zero.

Blobs

Small shape, medium run (the large shape’s blob store is alike: 10,008 files, 721.60 MiB allocated).

   
Files 10,008 (10,000 messages and 8 pooled attachments, which are stored once)
Apparent / allocated 667.90 MiB / 687.15 MiB
Per-file overhead (allocated less apparent) 19.25 MiB, 2.0 KiB a file, 2.8%
Fan-out directories 257 (256 two-hex-digit directories and the staging one), 0 B on APFS
Size Files Apparent Allocated
under 4 KiB 3,738 7.66 MiB 14.60 MiB
4 to 16 KiB 2,975 22.98 MiB 28.83 MiB
16 to 64 KiB 1,835 57.13 MiB 60.67 MiB
64 KiB and over 1,460 580.13 MiB 583.05 MiB

The files under 4 KiB are 37% of the files and 1.1% of the bytes, and carry 36% of the rounding overhead (6.94 of 19.25 MiB): each takes a whole block. Rounding is 2.8% of the blob store in this mix, so packing small blobs would save at most that much space (about 0.4% of the whole disk now); its case is the inode count, not the bytes. What a directory costs on ext4 (one block each, 4 KiB, so about 1 MiB for the blob fan-out) is still to be measured on Linux.

Compression estimate (all blobs of the small shape, read once and compressed in memory; speeds are per thread):

  Compressed Saving Compressed in blocks Saving in blocks Compress Decompress
flate (default) 291.08 MiB 56.4% 312.88 MiB 54.5% 93 MiB/s 184 MiB/s
zstd (default) 293.28 MiB 56.1% 315.29 MiB 54.1% 123 MiB/s 876 MiB/s

The 8 attachment blobs (random bytes) save nothing; the 10,000 message blobs save 56%. The two compressors save the same; zstd decompresses almost five times as fast (1 MiB in 1.1 ms against 5.4 ms) and compresses a third faster. The saving in blocks is what a disk would see: small blobs stay one block when compressed, which is why it is 2 points under the apparent saving. The large shape gives the same: zstd 56.1% and 54.2% in blocks, 127 and 893 MiB/s. This mix is synthetic text (see “Caveats”): real mail with HTML and embedded images will save less, so the figure to decide on is the one from a real corpus.

Bleve mapping comparison

Medium run: the documents of the first 2 accounts of the large shape, 2,000 documents with 137.29 MiB of indexed text (68.7 KiB a document), built under each variant. Sizes are allocated bytes after the index finished its merges.

Variant (batched, as the loader writes) Index, settled Against current Documents/s Text MiB/s
current mapping 782.09 MiB 1.00x 173 11.9
body Store off 695.37 MiB 0.89x 174 12.0
term vectors off 163.21 MiB 0.21x 349 24.0
body and subject Store off, term vectors off 71.86 MiB 0.09x 358 24.6
Variant (one document at a time, as the server writes; first 300 documents) Index, settled Against current Documents/s Text MiB/s
current mapping 101.08 MiB 1.00x 25 1.4
body Store off 89.54 MiB 0.89x 27 1.5
term vectors off 24.69 MiB 0.24x 31 1.8
body and subject Store off, term vectors off 12.13 MiB 0.12x 35 2.0

The quick run agrees on the ratios (0.89, 0.23 and 0.11 batched; 0.87, 0.26 and 0.15 one at a time). Findings:

  • Term vectors are the large cost: switching them off alone removes 79% of the index. Not storing the body removes 11% on its own, and with the subject’s store also off, on top of term vectors, the index is 0.09 of the current one.
  • Indexing one document at a time is 7 times slower than the loader’s batches (25 against 173 documents a second here). Term vectors off speeds both paths up (2 times batched, 1.3 times one at a time). The sizes of the two tables are not compared with each other: they hold different documents.
  • The tool’s rebuild of the “current” variant matches the loaded indexes of the same accounts within 0.7% (795.17 MiB against 800.75 MiB; 1.2% in the quick run), so the comparison is of the real thing.

Load rates (informational)

These rates are not the bulk loader’s throughput and must not be quoted as it. While loading, the storage tool also records every applied command to the Raft sidecar under one global mutex, so the workers serialise on that write; the JSON report carries load_rates_note next to each shape’s load, and the summary’s load line says the same. They are useful only to compare runs of this tool.

Rates as recorded, medium run, 4 workers, with other jobs running on the machine: small shape 49.9 messages/s while loading and then 265 s for the index worker to drain; large shape 147 messages/s and 3.5 s to drain; empty accounts about 10 per second (bcrypt dominates). For many small accounts the index worker, not the load, is the slow part.

Caveats

  • Bulk against the server. The loader writes through the server’s own apply code, but with Bleve documents in batches of 256 documents or 8 MiB, where the server indexes each message as it is delivered. The one-document-at-a-time rows above show the difference in speed. It also applies at Raft index 0, so it writes no Raft log or snapshot.
  • The text is synthetic. With --body-text words the bodies are pseudo-words drawn from a 30,000-word vocabulary with a Zipf frequency (exponent 1.07), which gives a term dictionary and a compression ratio nearer to real mail than the older random mode (random letters, nearly every word unique, which makes an index far larger and text far less compressible). It is still not mail. Attachments are random bytes and do not compress. A check against a real corpus is still to come, and the compression and index figures should be read with that in mind.
  • The plan is text-heavy. Message sizes are padded with body text, so the indexed text of a document averages 68.7 KiB against 72 to 76 KiB of raw mail: about nine tenths of the plan’s bytes are indexed text. Real mail, where large messages are mostly attachments, indexes less text per byte, so the Bleve share of the disk here is higher than a real mailbox would show, and the ratios to raw mail are not a prediction for real mail. They are comparable between runs of this plan, which is what the targets need. The plan also reuses 8 attachments, so deduplication is extreme (10,008 blobs for 10,000 messages).
  • One seed, one machine, one file system. Everything above is --seed 1 on one macOS machine with APFS.
  • Pebble as left and compacted differ. The as-left size is dominated by the write-ahead log and level 0 tables; the compacted one is where it settles. The targets below use compacted figures.
  • Allocated sizes. Blocks times 512 as the file system reports them. On a file system that compresses or inlines small files (some ZFS and Btrfs setups) they would be smaller.

The fixed cost of an account that has mail

The fixed cost of an account (the story after the figures above) is what an account’s SQLite file and Bleve index take before any mail is counted, and what its WAL does. Everything here is node-local: no Raft command, Pebble key or proto field changed, and an older binary opens the new files.

What changed.

  • Bleve page size. An empty per-user index is one bbolt file, root.bolt. bbolt sizes its pages from the operating system’s page size, which is 16 KiB on Apple Silicon (4 KiB on Linux amd64), and scorch gives it no key to override that. The index now sets bbolt’s package-level DefaultOptions to 4096-byte pages at start (internal/store/search.go, a process-wide setting of a third-party variable, like ldapauth and ber.MaxPacketLengthBytes; Bleve is the only bbolt user in the binary). That is where most of the 260 KiB went. An index made before keeps the page size in its file and still opens (a test rewrites one with 16 KiB pages and reopens it); only a rebuild or a new account gets the small file. On Linux amd64 the file was already built from 4 KiB pages, so this change is expected to save little there; that figure is not measured, and a kernel with larger pages (some arm64 builds use 64 KiB) would have given a larger file than the 260 KiB measured here.
  • SQLite page size. A new per-user database is created with 1024-byte pages (SQLite’s default is 4096). The schema is 23 tables and indexes, one page each, so it was 92 KiB before any row and is 27 KiB now. page_size in the DSN does nothing: the driver applies _pragma entries in lexicographic order, so journal_mode(WAL), which writes the header and fixes the page size, runs first. openSQLiteDB makes a missing file with a short connection that sets page_size and then WAL, and the tests read the size back with PRAGMA page_size. An existing database keeps its page size. This also reaches system.db when it is first created.
  • The WAL. journal_size_limit is 1 MiB and wal_autocheckpoint is 200 pages (default 1000). journal_size_limit alone does not bound an open database: it only truncates after a checkpoint has reset the log, which is why the checkpoint interval is lowered as well. UserIndex.Close runs PRAGMA wal_checkpoint(TRUNCATE) before closing, so eviction from the open-database cache (storage.max_open_user_dbs), CloseUser and Close all leave no WAL; a failed checkpoint is logged as index: user database wal checkpoint on close failed with the user id and error, and the database is closed anyway. SQLite itself deletes the WAL when the last connection closes, so the explicit checkpoint is the guarantee (the test holds a second connection open so that only the checkpoint can empty the log), not the main saving. The limit holds only while no reader holds an old snapshot: a long read transaction pins the log whatever the settings, and no test holds one. All of these are constants, not configuration.
  • Reads create nothing. Reading an account that has no mail used to create its SQLite file and Bleve index (a web list of the inbox or a search of a new account called acquire, which opens or creates). The read paths (QueryByType, QueryByTag, QueryByDateRange, MailPreviews, PendingPreviews, the header-view reads PendingHeaders, QueryToMe, QueryByParticipants, QueryByListID, QueryBySenders and ListGroups (so the summary page and /mail/view/* create nothing), Search, SearchContacts, SearchEvents, SearchWithRequest) now answer empty when the file or directory is not there and create nothing (acquireRead); pinning and Borrow are unchanged, because an absent file is decided before anything is opened or pinned. The header and preview backfill passes walk every account in the users table, empty ones included; they use BorrowRead, which answers a nil index (nothing pending) for an account with no file, so a pass creates none. An earlier version of this change used Borrow there, and every empty account then gained a 27 KiB SQLite file at the first pass (at start and every 30 minutes); TestBackfillsCreateNoDatabaseForEmptyAccount runs both passes over an empty account and pins that. Writes still create. A test pins that an account with no mail owns no file under metadata/users/ and search/users/ after every read, and gets them on its first message.
  • Bleve settings. Per-user indexes are created and opened with bleve.NewUsing and bleve.OpenUsing and a config (userIndexConfig): NumPersisterWorkers 1, which is also scorch’s default, so thousands of indexes do not each start several workers; opening existing indexes with it gives them the runtime settings too. The GAL index keeps the defaults but gets the page size. A test pins the literal map and the page size of a new index (read with bbolt, which is true on any OS). loadgen storage builds its comparison indexes through store.CreateUserIndex, so the comparison is of what the server builds.

What was measured and not kept. The merge policy and the persister’s nap time were tried on one account at a time, as the server writes (go test probes, go1.27.4, the machine below, APFS, shared with other jobs; 10 accounts, bodies of about 2 KiB, allocated bytes after close, three repeats at 10 messages and two at 100):

Per account 10 messages 100 messages
4 KiB pages, defaults 484, 516 and 546 KiB, 12.0 to 16.2 files 14.5 and 13.6 MiB, 84 to 93 files
MaxSegmentsPerTier and SegmentsPerMergeTask 3 452, 536 and 458 KiB, 10.4 to 14.4 files 9.1 and 12.2 MiB, 55 to 82 files
both 2 554, 484 and 407 KiB, 8.8 to 15.4 files 10.8 and 9.0 MiB, 75 to 96 files

A tighter plan saves between nothing and about a quarter at 100 messages, with the spread inside one setting as large as the difference between settings, because the merger runs on its own goroutine and the size depends on where it was when the index closed. Documents per second did not differ beyond that spread. It also made TestBulkLoadBatchedIndexMatchesPerMessage fail: that test compares term counts of a per-message and a batched load of one plan, and those counts include deleted documents until they merge, so a different merge plan moves them. The merge plan therefore stays at scorch’s defaults, and a zero PersisterNapTimeMSec was larger (527 KiB at 10 messages, one run), so it stays at the default too. A tuned plan would need a deterministic measurement (waiting for the merger to go idle before closing) that this tool does not have; that is recorded as a candidate, not claimed.

Page size against a large account. SQLite files of 5,000 messages in one account: 1,724 KiB with 4096-byte pages and 1,718 KiB with 1024-byte pages; 1,000 messages 424 and 363 KiB; 10 messages 92 and 29 KiB. At 20,000 messages 6,672 and 6,807 KiB (+2%). Insert rate of 5,000 messages in three repeats (messages per second): 4096 pages with the default checkpoint 6,267, 6,288 and 6,133; 1024 pages with the default checkpoint 7,483, 7,794 and 7,672; 1024 pages with 200-page checkpoints 7,013, 7,114 and 4,990. The lower checkpoint interval costs roughly 10% of the insert rate in the repeats that agree, and the smaller page does not cost anything measurable. An earlier single run at 1,000 and 20,000 messages swung from 750 to 7,700 messages per second between identical settings, so only the repeated figures are used.

Eviction under the manager lock. UserIndex.Close runs with the manager mutex held, as opening does. BenchmarkUserDatabaseEviction (two users alternating with max_open_user_dbs 1) gave 17 to 41 ms an operation without the checkpoint and 43 to 104 ms with it on the machine while a storage run was loading it; the runs were too noisy to say more than that the eviction is fsync-bound either way. SQLite’s own close already checkpoints and deletes the WAL, so the explicit TRUNCATE adds little to what close did before. Closing outside the lock was not done: it would touch the pin and refcount invariants that Borrow depends on, and the measured cost does not justify it. Re-measure on Linux.

Before and after, quick scale. Commands, run from the tree before and after the change:

go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-out storage-quick.json --storage-summary storage-quick.txt

Machine: Apple M3 Max, 16 CPUs, 64 GiB, macOS (Darwin 27.2.0), APFS with 4096-byte blocks, go1.27.4; the machine’s page size is 16 KiB (bbolt’s default there). Other jobs ran on it. Linux ext4 figures are still to come. Sizes are allocated bytes and repeated exactly between the two runs of each side; rates are not.

Quick scale (100 empty, 100 x 1, 200 x 10, 5 x 200) Before After
One per-user Bleve index, no document 260.0 KiB in 2 files 68.0 KiB in 2 files
One per-user Bleve index, one one-line message 264.0 KiB in 3 files 72.0 KiB in 3 files
One per-user SQLite file at its first message 128.0 KiB 28.0 KiB
Fixed cost of an account with mail (the two above) 392 KiB (128 + 264) 100 KiB (28 + 72)
Account with no mail, as left (compacted) 2.3 KiB (1.3 KiB) 1.8 KiB (0.8 KiB), no per-user file
First message (single shape), as left 1.18 MiB, 5.1 files, 7.9 inodes 911.5 KiB, 5.1 files, 7.9 inodes
Disk to raw mail, single (100 x 1) 11.32x 8.57x
Disk to raw mail, small (200 x 10) 7.93x 7.52x
Disk to raw mail, large (5 x 200) 6.29x (second run 7.82x) 6.30x
Per-user WAL, stores open, small shape 180.6 and 181.9 MiB (200 databases) 44.6 MiB (about 228 KiB each)
Per-user WAL, stores open, large shape 20.7 MiB (5 databases) 1.3 MiB
Per-user SQLite, clean close, small shape 25.0 MiB 7.0 MiB

Where the figures come from: before is storage-quick.txt of the tree at f571545f (two runs, 117.57 and 117.82 MiB for the single shape, 1.06 GiB for the small one); after is the same command on this change (two runs, 89.01 and 89.07 MiB, 1.01 GiB). The large shape’s Bleve size as left varies with where the merger was when the indexes closed (the second before run was 601.5 MiB), so its ratio is not a result of this change; the settled figures in “Bleve mapping comparison” are the ones to compare for index size.

Load rate (informational, see above). Messages per second while loading: small shape 31.5 and 40.2 before, 42.8 and 32.4 after; single shape 9.1 and 8.1 before, 7.1 and 7.8 after. The index worker drained the small shape more slowly in both runs after the change (95.6 and 77.6 s against 45.8 and 49.2 s) and the single shape too (20.1 and 29.6 s against 11.8 and 16.6 s). A store-level probe of the same writes (30 accounts of 10 messages, one at a time, three alternating runs of old and new settings) gave 2.0, 3.3 and 6.5 s of SQLite and 10.8, 15.6 and 23.8 s of Bleve for the new settings against 2.9, 12.6 and 4.5 s and 11.7, 35.6 and 22.5 s for the old: a spread of 10 times inside one setting on this machine while other jobs ran, so it neither shows nor excludes a slowdown, and a cause for the slower drain was not found. It needs a quiet machine and Linux before it is called noise.

Medium scale, after (1,000 empty, 1,000 x 1, 1,000 x 10, 10 x 1,000; storage-medium.txt command above, compared with the figures in “Figures”):

Medium Before (recorded above) After
Account with no mail, as left (compacted) 1.44 KiB (0.74 KiB) 1.5 KiB (864 B)
First message: SQLite 128 KiB 28.0 KiB
First message: Bleve index (message of 79.5 KiB) 836 KiB 644.2 KiB
First message, total 1.02 MiB 752.2 KiB, 5.0 files, 7.3 inodes
Small shape, disk per message 567.9 KiB (7.89x) 539.8 KiB (7.50x)
Small shape, per-user SQLite open (main + WAL) 329 MiB for 1,000 databases (227 MiB of it WAL) 94.6 MiB (52.5 MiB WAL)
Large shape, disk per message 477.6 KiB (6.31x) 514.4 KiB (6.80x)
Small shape, index drain 265 s 85.6 s

The large shape is larger by 7.7%: 1,000 messages in one account leave the index as-left to the merger, and two runs of the old code at quick scale differed by more than that (495.5 and 616.0 KiB a message). The drain figures are from different days and loads and are not comparable.

Against the targets. The account with no mail is 0.86 KiB with no per-user file (measured in a window before any backfill pass had run; the code now creates no file in a pass either, pinned by TestBackfillsCreateNoDatabaseForEmptyAccount, but the report was not re-run after the fix) (target 4 KiB, pinned by TestEmptyAccountCreatesNoPerUserFiles). The fixed cost of an account that has mail is 100 KiB at quick scale (28 + 72) and 96 KiB at medium (28 + 68): at the target of 100 KiB with no margin, on arm64 APFS, and not measured on Linux. Smaller bbolt pages were not tried (4 KiB is the page of a typical filesystem block), and 28 KiB of SQLite schema is the cost of keeping all 23 tables for every account; dropping or creating tables lazily was not done. The WAL of an open per-user database is bounded at about 200 KiB (200 pages of 1 KiB; 800 KiB for a database made before with 4 KiB pages, below the 1 MiB limit) and is gone after close (TestWALEmptyAfterClose, TestWALBoundedWhileOpen).

Tests: internal/store/fixedcost_test.go.

The search index stores no text (US-S2)

The per-user Bleve index used to store and term-vector every text field, so a message’s body and subject lived three times: in the blob, in the index’s stored fields and in its term vectors. The index answers “which documents match” and returns ids; display reads Pebble. It now keeps neither. The mapping is mailIndexMapping in internal/store/search.go.

The mapping

Field group Stored Term vectors Doc values Indexed
mail: subject, body, from, to, tags, date, has_attachment, spam_score no no no yes, as before
contact: display_name, email yes (SearchContacts returns them) no no yes
contact: phone, company no no no yes
event: title yes (SearchEvents returns it) no no yes
event: description, location, start_time, end_time no no no yes
GAL index (email, display_name) yes, unchanged unchanged unchanged unchanged

Index and IncludeInAll are untouched, so what is matched, and what the _all field holds, is as before. The mapping carries a comment that a sort, facet or highlighter needs Store and doc values back and a new store.MailIndexMappingVersion.

What was checked, and the result. A field needs term vectors only where a query matches phrases or positions.

Path Query Needs term vectors
Web search (SearchManager.Search) a query string only for a quoted phrase ("a b", subject:"a b")
IMAP SEARCH TEXT (buildBleveQuery, SearchWithRequest) a query string only for a quoted phrase
IMAP SEARCH SUBJECT, FROM, TO, BODY, other headers MatchQuery no
Participants (/search?participant=) SQLite, never Bleve no
Contact and event search a query string only for a quoted phrase
GAL search PrefixQuery no
Highlighting, sorting, facets none anywhere (a search of internal/, cmd/ and scripts/ for sort, facet and highlight use found none) no

So the only user of term vectors was a quoted phrase typed by a user. No existing test used one. Keeping term vectors on body and subject for it would keep most of the index (term vectors alone were 79% of it, see “Bleve mapping comparison”), so phrases are served another way:

  • A phrase is an all-words match (withoutPhrases, internal/store/search_mapping.go). Every user-text query (web search, contact search, event search, and any query string inside the IMAP request) is parsed, and each phrase becomes a match of all its words, in the same field with the same analyzer. A phrase therefore finds everything it found before, and may find more.
  • Behaviour change, recorded here on purpose. A quoted phrase now matches its words in any order and anywhere in the field. A negated phrase (-"a b") now excludes every message holding both words anywhere, which is more than it excluded. A parse error is returned as before, wrapped.
  • Not measured: what keeping term vectors on body and subject only would cost. The earlier comparison already bounds it, and no path above needs them.

The contact, event and GAL mappings. Contact and event documents share the user’s index; only the three fields the display paths read stay stored (display_name, email, title), the rest are indexed only. The GAL mapping is left as it is: both its fields are read by SearchGAL, its query is a prefix query that needs no positions, and the whole index is 264 to 736 KiB for a node, so a change would force a reset of the one global index for a negligible saving.

A tag change reads the blob

IndexMailPreservingBody carried the stored body over a tag-only re-index. With nothing stored it cannot work, and it is gone. The two tag paths (UpdateMessageTags and BulkTagAction) now call store.MailIndexContent(blobs, meta): one blob read and one MIME parse, the same body extraction delivery indexing uses (the function moved out of internal/cluster, which still wraps it with its log levels unchanged). If the blob cannot be read, or there is no blob store, the handler skips its own Bleve write and logs a warning with the user and message guid; it never indexes an empty body over a good document. The FSM’s index worker re-indexes the same MailMeta write from the same blob, so the handler’s write is a second write of the same document and a tag change now costs two blob reads and parses (the handler’s and the worker’s). Dropping the handler’s re-index is a candidate for PRD section 8.2.

The cost of the handler’s part, measured with BenchmarkMailIndexContent (warm file cache, plain text bodies, so the figure is the read, parse and text extraction):

go test -run '^$' -bench BenchmarkMailIndexContent -benchtime 2s -count 3 ./internal/store/
Message text Per message (3 runs) Bulk tag of 100 Bulk tag of 1,000
2 KiB 147 to 154 microseconds 15 ms 0.15 s
20 KiB 369 to 405 microseconds 37 to 41 ms 0.37 to 0.41 s
100 KiB 0.90 to 0.98 ms 90 to 98 ms 0.90 to 0.98 s
1 MiB 6.2 to 6.5 ms 0.62 to 0.65 s 6.2 to 6.5 s

The bulk endpoint has no cap on message_ids, so a bulk tag of N messages does N reads and parses inside one request. That is noted, not changed: a cap would be a new config key and is outside this story.

Existing indexes are rebuilt once

An index keeps the mapping it was created with, so a rebuild alone would change nothing. The mapping version is the file {data_dir}/search/users-mapping-version (current: 2; absent means 1). It is a file, not a Pebble key, so it never travels in a snapshot to a node whose indexes it says nothing about.

  • A fresh install (no file, no index directory) writes the current version, so the bulk loader’s data directories are current and are not wiped.
  • On the first start of this version, checkDerivedIndexes finds the version stale, logs fsm: rebuilding derived indexes: search mapping changed with the old and new versions, discards every per-user index (it waits for pinned ones, closes the open ones and replaces the directory; nothing is served from the old indexes, so their disk goes at once) and rebuilds from Pebble and the blobs. This happens even when the clean-shutdown marker matches.
  • The rebuild also re-indexes contacts and events into Bleve. Only the stores write those documents, so a wipe without it would empty compose autocomplete and calendar search.
  • It logs fsm rebuild: progress (users, mails, contacts, events, elapsed) every 10 seconds or 10,000 messages.
  • The version is marked current only at the successful end of the rebuild, so a crash part way rebuilds again at the next start. On a start that restores a snapshot the reset happens at once and the restore’s own rebuild recreates the indexes and marks the version.
  • The reset is in checkDerivedIndexes and never in NewSearchManager: an edge node opens the same manager and has nothing that would rebuild.

Search is unavailable while that start-up rebuild runs, and that is deliberate. checkDerivedIndexes is synchronous and runs before any listener opens, so no index answers anything during any rebuild. Serving from the old index until the new one is complete would need both on disk at once and a swap, and there are no users yet to protect (PRD section 6): the old index is discarded instead.

Rebuild rate, BenchmarkRebuildDerivedIndexes (10 accounts of 100 messages of 20 KiB of words, so 1,000 messages a pass; reset, then the whole rebuild, including SQLite and one Bleve document at a time):

go test -run '^$' -bench BenchmarkRebuildDerivedIndexes -benchtime 3x -count 2 ./internal/cluster/

The two runs gave 25.8 and 11.5 messages/s (38.8 s and 86.7 s a pass). The machine was shared with other jobs and the two runs differ by a factor of 2, so the range is what to read: for the medium shape’s 10,000 messages that is about 6.5 to 15 minutes of start-up. The rebuild indexes one document at a time; the bulk loader’s batches were 7 times faster per document in the earlier comparison, and batching the rebuild is the way to shorten this. It is not done here.

Figures

Machine and version as in “Machine and version” above: Apple M3 Max, macOS, APFS, go1.27.4 darwin/arm64, a build of the main tree with this change (“after”) against a build of the main tree without it (“before”). Linux ext4 figures are still to come. “Before” for the medium run is the run recorded above; “before” for the quick run is a fresh run of the unchanged tree, made for this story. The “after” figures are:

make storage-report SCALE=quick OUT=storage-quick-after.json
go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-small-users 1000 --storage-small-messages 10 \
  --storage-large-users 10 --storage-large-messages 1000 --storage-empty-users 1000 \
  --storage-single-users 1000 --storage-workers 4 \
  --storage-out storage-medium-after.json --storage-summary storage-medium-after.txt

The quick run took 3 minutes 24 seconds (4 minutes 57 seconds before); the medium run took 30 minutes.

Disk, medium run, compacted:

  Before After
Small shape (1,000 x 10): disk to raw mail 7.89x 2.85x
Small shape: disk per message 567.9 KiB 205.4 KiB
Small shape: Bleve per message (marginal) 484.4 KiB 121.9 KiB
Small shape: bleve_user class 4.62 GiB 1.16 GiB
Large shape (10 x 1,000): disk to raw mail 6.31x 1.37x
Large shape: disk per message 477.6 KiB 103.5 KiB
Large shape: Bleve per message (marginal) 402.5 KiB 28.5 KiB
Large shape: bleve_user class 3.84 GiB 277.88 MiB
Single shape (1,000 x 1): disk to raw mail 12.83x 7.70x
Single shape: disk per message 1044.8 KiB 627.1 KiB

The small and single shapes keep the 264 KiB a per-user index costs with no document in it, which is why they fall less than the large shape (the fixed cost of an account is a separate story).

Disk, quick run (before: a fresh run of the unchanged tree):

  Before After
Small shape (200 x 10): disk to raw mail 7.92x 2.88x
Large shape (5 x 200): disk to raw mail 6.28x 1.58x
Single shape (100 x 1): disk to raw mail 11.30x 6.40x
bleve_user class, small / large / single 924.28 / 407.05 / 94.45 MiB 234.20 / 45.45 / 43.29 MiB

The index against the current mapping (the target is at most 0.12x), settled sizes of the same documents:

  Before After Ratio
Medium, batched (2,000 documents) 782.09 MiB 55.70 MiB 0.071x
Medium, one document at a time (300) 101.08 MiB 10.84 MiB 0.107x
Quick, batched (400) 157.18 MiB 14.31 MiB 0.091x
Quick, one document at a time (200) 58.02 MiB 7.05 MiB 0.122x

The target is met at the medium scale. On the quick scale’s 200 documents the one-at-a-time ratio is 0.122x, 0.002 over: the sample is smaller and the fixed 260 KiB of an index weighs more in it.

What the report shows now, and what it does not. The storage tool takes the “current” mapping from a loaded index, so after this change “current” is the new mapping and the switches of the mapping comparison (body store off, term vectors off) are already off: its four variant rows are one mapping and read 1.00x. Their documents/s differ by up to 4.5 times between identical mappings (58 against 263 documents/s batched in the medium run) because the machine was shared with other jobs while it ran, so the variant rows’ speeds are not to be quoted. The comparison’s cross-check (loaded indexes against the tool’s rebuild) read 8.2% (medium) and 22.3% (quick), outside its 5% bound: the loader closes an index with unmerged segments, and a smaller index settles by a larger share. The settled column above is the comparable one.

Indexing speed. The only like-for-like figures are the two quick runs, made on the same shared machine, current mapping, settled: batched 137 documents/s before and 347 after (2.5 times); one document at a time 11 before and 35 after (3.2 times). The medium run before recorded 173 and 25; its after figures (58 and 14, with the noise above) are not comparable.

All of this is on APFS; ext4 will differ in block rounding and in how Scorch’s merges settle.

The file layout holds at scale (US-S6)

Before this story a node kept blobs at data/blobs/{2 hex}/{sha256} (256 directories), per-user SQLite at data/metadata/users/{user_id}.db with its -wal and -shm, and per-user Bleve at data/search/users/{user_id}/, all in one directory each. At 100 million blobs that is about 390,000 files in each blob directory, and 1 million users put 3 million entries in one metadata directory. This section records what changed, what it costs and what it does not cover. Everything here is per node: no Raft command, Pebble key or proto field changed, and blob sync is by hash, so it does not depend on the layout.

The layout

Files Path now Path before (still read)
Blob blobs/{h[0:2]}/{h[2:4]}/{sha256} blobs/{h[0:2]}/{sha256}
Per-user SQLite metadata/users/{b}/{user_id}.db, -wal, -shm metadata/users/{user_id}.db...
Per-user Bleve search/users/{b}/{user_id}/ search/users/{user_id}/

b is the first byte of sha256(user_id) in hex (store.UserBucket): 256 buckets, hashed so the spread does not depend on how ids are generated. One million users give about 11,700 SQLite entries and 3,900 index directories per bucket, against 3 million and 1 million in one directory.

Directories are made when a first file needs them, never all 65,536 up front. The legacy blob path sits in the same top directory as the new buckets: a 64-hex regular file under blobs/aa/ is a legacy blob, a two-hex directory is a bucket, and any other name (the tmp staging directory, the marker) is skipped. So no second root and no directory removal is needed.

What it costs. This is arithmetic, not a measurement, and it is not an ext4 figure. With n blobs spread evenly over the 65,536 second-level buckets the expected number of directories is 65,536 x (1 - e^(-n/65,536)):

Blobs Second-level directories Blobs per directory
10,000 (the medium run) 9,274 1.1
100,000 51,287 1.9
300,000 64,862 4.6
1,000,000 65,536 15.3
100,000,000 65,536 1,526 (390,625 before)

On ext4 each directory is an inode and at least one 4 KiB block. At the medium run’s 10,008 blobs that is about 9,300 more inodes (0.93 for each blob) and about 36 MiB, 5.3% of that run’s 687 MiB blob store. APFS allocates nothing for a directory, so the APFS runs on this page do not show the cost at all. It does not change the inode verdict below (bytes still run out first), and it is paid for the gain at scale: from about 300,000 blobs every bucket exists and the cost is fixed at 65,536 inodes and 256 MiB, while a directory holds a few thousand entries instead of hundreds of thousands. A node that will stay small gains nothing; the move is done now because no installation has to be migrated by hand and a later change would have to do it on a live system.

How it is moved, and what is safe

Reads follow both layouts, permanently. Get, Exists, Stat, Size, ModTime and Verify try the new path, then the legacy one, then the new one again (the third try covers the mover renaming the blob between the first two). Only a not-exist error moves on. The extra stat costs only on a miss, and blob sync’s Exists on a missing hash is the one frequent miss. There is no switch that turns the fallback off, and nothing outside BlobStore builds a data directory path: blob sync, restore (PutReader), export (FullRawMessage), the FSM and the GC all go through its methods. The backup format’s own path (blobs/{aa}/{sha256} in a backup directory) is a format, not the data layout, and did not change.

The blob mover (BlobStore.MigrateLayout, the storage-layout worker, on every node, not only the leader) walks the top directories in order and, for each legacy file, takes the store’s lock, renames it to the new path (a rename keeps the mtime) and releases the lock. The lock is the one the dedup touch and the GC’s conditional delete already share, so the three never interleave on one blob, and the 2026-08-30 argument still holds: a delete that wins the lock either removes the blob (a writer’s next Put finds none and rewrites it) or finds it already moved and removes that copy. If a writer already made the new copy, the mover gives the survivor the later mtime and removes the legacy one. Delete and DeleteIfNotModifiedSince look at both paths under the lock and, in the second, spare the blob if either copy is younger than the cutoff. The code never assumes one copy per hash. The lock is held for one blob, never across a directory; the pass pauses between directories and stops between them when the context ends. A directory read while entries are renamed out of it can skip some, so the pass repeats (at most four times) until a pass moves nothing, and only then writes blobs/layout-v2 (temp file and rename). The marker lets later starts skip the walk; it is not what makes the fallback safe.

Crash safety. A rename is atomic on one file system. A crash leaves a blob at its legacy path (still read), at its new path, or, if the directory entry was not yet synced, at both (the next pass keeps one). Nothing is deleted before its replacement exists, and the GC remains the only component that removes a blob for being unreferenced.

Per-user files move lazily. A user’s SQLite file or index directory moves when it is first opened, under the manager’s lock and only when it is not in the cache, so nobody holds a handle. A background pass moves the accounts nobody opens, one user per lock, in batches, with a pause between batches; startup time does not grow with users. Order, for SQLite: make the bucket, rename -wal, remove -shm (SQLite rebuilds the wal-index when no connection is open), rename the .db last. The .db rename is the commit point: a legacy .db always means “resume”, so a crash after any step converges and the WAL always travels with, or ahead of, its database. A search index moves with one directory rename. When a file exists at both places (an operator’s copy, or a downgrade and upgrade) the bucketed one is used, a warning is logged once per kind (SQLite, search) per process, and nothing is deleted. Such a conflict is not work left: the background pass counts it, finishes without retrying, and logs the counts once (storage-layout: users found at both the legacy and the bucketed path, with user_databases and search_indexes). A user id of exactly two hex characters is not supported by the search move (it would look like a bucket); ids are generated UUIDs. DeleteUser removes both locations.

Statistics. BlobStore.Stats is no longer a walk that stats every blob: it returns counters kept as blobs are written and removed, plus whether they are known yet. A store that was empty at start knows its totals; any other is seeded by the first walk (the storage-layout worker’s, then every GC pass re-seeds them). Between walks the figures are approximate: a rename that replaces an existing file is not seen. They feed /admin and the Prometheus gauges and are never used for a quota or any other decision. Before the first walk /admin shows an em dash.

The GC streams. BlobStore.Walk reads one directory in chunks of 1,024 entries, so a pass holds the reference set and the orphan candidates and never every stored hash, and ListBlobs and its slice of all hashes are gone from the pass. Memory is pinned by a test that walks 5,000 blobs in both layouts with a batch of 64 and asserts that no more than three batches (one per directory level) were ever held, not by timing; a second test holds the GC pass itself to the same bound (weak pointers to the walked hash strings, counted after a forced collection at checkpoints inside the walk), so a pass that collects every hash into a map fails it. The GC’s two-pass rule, the mtime cutoff and the re-validation against a fresh reference scan are unchanged. The walk is linear: go test -run '^$' -bench BlobWalk -benchtime 20x ./internal/store/ (go1.27.4, Apple M3 Max, APFS, warm cache) gave 124.9 ms for 5,000 blobs, 234.3 ms for 10,000 and 466.6 ms for 20,000, which is 1.88x and then 1.99x for each doubling, about 25 microseconds a blob. Extrapolated, not measured: 100 million blobs would take about 42 minutes of walking on this machine with a warm cache; a cold cache on a spinning disk will be slower.

Downgrade

An older binary cannot read this layout. It looks for a blob only at the one-level path, so it reports every moved message body as missing, and it opens an empty index for every moved user. Do not run an older binary on a data directory this version has started on. There is no tool that moves files back; restore a backup of the data directory taken before the upgrade, or upgrade again. No Raft state changed, so a cluster in which every node runs this version is unaffected, and a node running an older version beside it still agrees on every Pebble key. The release notes say the same.

Inodes: when they run out before bytes

The storage report now divides each shape’s allocated bytes by its inodes (files plus directories), less the empty node:

Shape (quick run, compacted, less the empty node) Disk per message Files per message Inodes per message Allocated bytes per inode On a default ext4
Single (100 x 1) 386.8 KiB 5.10 10.70 37,021 bytes run out first
Small (200 x 10) 173.4 KiB 1.41 2.86 62,131 bytes run out first
Large (5 x 200) 115.4 KiB 1.03 2.31 51,222 bytes run out first

Command, with this change in the tree (git describe: v0.18.0-23-gf2e0391e-dirty; go1.27.4 darwin/arm64, Apple M3 Max, macOS, APFS with 4096-byte blocks, 4 workers, one run on 2026-12-02):

go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-out storage-quick.json --storage-summary storage-quick.txt

These are not comparable line by line with the medium run above: the quick scale holds 2,000 messages in the small shape where the medium run held 10,000, and the index work (US-S2) and the SQLite and bbolt page sizes (US-S3) landed between the two. What this run does show is the cost of the two-level fan-out at a small store, read straight from the class table: the small shape has 2,008 blob files and 2,237 blob directories (257 before the change), so about one extra inode for each blob (0.99), and 137 SQLite and 538 index directories for its 200 accounts. That is why inodes per message are 2.86, 2.31 and 10.70 here against 1.63, 1.03 and 7.26 in the medium run. The arithmetic table above says the same thing in general: the extra inode per blob is about one at 10,000 blobs and falls as the store grows (0.51 at 100,000, 0.07 at 1,000,000).

The inode target of “Proposed targets” (at most 2 a message) is therefore not met by this layout in a small store, and is met only above roughly 500,000 blobs (from the small shape’s 1.86 inodes a message without blob directories, plus 65,536 x (1 - e^(-n/65,536)) / n for n blobs, which falls to 0.14 at about 465,000 blobs). Bytes still run out first on every shape by a factor of at least 2.2 (37,021 against 16,384 bytes per inode), so nothing breaks, but the move is a bet on scale and costs a small install about 1 inode and 4 KiB (ext4) per message.

Decision (accepted 2026-12-02): the two-level layout stays as built, and the small-store inode target is missed on purpose. Below roughly 500,000 blobs a store pays about 1 extra inode and 4 KiB (ext4) for each blob; past that the directories are shared widely enough that the target holds. An adaptive second level (turned on only past a size threshold, for example one bucket directory per 4,096 blobs) was considered and not built: the fixed layout keeps one path rule, and bytes still run out before inodes on every shape measured.

ext4 makes one inode for every 16,384 bytes of capacity by default (inode_ratio in /etc/mke2fs.conf; a distribution can change it, so read the file on the machine that is sized). A workload that allocates fewer bytes per inode than that runs out of inodes first. The storage report now computes this for every shape (allocated_bytes_per_inode and inodes_run_out_before_bytes_on_default_ext4 in the JSON, and a line in the summary). On these runs every shape is far above 16 KiB per inode, so bytes run out before inodes on a default ext4. The margin shrinks as the index shrinks (see “Proposed targets”), and a store of many tiny messages (a mailing-list archive) or of many empty accounts would be a different mix, so the guard below exists and the figure is re-measured on ext4. These are APFS figures; ext4 figures are still to come.

Low inodes

storage.min_free_inodes (default 100,000; 0 disables the check; restart class) is the free-inode count below which the node refuses the same new work as storage.min_free_mb: SMTP MAIL, IMAP APPEND, web compose and import, and DAV writes. The monitor is built when either threshold is above zero and samples both every 10 seconds, at once on start, so a node that starts without inodes refuses at once. min_free_mb = 0 alone therefore no longer turns the monitor off: with the default min_free_inodes it keeps running on inodes. Set both to 0 to disable it. It reads Ffree from statfs; a filesystem that reports no inode total (btrfs, for one) is skipped, and a statfs error fails open, as for bytes. The log line storage low carries free_inodes and threshold_inodes, and /admin shows a second banner naming inodes when inodes are the short resource. bongo_storage_low is 1 for either. A node already low on one resource logs the other as it runs short (storage low: free space below threshold too or storage low: free inodes below threshold too), and an INFO line when one clears while the other holds; storage recovered comes when both have.

Filesystem guidance

For a store of many small files on Linux:

  • ext4. The default (inode_ratio 16,384, from mke2fs.conf) is enough for the mixes measured here. For many small messages or many accounts make the file system with more inodes: mkfs.ext4 -i 8192 (one inode per 8 KiB) or -T news (one per 4 KiB). Inodes are fixed at mkfs; they cannot be added later. Check df -i beside df. Turn on dir_nlink (default in current e2fsprogs; tune2fs -l DEV | grep features) so a directory may hold more than 65,000 subdirectories, which the 256 x 256 blob fan-out and the user buckets stay under, and large_dir (tune2fs -O large_dir DEV, needs kernel 4.13 or later) so a directory may hold more than about 10 million entries and a 3-level htree. Neither the blob fan-out nor the user buckets need large_dir at the sizes in “The layout”; it matters only for an install that is still on the old layout at the top of the range.
  • XFS. Allocates inodes dynamically, so it does not run out of them before bytes (up to the maxpct limit, 25% of the space by default for file systems under 1 TiB). It is the simpler choice when inode count is the worry.
  • btrfs and ZFS have no inode table to exhaust; storage.min_free_inodes is skipped on btrfs.

The measured files per message are in the table above (APFS, quick run after the layout change): 5.10 for a single message on an account, 1.41 for 10 and 1.03 for 200, and inodes 10.70, 2.86 and 2.31. A capacity plan for a default ext4 is the larger of the bytes and 16 KiB times the inodes; at 2.86 inodes a message that is 46 KiB a message, under the 173 KiB a message uses in that shape.

Pack files: a study

The question is whether small messages should be appended to large pack files, as Dovecot mdbox and git packfiles do, with compaction after deletes. Building it is a separate decision; this is the case for and against, from the figures above.

Savings, from the medium run’s blob size histogram (small shape, 10,008 blobs; see “Blobs”). These are arithmetic on measured figures:

  Blobs under 4 KiB All blobs
Files (inodes) saved 3,738 of 16,287 inodes in the whole directory: 23% 10,007 (about 61%)
Block rounding saved 14.60 less 7.66 MiB = 6.94 MiB, 0.13% of the 5.42 GiB disk 19.25 MiB, 0.35% of the disk
Walk time of the GC the walk is 25 microseconds a blob (the benchmark above), so 37% fewer files is 37% less of it; a pack index lookup replaces a file stat  

The gain in bytes is rounding, and rounding is small: 0.13% of the disk for the blobs that would be packed. The gain in inodes is real (23%, or 61% if everything were packed) but inodes are not the scarce resource at these sizes (see above).

Costs. A pack index (hash to pack, offset, length) must live per node and be rebuilt from the packs, a second store beside Pebble and SQLite. The blob store’s rule that only the GC deletes a blob, and that it deletes by content hash, turns into compaction: dead space in a pack is only reclaimed by rewriting the pack, under a lock shared with readers, with the same two-pass and re-validation rules and a safe order of “write the new pack, switch the index, delete the old”. Blob sync, restore and export would read through the index, a crash between an append and its index entry needs a recovery scan, and dedup now has to look the index up. Every one of those is the subject of the 2026-08-30 incident class.

Recommendation: do not build it in 1.x. On the measured mixes it saves 0.13% of the disk and inodes are not the limit; the work is large and sits on the one code path that has lost a message before. Revisit if ext4 runs show inodes running out first, or if a real corpus has far more messages under 4 KiB than the 37% of this synthetic mix. Leave it to 2.0 with object storage (open question 8), where the blob store changes anyway.

Storage stays bounded (US-S4)

The question here is whether disk goes back down when mail is deleted, moved and expunged, and what a node should be sized for beyond the mail it holds. The answer is in three parts: a soak that drives deletes through the whole chain, a decision on how SQLite returns pages, and a per-component disk figure the server publishes. Every figure below is from a run on the machine in “Machine and version” (Apple M3 Max, macOS 27.2.1, APFS), from the command shown; the soak tables are from a build of 742959d4 (v0.18.0-42) with the Pebble split described below, the SQLite figures from v0.18.0-33-g47077a1b. Linux ext4 figures are still to come: block rounding, fsync cost and the time Pebble and Bleve take to settle may all differ there.

What the server reports

Every node samples the disk each component uses about 30 seconds after start and then every 10 minutes (constants, not config keys), on its own worker, and keeps the last answer. /admin (global admins only: a domain admin is redirected before any figure is loaded) shows it as a table with “measured N minutes ago”, and /metrics carries it as bongo_disk_bytes{component=...}, bongo_disk_usage_sampled_timestamp_seconds and bongo_raft_log_entries (docs/load-testing.md). A page view or a scrape reads the cached answer and never walks a directory; a test counts the walks across repeated requests. The sample is the only thing that walks metadata/, search/, spool/ and the snapshot directory, and it stops when the server shuts down.

All figures are allocated bytes (blocks times 512) and the components do not overlap:

Component How it is measured Notes
pebble Pebble’s own disk counter (tables, write-ahead log, manifests, obsolete files not yet deleted), minus raft_log includes the write-ahead log, live and closed-but-kept-for-reuse, so it climbs while memtables fill and need not fall at a flush. bongo_pebble_disk_bytes{part} splits the whole data Pebble into tables, tables_obsolete, wal, wal_obsolete and other from Pebble’s counters at scrape time, with bongo_pebble_wal_files and bongo_pebble_flushes_total beside it (docs/load-testing.md)
raft_log Pebble’s estimate for the _raft/log/ key range sstable bytes only: not the memtable or the log, so an under-estimate that moves in steps
raft_snapshots a walk of raft-snapshots/ each snapshot is a Pebble checkpoint tarred into one file, raft-snapshots/<id>/state.bin: a full copy of Pebble, write-ahead log included, sharing nothing with pebble/ on disk, so it is about the size of pebble and moves with it. Zero in the dev role (snapshots are in memory)
blobs the blob store’s own incremental counters absent until they are seeded, never a walk of the tree. File sizes as stored (after compression, if it is on), not blocks, so a little under the allocated figure
sqlite a walk of metadata/, -wal and -shm files included the write-ahead log of every open database is in here
search a walk of search/  
spool a walk of the spool  

The cross-check in each soak table below walks the data directory from outside (walkDataDir, the storage tool’s walker, which counts a hard link once across the whole directory) and agrees with the server’s figure exactly for sqlite and search, within 1% for pebble plus raft_log (10.40 against 10.54 MiB in round 1 of the medium run), and reads 9% to 11% higher for blobs (18.45 against 16.85 MiB in round 1 of the quick run, 134.1 against 120.8 in the medium run), because the server’s counters are file sizes and the walk counts blocks.

Pebble’s figure includes the write-ahead log, measured

TestPebbleDiskSpaceUsage (internal/store) writes 40 small keys with nothing flushed and shows the figure rising by at least their size while the table bytes stay zero; after a flush it shows a table written and the live log smaller. Pebble’s figure also counts a closed log (WAL.ObsoletePhysicalSize) until Pebble reuses it for a new log or deletes it, so a flush moves log bytes into the tables without freeing the old log.

The server now publishes the split, from Pebble’s in-memory counters at each scrape (bongo_pebble_disk_bytes{part}: tables, tables_obsolete, wal, wal_obsolete, other; bongo_pebble_wal_files{state}; bongo_pebble_flushes_total), and the soak records it every round. The parts add up to Pebble’s own figure (TestPebbleDiskParts, TestPebbleDiskPartsRealDatabase in internal/observability). The quick soak below shows what the pebble climb is (MiB, whole data Pebble):

round tables live log closed logs kept log files live / kept flushes
1 0.28 0.90 0.00 2 / 0 0
3 0.28 1.96 0.00 2 / 0 0
4 0.49 0.50 1.99 1 / 2 1
9 0.49 3.17 1.99 1 / 2 1
10 0.25 0.22 5.32 1 / 2 2
16 0.25 3.36 5.32 1 / 2 2

The tables stay between 0.25 and 0.49 MiB for all sixteen rounds; the climb is the log, about 0.53 MiB a round, which a flush moves into a table (round 4: the live log falls to 0.50 and the closed 1.99 MiB log is kept; round 10: the same with 5.32 MiB kept) without the total falling. The other part (manifest and options file) stayed under 0.01 MiB. So the reading in the earlier soaks, that the climb is the write-ahead log filling to a flush, is now measured.

The log is bounded by Pebble’s configuration, not by the mail: a memtable rotates to a new log at MemTableSize (4 MiB, Pebble v1’s default; Bongo sets neither option), at most MemTableStopWritesThreshold (2) memtables wait for a flush before writes stall, and a flushed log is kept for reuse by the log recycler (at most MemTableStopWritesThreshold + 1 = 3) or deleted. That is at most 6 log files of about 4 MiB: about 26 MiB with 10% for framing. The soaks peaked at 3 files and 8.68 MiB (quick) and 10.65 MiB (medium).

The soak

loadgen soak seeds the quick plan (20 accounts of 25 messages, the same plan as make bench), stops the server, and starts a copy of that data with storage.blob_gc = "on". It then runs rounds, each over IMAP, in every account in round 1 and in half of them (rotating) after that:

  1. move every second message of INBOX to a folder;
  2. mark every fourth message of INBOX deleted and expunge it;
  3. empty that folder completely;
  4. append fresh messages to INBOX until it holds its original count, and to the folder until it holds half that.

It waits for the server to deliver and index, waits four garbage collection intervals (three ticks are the chain: expunge, then the orphan metadata, then the blob, each pass needing the one before), and then waits for a disk sample the server took after that. Every message is new text, so it is a new blob. A component is bounded when its final size is at most 1.10 times its size after round 1 and at most 1.05 times its size one round earlier. The report also says whether a component is levelled: its last three rounds within 10% of each other. Only ratios are used.

pebble and raft_snapshots are judged on their parts when the server publishes them (soakPebbleVerdict, scripts/loadgen/soak_verdict.go). Their total holds the write-ahead log, which climbs until a flush and does not fall after it, so a round 1 taken before a flush is no baseline, and the total failed the test in every earlier run without anything growing. The parts are judged separately, and neither test is looser than the plain one on what it judges:

  • The log (live plus closed logs kept) must stay within its configured bound in every round: at most 6 files and about 26 MiB (above). A log that is not recycled or deleted exceeds it within a few memtables.
  • The data (tables, tables awaiting deletion and the manifest, less raft_log, which the entry count bounds) takes the 1.10x test against the first round with more flushes than round 1, when what the soak wrote has reached the tables. Its “still growing” test asks whether the final round is a new high, more than 1.05 times every round from that baseline on, rather than more than the round before: a flush adds a level 0 table and a later compaction folds it away, so the data saws (medium run: 1.31, 1.28, 1.24, 0.89, 1.21 MiB), and a fall followed by the next rise is not growth. A climb makes every round a new high and fails as before. A run with no flush after round 1, or with fewer than three rounds from that baseline, is not judged and does not pass: run more rounds.
  • Snapshots are judged the same way per snapshot from the tar headers of each state.bin (.sst tables, .log logs, the rest): the copied log against the same bound, the tables and manifest by the ratio test from the same baseline, and at most 2 finished snapshots on disk, which is what raft keeps.

TestSoakPebbleVerdict and TestSoakSnapshotVerdict hold the cases: the quick run’s shape passes on its parts and fails the plain test on its total; data growing after a flush, a new high at the end, a log above its file or byte bound, a third snapshot and growing snapshot tables all fail; a run with no flush after round 1 is not judged.

The soak needs a server built with the soakhooks tag, which makes the blob garbage collector’s interval and minimum age (a constant 15 minutes and 1 hour in a release) and the disk sample’s interval come from the environment: BONGO_SOAK_GC_INTERVAL, BONGO_SOAK_GC_MIN_AGE, BONGO_SOAK_DISK_INTERVAL. make soak builds that binary into a scratch directory and never as part of make build or make dist. Tests pin 15 minutes, 1 hour, 30 seconds and 10 minutes in the default build and fail if the tag appears in the Makefile outside the soak target, a Dockerfile, a workflow or a release script. The whole chain at production timings, with a short grace, is also run in-process (TestExpungeToBlobDeletionChain): a message with no mailbox entry loses its metadata on the second sighting, its blob is a candidate on the next pass and deleted on the one after, and Stats bytes fall.

Commands, from the repository root:

make soak SCALE=quick ROUNDS=16 OUT=soak-quick.json
make soak SCALE=medium ROUNDS=6 SOAKFLAGS="--soak-raft-threshold 0 --soak-raft-trailing 0" OUT=soak-medium.json
make soak SCALE=quick ROUNDS=6 SOAKFLAGS="--soak-max-open-indexes 2" OUT=soak-few-indexes.json

The first two use the garbage collector at 30 seconds and a minimum age of 1 minute, Raft snapshot_threshold 1,024 and trailing_logs 512 with a 10 second check (the first), and the server defaults (the second, 40 accounts of 100 messages). A round is about 3 minutes at the quick scale (16 rounds: 47 minutes) and 7 to 8 at the medium scale (46 minutes). Both ran on 742959d4 with the Pebble split, on 2026-12-03, with other jobs on the machine (sizes do not depend on it). The reports (JSON and Markdown) are not committed.

The numbers in the “start” row are the seeded data, before any round. The “of which log” column is wal plus wal_obsolete from the Pebble split (the whole data Pebble’s log, which pebble holds because raft_log is only sstable bytes).

Quick, 16 rounds (MiB):

round pebble of which log (live + kept) blobs sqlite search raft_log raft_snapshots snapshots on disk raft log entries
start 0.11 0.00 65.32 1.07 105.23 0.17 0.00 0 652
1 1.01 0.90 18.90 6.65 107.63 0.17 0.59 1 1,462
2 1.54 1.43 15.33 6.51 73.08 0.17 1.97 2 1,124
3 2.07 1.96 14.13 6.54 57.09 0.17 3.43 2 916
4 2.73 2.50 10.75 6.37 41.81 0.26 2.98 2 764
5 3.27 3.03 10.19 6.37 26.62 0.26 2.44 2 596
6 3.80 3.56 10.17 6.42 24.57 0.26 2.44 2 1,487
7 4.33 4.09 10.18 6.41 23.93 0.26 3.68 2 1,274
8 4.86 4.63 10.17 6.40 22.89 0.26 5.14 2 854
9 5.40 5.16 10.18 6.37 22.89 0.26 6.61 2 649
10 5.67 5.54 10.17 6.37 22.88 0.12 4.11 2 512
11 6.14 6.01 10.18 6.36 22.87 0.12 4.11 2 1,405
12 6.68 6.54 10.17 6.34 22.86 0.12 1.64 2 1,100
13 7.21 7.07 10.18 6.34 22.86 0.12 3.08 2 777
14 7.75 7.61 10.17 6.32 22.86 0.12 4.44 2 626
15 8.28 8.14 10.18 6.33 22.85 0.12 4.44 2 1,517
16 8.81 8.68 10.17 6.34 22.85 0.12 5.77 2 1,168

Medium, 6 rounds, server defaults for Raft (MiB):

round pebble of which log (live + kept) blobs sqlite search raft_log raft_snapshots snapshots on disk raft log entries
start 0.84 0.00 549.13 4.64 846.93 1.25 0.00 0 4,294
1 8.23 7.25 121.74 18.02 880.16 2.17 3.75 1 12,327
2 11.30 9.98 90.82 18.08 599.77 2.76 10.72 2 10,240
3 11.61 10.65 73.04 18.00 453.62 1.65 10.72 2 17,671
4 11.91 10.65 54.34 18.05 259.48 2.22 13.14 2 13,809
5 11.56 10.65 47.75 18.01 150.59 1.63 13.14 2 21,240
6 11.87 10.65 46.09 18.01 129.90 2.18 12.28 2 17,451

The spool was empty (under a block) at every sample in every run.

What it shows.

  • Blobs go down through the garbage collector. 65.3 to 10.2 MiB (quick) and 549 to 46.1 MiB (medium). The seeded mail is larger than the mail the soak writes back, so the fall is the deleted seed plus the refilled folders; what the soak establishes is that the figure stops falling once the old blobs are gone (quick: 10.17 or 10.18 MiB in every round from 6 to 16) and that deleting and re-adding the same amount of mail does not grow it. Verdict: bounded in both runs.
  • SQLite stays flat. 6.32 to 6.65 MiB (quick) and 18.00 to 18.08 (medium), most of it the write-ahead logs of the open databases (bounded at 200 pages each by wal_autocheckpoint). The auto_vacuum decision below is about the file shrinking when rows go; the soak’s workload replaces what it deletes, so it shows no growth rather than a fall. Verdict: bounded in both runs.
  • Bleve shrinks, slowly. 108 to 22.9 MiB (quick, level from round 8) and 880 to 130 MiB (medium), still falling at the end of the medium run (0.86 of the round before). A per-user index merges its segments while it is open, so the fall is the account being worked on again each round, a few rounds after the delete. Verdict: bounded (final / round 1 is 0.21 and 0.15), but the medium run had not finished settling; it does not show where the index stops.
  • Pebble: the data is flat, the climb is the log, and both are bounded. The total climbs (quick: 1.01 to 8.81 MiB over sixteen rounds, about 0.53 MiB a round; medium: 8.23 to 11.87, level from round 2) and would fail the plain test, as it did in every earlier run. The split shows why: the log is 8.68 of the 8.81 MiB at the end of the quick run and 10.65 of 11.87 in the medium run, in at most 3 files (bound: 6 files, about 26 MiB). The data (tables less the Raft log) is 0.24 MiB after round 4 and 0.14 MiB at the end (quick), and 1.33 MiB after round 2 and 1.22 MiB at the end (medium), sawing between 0.89 and 1.33 MiB as flushes add level 0 tables and compactions fold them away. Verdict on the parts: bounded in both runs (data final over baseline 0.57 and 0.92; final over the earlier high 0.57 and 0.92).
  • Snapshots: two on disk, bounded. Raft keeps two finished snapshots, and two were on disk from round 2 on in both runs. (The soak used to count the snapshot store’s snapshots directory itself, so earlier runs read one snapshot whatever was there; it now counts the snapshots in it.) Each is a tarred Pebble checkpoint: tables, the live log copied, and the manifest. The copied log is what moved raft_snapshots (quick: 1.64 to 6.61 MiB, with up to 5.59 MiB of log); the tables and manifest per snapshot were 0.25 MiB at the end against 0.39 after round 4 (quick) and 2.58 against 3.62 after round 2 (medium). Verdict on the parts: bounded in both runs.
  • Raft log bytes are an sstable estimate that steps with each compaction (1.63 to 2.76 MiB at the defaults) and fail the plain “still growing” test in the medium run’s last round (2.18 against 1.63), so make soak at the medium scale still exits 5 on raft_log alone. The bound that matters is the entry count, below.

Raft log and snapshots on one node

The log shares the data Pebble under _raft/log/; compactLogs in raft v1.8.0 removes entries up to the lesser of the snapshot index and the last index less TrailingLogs at each snapshot, and a snapshot fires when snapshot_threshold entries have been added, checked every snapshot_interval. So the log should hold between trailing_logs and trailing_logs + snapshot_threshold entries, plus whatever is written between two checks of the threshold (one snapshot_interval, 120 seconds by default). Measured, with the entry count read from bongo_raft_log_entries after every round:

Run Bound without the interval Entries seen Snapshots on disk
snapshot_threshold 1,024, trailing_logs 512, 10 s check (quick, 8 rounds, v0.18.0-33) 512 to 1,536 568 to 1,461 not measured (see below)
server defaults, 8,192 and 10,240, 120 s check (medium, 6 rounds, v0.18.0-33) 10,240 to 18,432 10,240 to 17,671 not measured
quick, 16 rounds (742959d4) 512 to 1,536 512 to 1,517 2 from round 2
medium, 6 rounds (742959d4) 10,240 to 18,432 10,240 to 21,240 2 from round 2

The minimum is each run’s trailing_logs (10,240 is exactly raft’s own default). The second medium run went 2,808 entries above trailing_logs + snapshot_threshold in round 5: the threshold is checked every 120 seconds at the defaults, and the soak’s writes in that interval landed on top. So the bound is trailing_logs + snapshot_threshold plus one interval’s writes, not the sum alone; it stays a bound (the next check snapshots and truncates; round 6 read 17,451). The log bytes (the sstable estimate) stayed between 0.12 and 0.27 MiB for the small retention and between 1.07 and 2.76 MiB at the defaults, and fell back between rounds without any manual compaction: the deleted range is dropped by Pebble’s own compactions, so no manual Compact was added.

Snapshots on disk: raft keeps two finished snapshots, and the 742959d4 runs saw two from round 2 on, 13.1 MiB for both at most (medium). The earlier runs recorded one at every sample, but the soak then counted the store’s snapshots directory (raft’s file store keeps its snapshots one level down, raft-snapshots/snapshots/<id>/), so it read one whatever was there; TestSnapshotStoreLayout now writes snapshots with raft’s own store and checks the count.

So the log is bounded at the defaults, as compactLogs says. The comment on TrailingLogs in internal/config and the startup warning in applyRaftTuning had said that the log “never truncates” when trailing_logs is not below snapshot_threshold. That was wrong, and both now say what the code does: the log is never shorter than trailing_logs entries, and holds up to trailing_logs + snapshot_threshold. The refusal of a file that sets trailing_logs at or above snapshot_threshold stays (it is almost certainly a mistake), with its message corrected. No behaviour changed.

SQLite: auto_vacuum=FULL for new files

A SQLite file never shrinks when rows are deleted unless it is told to. The choices were auto_vacuum=FULL, which moves freed pages to the end and cuts the file at each commit that frees any; INCREMENTAL, which needs a sweep that calls PRAGMA incremental_vacuum on each database (the per-user databases are opened a few at a time, and a pass over 20,000 of them is already a problem elsewhere in this tree); and a periodic VACUUM, which rewrites the whole file and needs up to twice its size free. FULL is set when a per-user or system database is created (PRAGMA auto_vacuum=FULL in initSQLiteFile, before the first table and before the WAL header is written; tests read the pragma back, check a delete shrinks page_count and check a file made without it still reports 0). Cost: one pointer-map page per about 200 pages (about 0.5% at the 1 KiB page size), and page-moving work on the commits that free pages. FULL does not defragment.

Existing files keep auto_vacuum=NONE and nothing converts them: there are no users yet whose files would need it. To convert one, with the server stopped:

sqlite3 /path/to/metadata/users/ab/USER.db 'PRAGMA auto_vacuum=FULL; VACUUM;'

VACUUM rewrites the whole file, needs up to twice its size free, and holds an exclusive lock while it runs. The other route is to delete metadata/users and search and start the server: both are derived from Pebble and the blobs and are rebuilt at startup, at the cost of a full rebuild of every account.

Measured on this machine, three runs of each (go test -run xxx -bench SQLiteAutoVacuum -benchtime 300x -count 3 ./internal/store/, a batch of 200 rows of 300 bytes per operation, the “none” file built as an older install’s was):

Operation auto_vacuum=FULL NONE Ratio
Insert 200 rows in one commit 1.073 ms (1.047, 1.094, 1.078) 1.037 ms (1.047, 1.031, 1.034) 1.03
Delete 200 rows in one commit 0.165 ms (0.167, 0.165, 0.165) 0.368 ms (0.372, 0.368, 0.366) 0.45

Insert is 3% slower and delete is faster (a file that does not truncate takes the freed pages onto its free list, which writes more), well inside the 10% read-cost budget, and the file is cut back by the commit that frees the pages, which is what the soak needs. The whole-server make bench was also run once per build (make bench BONGO=... RUNS=2, two builds that differ only in this pragma). Delivery rate (8.89 against 8.74 messages a second), disk per message (386,203 against 385,873 bytes) and the SQLite size agreed within 2%. Its report-compare flagged 13 figures worse than 10% and 4 better, all of them latency percentiles of a few milliseconds, idle memory (34% better) and start-up time (23% better), and the runs of one binary did not agree with each other on most of them (“runs do not agree on” for both builds). The machine was shared with other measuring jobs. The flagged operations are reads and logins, which a pragma that only changes how commits free pages cannot slow, so this is recorded as noise on this machine rather than a cost, but the figures were not clean, and the comparison should be repeated on a quiet Linux machine (the decision rule was to switch to INCREMENTAL if any figure was more than 10% worse). The operator kept FULL on 2026-12-03, with that repeat to be done before the release. If it is repeated and a real cost shows, INCREMENTAL is the fall-back.

Bleve: a deleted document stays until the index is reopened and merges

Bleve’s scorch index merges segments in a background goroutine that lives as long as the index is open (a reading of the library, not something measured here). The server keeps a bounded number of per-user indexes open (storage.max_open_search_indexes), so an account whose index was evicted keeps its deleted documents on disk until its index is opened again, by a new message, a search or a start. The run with two indexes open (make soak SCALE=quick ROUNDS=6 SOAKFLAGS="--soak-max-open-indexes 2") followed the default run round by round to within 1% (107.4, 73.5, 57.5, 35.7, 27.0 and 24.95 MiB of search after rounds 1 to 6, against 108.1, 73.5, 57.5, 36.0, 27.2 and 25.1). That is not evidence that eviction is harmless: every account the soak works on is opened by that work, which is when it merges. What is not measured is an account that is deleted from and then never touched again; its index would be expected to stay at its size, and the soak does not exercise that case. A forced merge on close was not added: it would put work on the path that closes an index, and without a measured need it is left as a candidate in the 1.0 criteria document (section 8.2).

Sizing

From the two end states above (all accounts and all messages in the data directory, per message after the soak’s own mail replaced the seed):

Run Accounts Messages Disk, all components Per message Per account
Quick, round 8 20 718 49.85 MiB 71.1 KiB 2.49 MiB
Medium, round 6 40 5,902 226.78 MiB 39.3 KiB 5.67 MiB

The messages the soak writes are 2 to 9 KiB of text, 5.5 KiB on average, so these are about 13 and 7 times the raw mail: at this size the fixed cost of an account with mail dominates (SQLite and Bleve together were 1.5 MiB an account in the quick run). The medium run’s search index was still falling when it stopped (0.88 of the round before), so its figure is an upper bound for this mail. For other mail, use the bulk-load figures above (disk per message and per account for large messages, taken before the index stopped storing text) or run make storage-report on your own mix, and add the following to a figure from either.

Headroom for How much Basis
Garbage collection lag the mail you expect to delete in one go, for up to the minimum age (1 hour, counted from the message’s arrival) plus three 15-minute ticks (45 minutes) a deleted message’s metadata is removed on the second tick after it is old enough and its blob on the tick after that (TestExpungeToBlobDeletionChain; the soak at 30 seconds and 1 minute); emptying a 20 GiB mailbox needs the 20 GiB for that long
Pebble’s write-ahead log up to about 26 MiB whatever the mail (6 log files of a 4 MiB memtable, live and kept for reuse); 10.65 MiB in 3 files in the medium run bongo_pebble_disk_bytes{part="wal"} and {part="wal_obsolete"}; the soak
Pebble’s tables small next to the mail: 1.2 to 1.3 MiB at 6,000 messages, less the Raft log the same, part="tables"
Raft log at most about 3 MiB at the defaults (2.74 MiB as an sstable estimate at 13,175 entries); more as an unflushed log, which is in pebble raft_log and bongo_raft_log_entries
Raft snapshots two, each Pebble’s tables plus its live log at the time (13.1 MiB for both in the medium run, up to 7.1 MiB of it copied log) raft_snapshots; the soak’s tar headers
Per-user SQLite write-ahead logs up to about 200 KiB for each open database (wal_autocheckpoint), with at most storage.max_open_user_dbs open the WAL figures above and the soak’s sqlite
Search index after a large delete it falls over several rounds of use, not at once, and an account that is not touched again does not fall the soak, and the Bleve section above
Converting an old SQLite file up to twice that file, temporarily VACUUM
Spool the mail in flight (empty after every load) spool

These add to the free-space floor (storage.min_free_mb), which is the line the server refuses writes at.

Per-component disk in the dev role

The dev role has in-memory snapshots, so raft_snapshots reads 0 there; its Raft log is in the Pebble in the scratch directory and is counted as on any other node.

Message bodies are stored compactly (US-S5)

Outcome: built, measured, and off by default. Compression saves 54% of the blob bytes in blocks on the storage mix, but it makes fetching a large message slower by more than the 10% budget, so it fails the rule (below). The operator decided on 2026-12-03 to keep the code with storage.compress_blobs defaulting to false: turning it on slows large fetches, and a node that has written compressed blobs cannot be rolled back to v0.18 or earlier without losing them. Nothing changes for a node that does not turn it on.

The format

With storage.compress_blobs = true a new blob is written compressed when it is at least 4,096 and at most 65 MiB raw bytes and its zstd form (header included) is at most 7/8 of the raw size; anything else is written raw, so random attachments, images and small messages are untouched. A compressed file is a 56-byte header and one standard zstd frame (the encoder default, CRC on):

Offset Size  
0 4 0x184D2A5B little-endian, a zstd skippable frame
4 4 48, little-endian, the length of the rest of the header
8 8 BONGOZ01
16 32 SHA-256 of the raw content, binary (equal to the file name)
48 8 raw size, little-endian
56   the zstd frame

A file is compressed if and only if its first 56 bytes parse as this header and the embedded hash equals the hash being read. A plain check for the zstd magic number would be wrong: an attachment is extracted into its own blob and stored raw, and a user can attach a .zst file. A raw blob would have to contain its own SHA-256 near its start to be mistaken for a compressed one, which is not feasible, so a read never hashes to decide. The content address stays the SHA-256 of the raw message, so deduplication, blob sync and the GC are unchanged. An existing raw blob is never rewritten, and a dedup hit on one leaves it raw. internal/store/blobcompress.go is the only code that knows the format; it decodes through a pool of decoders bounded to 65 MiB (the 64 MiB a peer may send in one blob sync, plus slack; a header may not claim more), every read streams and stops one byte past the recorded raw size, so a damaged or hostile frame that expands further is cut off rather than decoded in full, and a read that does not end at exactly the recorded raw size is an error, never a short message. The zstd frame checksum is checked only when a reader reads to the end of the frame; the length check and the content hash (Verify, and the re-hash of every blob a peer receives) are the integrity controls.

Raw size or stored size

Reads Gives
Get, Size, Verify; raw_message.size; quota and usage; IMAP RFC822.SIZE; POP3 LIST; bounce RET=FULL sizing; the backup’s “already copied” check the raw size and bytes (Size reads the 56-byte header, not the frame)
Stat, Walk and BlobInfo.Size, Stats, WalkTotals; the admin page and /metrics blob figures; the GC’s “bytes reclaimed” log line the on-disk size

A user’s quota must not depend on a node’s compression setting or on whether a blob was written before or after it, so quota stays on the raw size. Disk figures are on-disk. PutReader returns the raw size, because callers store it as raw_message.size, while Stats grows by the stored size.

Mixed versions and downgrade

An older binary cannot read a compressed blob. It opens the file as raw and would serve the header and the zstd bytes as the message over IMAP, POP3 and the web, fail Verify and index the bytes, all silently. Upgrade every node before turning the switch on, and do not run an older binary on a data directory that holds compressed blobs. There is no tool that rewrites them raw; the way back is a backup (which holds raw blobs) taken before, or never turning it on. Turning it off later affects only new blobs: this version still reads the compressed ones. Blob sync is safe between versions, because the peer endpoint serves Get output (raw) and the receiver stores it in its own format. No Raft command, key or proto field was added (the node-local file format only), so no test applier changes and an older node agrees on every Pebble key. Details: docs/design/keyspace.md, “Compressed blobs”.

The rule

Open question 6 asked what saving makes compression worth the read cost. The operator set the rule on 2026-12-03 (PRD decision 12): compression pays if it saves at least 20% of blob bytes in blocks on the measured mix AND the US-P1 fetch figures (small and large message, p50 and p99, report-compare) are no worse than 10%. It replaces the earlier proposal in “Proposed targets” (at least 25% in blocks on a real corpus and a 1 MiB message decompressing in under 5 ms); the two are not both kept. The 5 ms bound is met many times over (below), but it was not the same question as the 10% budget.

The measured mix is synthetic text, which saves 54% already, so the saving half of the rule passes easily and says little about real mail. A real-corpus figure is still to come.

Figures

All figures: v0.18.0-33-g47077a1b-dirty (the v0.19 tree with this change), Go 1.27.4, Apple M3 Max (16 CPUs, 64 GiB), macOS 27.2.1, APFS with 4,096-byte blocks. Linux ext4 figures are still to come, and other jobs ran on the machine during every run (three other measuring jobs shared it), so latencies are indicative; the figures that matter agreed between repeats.

Saving, the storage mix, quick scale, blobs written compressed by the loader (the stored files, not an estimate):

go run ./scripts/loadgen storage --target-allow 127.0.0.1 --test-domain bongo.test \
  --storage-scale quick --storage-compress-blobs --storage-out storage-quick-compress.json
Shape Blob files (compressed) Raw On disk Allocated, as stored Allocated, if raw Saved in blocks
single (100 x 1) 108 (63) 10.14 MiB 4.63 MiB 4.83 MiB 10.34 MiB 53.3%
small (200 x 10) 2,008 (1,252) 130.62 MiB 58.24 MiB 61.96 MiB 134.42 MiB 53.9%
large (5 x 200) 1,008 (626) 72.87 MiB 32.49 MiB 34.37 MiB 74.75 MiB 54.0%

The files that stay raw are the messages under 4 KiB and the random attachments. This agrees with the estimate above (54.1% in blocks).

The bench’s own mix (loadgen seed default bodies, SMTP load of 2 KiB messages) is less compressible: the blob store is 78,680,064 bytes allocated raw and 65,748,992 compressed, 16.4% saved in blocks, under 20% on its own. The rule names the storage mix; the two together show how much the saving depends on what the mail is.

Fetch latency, loadgen bench (20 x 25 messages, 4 KiB and 1 MiB targets, 500 fetches each, two runs per report, medians), the same binary with the key off and on. Off, on, off, on, so that two pairs show the spread:

loadgen bench --target-allow 127.0.0.1 --test-domain bongo.test \
  --bench-bongo-bin ./bongo --bench-dir DIR --bench-label compress-off \
  --bench-compress-blobs off --bench-fetch-protocols --bench-fetch-count 500 --bench-runs 2 \
  --bench-out report-off.json     # then the same with --bench-compress-blobs on
loadgen report-compare --target-allow 127.0.0.1 --test-domain bongo.test \
  --report-compare-baseline report-off.json --report-compare-candidate report-on.json
ms off (1) off (2) on (1) on (2)
IMAP small p50 / p99 0.118 / 0.381 0.110 / 0.243 0.108 / 0.223 0.117 / 0.328
IMAP large p50 / p99 0.922 / 2.221 0.768 / 1.541 1.206 / 1.763 1.129 / 2.099
POP3 small p50 / p99 0.086 / 0.291 0.072 / 0.126 0.103 / 0.181 0.096 / 0.192
POP3 large p50 / p99 4.307 / 5.687 4.142 / 5.276 4.400 / 5.524 4.376 / 5.370
Web small p50 / p99 0.116 / 0.307 0.105 / 0.219 0.121 / 0.235 0.109 / 0.296
Web large p50 / p99 0.830 / 1.633 0.725 / 1.442 1.295 / 1.927 1.283 / 1.846

report-compare of off(1) against on(2), and of off(2) against on(4): large IMAP p50 +31% and +47%, web large p50 +56% and +77%, web large p99 +18% and +28%. Every small-message figure is a few tens of microseconds either way and swings by more than 10% between repeats of the same setting (0.126 against 0.291 ms for POP3 small p99, both off). POP3 large is dominated by the protocol (4 ms) and agrees. The large-message p50 is worse by more than 10% in both pairs, and by more than the spread between repeats, so the latency half of the rule fails. These runs are warm: the file is in the page cache, so what they measure is the extra decompression pass with nothing saved on I/O; a cold read of a compressed blob reads fewer bytes, and that case is not measured.

The read cost on its own, go test -run XXX -bench BlobGet -benchmem -count 3 ./internal/store/ (compressible text, file in cache; the 2 KiB blob is under the 4 KiB threshold, so it is raw both ways):

Message Raw Compressed Extra
2 KiB 15.5 to 16.2 us 15.5 to 15.9 us none (stored raw)
64 KiB 20.7 to 21.2 us 35.4 to 36.2 us about 15 us
1 MiB 103 to 104 us 241 to 242 us about 138 us

A 1 MiB message decompresses in about 0.14 ms more than it reads, far under the 5 ms the earlier proposal asked for; the extra pass is also what the large fetch p50 shows. Compressed reads allocate two more objects and about 1 KiB more (the pooled decoder is reused).

What stays open

  • Under the rule the answer is “does not pay”: the saving is 54% on text but the large-message fetch costs about 0.3 to 0.5 ms more on a warm cache, against a 10% budget on a figure of 0.8 to 1.2 ms. A real corpus (HTML, embedded images) will save less than 54%. A faster decode for large messages, or a higher size threshold, comes before the default is reconsidered.
  • A real-corpus saving figure, a medium-scale run (not done; only the quick scale was measured), a cold-cache fetch figure, and every figure above on Linux ext4.
  • If it is turned on: the on-disk size of a message is its stored size, so the disk.ratio_to_raw figure of the bench falls from 5.45x to 5.08x with it on (193,425,408 to 180,445,184 bytes allocated in total).

Proposed targets

The targets below come from the medium run on APFS; the full scale has not been run (see “Not yet measured”).

Open question 1 of the 1.0 criteria asks for the storage targets to be set from these figures, with two first guesses to start from: disk under 2 times the raw mail including the index, and under 100 KB for an account with no mail. These are proposals for the operator to accept or change. Each is stated against the default plan and this file’s runs, and each story re-measures with the same command and records before and after here.

The projections are arithmetic on the medium run, not measurements: the Bleve share is scaled by the settled ratios above (0.092 batched, 0.12 one at a time), keeping the 264 KiB fixed cost of an index, and the blobs by the 54.1% of zstd.

Target Measured now Projected Proposed
Disk to raw mail, few large accounts 6.31x 1.5x to 1.6x after the index work alone; 0.95x with zstd at most 1.6x
Disk to raw mail, many small accounts (10 messages) 7.89x 2.1x to 2.3x after the index work alone; 1.7x with the fixed cost of an account also cut; 1.2x with zstd at most 2.2x, then 1.8x
Bleve index of the same documents, against the current mapping 1.00x 0.09x batched, 0.12x one at a time at most 0.12x
Account with no mail 0.74 KiB compacted (1.44 as left), no per-user file already met at most 4 KiB, and no SQLite file or Bleve index until its first message, pinned by a test
Fixed cost of an account that has mail (SQLite plus Bleve, before its mail) about 390 KiB (128 + 264), 4 files and 2 directories   at most 100 KiB
Per-user SQLite WAL while open about 227 KiB after 10 messages, 4.5 MiB after 1,000   at most 1 MiB, and none after close
Raft log on one node between trailing_logs and trailing_logs + snapshot_threshold entries (10,240 to 18,432 at the defaults); measured 10,240 to 17,671 entries, and 21,240 once when the 120-second threshold check let one interval’s writes land on top, and at most 2.76 MiB as an sstable estimate at the defaults; two snapshots on disk, 13.1 MiB for both   at most 16 MiB at the defaults for the log, measured by a soak; snapshots measured separately (met on APFS; ext4 to come)
Blob compression (open question 6) zstd saves 54% in blocks on synthetic text and decompresses at 876 MiB/s after the index work the blobs are about 45% to 65% of the disk, so this is a 25% to 35% cut of it adopt when it saves at least 20% of blob bytes in blocks on the measured mix and fetch p50 and p99 (small and large, IMAP, POP3 and web) are no worse than 10% by report-compare; this replaces the earlier proposal (25% on a real corpus and 1 MiB under 5 ms) and was set by the operator (PRD decision 12). Measured: 54% saved, large-fetch p50 worse by 31% to 77%, so the code is kept and off by default (“Message bodies are stored compactly”)
Inodes 1.63 a message (small), 1.03 (large), 7.3 for an active account   at most 2 a message and 8 for an active account, whatever layout is chosen

Reasoning, by story:

  • Disk and the index (the story on search text). The index is 85% of a message’s disk, and term vectors alone are 79% of the index. The first guess of 2 times raw is met for the large shape by the index work alone and just missed by the small shape until the fixed cost of an account is cut. The ratios are those of this text-heavy plan; the ratio-to-raw targets say “at the default plan” for that reason, and the one that carries over to real mail is the Bleve-against-current ratio.
  • The fixed cost of an account. The empty account is already 0.74 KiB, so the story’s first criterion is a pinned test, not work. The cost that matters is the first message: 128 KiB of SQLite and 264 KiB of Bleve before any mail, which is 54% of the raw mail of an account of 10 messages. The WAL of an open database is unbounded today and is the largest part of the open-state disk (227 of 329 MiB for 1,000 databases).
  • Bounded storage. Done by the soak above: the Raft log and the snapshots are bounded by the retention, blobs, SQLite and Bleve return towards a steady size after deletes, and Pebble’s data and its snapshots’ tables stay level while its write-ahead log stays within the bound its configuration sets (measured by part in both soaks; the quick soak passes two flushes in 16 rounds). The per-component figures are published on /admin and /metrics.
  • Compression. The saving is large on text and nil on attachments, but the extra decode pass made large fetches 31% to 77% slower on a warm cache, so it fails the rule and is off by default (“Message bodies are stored compactly”); a real corpus is still to be measured. Blobs under 4 KiB save nothing in blocks whatever the compressor.
  • The file layout. Bytes run out before inodes at these sizes. The medium run held 349 KiB of disk for every inode used in the small shape and 461 KiB in the large one; the quick run after the layout change holds 62,131 and 51,222 bytes (see “The file layout holds at scale”). ext4’s default of one inode per 16 KiB (inode_ratio in /etc/mke2fs.conf; check the value on the real machine) gives 16 KiB, so the disk fills 2 to 4 times before the inodes do in the quick run. Inodes would come first only for mail of a few KiB with the index shrunk as well. This is computed from the APFS runs and is to be confirmed on ext4. The two-level blob fan-out and the user buckets were done for scale, at the cost of about one inode per blob in a small store (see that section); the “at most 2 a message” target above holds only past roughly 500,000 blobs. That miss below 500,000 blobs was accepted on 2026-12-02 (about 1 extra inode and 4 KiB per blob); the second level is not made adaptive.

Not yet measured

  • The full scale (5,000 x 10, 50 x 2,000, 1,000 empty, 1,000 single): not run. It needs about 72 GiB free and was refused on the machine above for lack of space; a full run on Linux ext4 is a follow-up, and its peak memory is unmeasured (see “Memory” above). The medium run is one fifth of the small shape’s messages and a tenth of the large shape’s; the per-message figures were stable between the quick and medium runs (7.92x and 7.89x; 6.31x and 6.31x).
  • Linux ext4 (and XFS). Block rounding, directory blocks, inode use and the cost of fsync there; the inode computation above, and the real cost of the second-level blob directories (“What it costs” in the layout section is arithmetic: APFS allocates nothing for a directory).
  • The layout at scale. The walk time of 100 million blobs and a million accounts is extrapolated from a linear benchmark of up to 20,000 blobs; the mover’s time on a large store and its effect on foreground latency have not been measured. The medium run was not repeated after the layout change; the quick run above is the only run with it.
  • A real mail corpus, for the text, compression and index figures. The compression saving (54% on synthetic text) is the figure most in need of it.
  • The soak on Linux ext4 and over a longer time: it ran on APFS for up to 16 rounds of about 3 minutes at the quick scale (two Pebble flushes) and 6 at the medium scale. An account that is deleted from and never touched again was not exercised (see “Bleve”), and the whole-server make bench comparison for auto_vacuum=FULL was too noisy to read on a shared machine and is to be repeated.
  • A forced Bleve merge for an index that is evicted: not measured and not added.
  • Compressed blobs on Linux ext4, with a cold cache and at medium scale: the fetch figures of “Message bodies are stored compactly” are warm-cache figures from APFS at the quick scale.
  • Memory and open files of a node holding this data. This tool measures disk.
  • Real concurrent load: this is the state after a load, not under traffic.

View this page's source on GitHub