Technical report

tierstore: an S3 tiering proxy for small writes and repeat reads

A flash tier absorbs many small writes, a node-local cache serves repeat reads, and cheap disks keep everything, all behind one S3 endpoint.

Komira AI · Draft · All research · github.com/komira-ai/tierstore

0. Overview

tierstore is a process that makes object stores faster. It caches and tiers objects, the way a CPU’s L1, L2 and L3 caches make RAM faster.

Object storage is a popular way to keep data because it is cheap. Most object stores use hard disks, and they scale at low cost: more capacity means more disks. But a program that reads and writes many objects soon waits on those remote disks. NVMe drives and SSDs also keep data, and they are much faster, but they cost several times as much per terabyte (section 6). A small amount of flash, used as a cache and not for long-term storage, gives most of that speed for little extra cost.

1 ns1 µs1 ms1 sLevelReadWrite4 KiB latency, log scaleL1CPU cacheabout 1 nsabout the sameL2CPU cacheabout 3–5 nsabout the sameL3CPU cache, sharedabout 10–40 nsabout the sameRAMmemoryabout 100 nsabout the sameAbove this line: memory inside the computer. Below it: persistent storage.Local NVMein the node; local_cache0.1 ms0.1 msDistributed SSDover the network; hot_store4.0 ms10.7 msDistributed HDDover the network; cold_store28.6 ms956 msreadwrite (a ring where it matches the read)CPU levels: typical published figures. Storage levels: measured in the lab, straight to the hardware (bold).
Read and write latency at each level of storage, on one log scale. The CPU levels are typical published figures. We measured the three storage levels in Komira’s lab, directly on the hardware, without tierstore: 4 KiB at one request in flight, from the test machine to its own NVMe and to the SSD and HDD MinIO on the six build nodes (sections 2 and 3). A small write to the distributed hard disks takes about 90 times as long as a small write to the distributed SSDs.

Komira needed exactly that. Its build farm reads the same inputs many times and writes many small outputs. The hard disks under the farm’s object store were 87–100% busy, but they wrote only 0.2–0.9 MB/s. So Komira built tierstore: one program behind one S3 endpoint that moves objects between the tiers automatically. It caches repeat reads on a node’s local NVMe (local_cache). It absorbs writes on distributed NVMe or SSD (hot_store). It keeps all data on distributed hard disks (cold_store). tierstore sits on top of S3-compatible object stores and does not replace them. The stores below it keep the data durable, and any S3-compatible store, or several, can be there (section 4).

The Zig toolchain, 15,189 small files, is the build output that broke the old store. tierstore writes it as one pack and makes it durable in less than half a minute: from 43 minutes and a failed upload to 27 seconds. A node that never had the tree reads all of it back in 9.2 seconds. A node that has it in its cache reads it in 1.6 seconds. The hard disks alone take 176–179 seconds (section 6).

Write: 15,189 filesuntil the writer is released0153045minutesold store43 min, then failedtierstore27 s, durableRead the whole tree backseconds (log)1101001,000secondsHDD direct176–179 stierstore, cold / warm9.2 s cold, 1.6 s warm
The Zig toolchain on the old store and on tierstore. The upload takes 27 seconds, not 43 minutes and a failure. A full read of the tree takes 9.2 seconds cold and 1.6 seconds warm, not 176–179 seconds from the hard disks. We measured the tierstore rows on the farm nodes (10 Gb/s) while the farm was almost idle (load 0.6–5.4 on 88 CPUs). We used a salted copy of the tree, so that no node had its bytes, and show the median of three runs. The writer is released 27 s after the action ends, and at that time the pack is already durable in SeaweedFS (section 6).

1. The build farm problem

A build runs thousands of actions. Each action reads its dependencies from the object store and writes its outputs back. This traffic has two properties that are specific to a build store.

Shared dependenciestoolchain: compiler, headers, librariesOwn inputssources of this action, read onceBuild actionruns in a sandboxOutputsmany small files, one object eachwritten once, read by later actionsObject storeREAD: same files, again and againWRITE: many small objects
What a build action reads and writes. Each action reads the toolchain again. Each output is thousands of small objects.

Many small writes

The store keeps each output file as its own object. This approach is simple, but some artifacts break it. For example, the Zig 0.12.0 toolchain has 15,189 files and 307 MB: about 20 KB per file on average, with 144 empty files and one file of 157 MB. Hard disks handle this traffic badly. Before tierstore, the 12 disks behind the farm’s MinIO were 87–100% busy, but each disk wrote only 0.2–0.9 MB/s. The average write was 7 KB, and 71% of writes took longer than 10 s. (These farm measurements come from the kbf paper and were made before tierstore. They are not part of the benchmarks in this paper.)

Repeat reads

Most inputs are shared. Every action on a node reads the same compiler, headers and libraries. In one cold full build, each node read 667 GB to 1.00 TB of input, but only 5.2–8.0 GB of it was distinct. Each distinct byte was read 111–133 times. The most-read blob, about 139 MB, was read about 1,600 times per node (same source). Without a cache, each of these reads goes across the network to the disks.

2. Understanding the hardware performance

Before we added anything on top, we measured the drives themselves. We tested three kinds of drive:

The benchmark is our own client, a Python SigV4 driver. It reads and writes objects of 4 KiB to 128 MiB, and the real 15,189-file Zig tree, at one and at sixteen requests in flight. Each cell has one discarded pass and three measured passes. Before each read pass, we drop the nodes’ page cache. MinIO warp v1.3.1, the public S3 benchmark, adds throughput results for get, put, mixed, stat and list at 4 KiB, 1 MiB and 16 MiB.

The baseline: straight to the disk stores

4 KiB write, p501 in flight, ms (log)0.11101001000milliseconds1 GB of 1 MiB objects, rate16 in flight, MiB/s (log)1101001,00010,000MiB/sNVMe, file I/O0.12,439SSD MinIO10.7102.5HDD MinIO955.87.2Bars: median of three measured passes.4 KiB read, p501 in flight, ms (log)1 MiB read, p501 in flight, ms (log)0.1110100milliseconds0.1110100millisecondsNVMe, O_DIRECT0.10.5SSD MinIO4.019.5HDD MinIO28.634.2
Baselines directly on the disk stores, without tierstore. NVMe is the local drive of the test machine. For large objects, both MinIO stores read at the limit of the network link (section 3).

Hard disks are slow when a build is small. A 4 KiB write takes 956 ms on the HDD MinIO and 10.7 ms on the SSD MinIO. A 4 KiB read takes 28.6 ms and 4.0 ms. A 1 GB write of 1 MiB objects, at 16 in flight, runs at 7.2 MiB/s on the hard disks and at 102.5 MiB/s on the SSDs, which is the limit of the network link. Large objects hide the difference: 128 MiB reads reach 103.8 and 111.1 MiB/s, both at the link. The HDD store also becomes slower as the volume increases. A 10 GB write took 634 s, and then 1,138 s (8.8 MiB/s on the measured pass), in its two completed passes. We stopped a third pass after 38 minutes, at about 1 MiB/s.

3. Buffering HDDs with SSDs

Section 2 shows the gap: a small write takes about one second on the hard disks and about 11 ms on the SSDs. The first solution is the one a CPU uses for memory: put the fast tier in front, as a buffer. tierstore acknowledges each write when it is on the SSDs. A reconciler then copies it to the hard disks. The closest tier that holds a key answers each read.

tierstore is a stateless S3 proxy over S3 stores. It keeps nothing durable of its own, except its cache and the files that a job has staged but not committed. The hot tier and the cold tier are each an object store (or a directory) that tierstore uses. The stores below are responsible for durability, replication and erasure coding. Each of the two problems gets one tier, and a third tier keeps all data.

ClientsS3 tools, SDKs,OCI enginesOne tierstore processFrontS3 interfacemore interfaces(config list)local_cacheOPTIONALnode flash, LRUread-throughkeeps listed prefixeswrite-throughProxytier logic, per-key markershot first, cold on a missReconcilerone leader at a time (lease)copy hot to cold, finish deletes,copy back, evicthot_storeflash (NVMe or SSD)takes every write;holds markers and leasecold_storehard disks, any S3 storekeeps everythingWithout a hot_store: a local_cache overa cold_store that is another tierstore.Dashed orange: background work of the reconciler.
The parts of one process, as the farm ran it during these measurements: local_cache, hot_store and cold_store behind one S3 front. Solid arrows are client requests. Dashed arrows are the reconciler. The local_cache is optional. Nodes that read the same objects many times use it.

The setup

All benchmarks of sections 2 and 3 ran on these machines: the test machine (Intel Core i7-14700K, Micron 9300 NVMe, 1 GbE) and the six build nodes (SSD MinIO on six SSDs, HDD MinIO on twelve 8 TB hard disks, 10 Gb/s NICs).

Client boxi7-14700K, 123 GiB RAMLoad generatorsPython SigV4 client, warp 1.3.1Cache process (tierstore)local_cache on NVMe30 GiB, write-throughBare baselines go straightto the two MinIO stores;the cache process uses thestorage tierstore upstream.1 GbEclient NIC~110 MiB/sStorage node (10 Gb/s NIC, 251 GB RAM)Storage tierstoreproxy + reconciler (copy_parallel 16)no local disk used for datareconciler copyhot_store: SSD MinIOEC:3, 6 pods × 1 SSDacross the six build nodesSSD 1SSD 2SSD 3SSD 4SSD 5SSD 6Fanxiang S101 ×5, BX500 ×1cold_store: HDD MinIO6 pods × 2 HDDacross the six build nodes123456789101112Seagate ST8000DM004, 8 TB
The setup. The load generators and the cache process run on the test machine. Its single 1 GbE link is the limit for every network path. tierstore runs on a storage node with a 10 Gb/s NIC, so the copy from hot to cold never uses the test machine’s link. The baselines use the same two MinIO endpoints without tierstore.

Each cell runs against up to four targets. Two are the SSD MinIO and the HDD MinIO directly (the baselines). The third is the storage tierstore on the storage node: the SSD MinIO is its hot store, the HDD MinIO is its cold store, and it has no local cache. The fourth is the cache process on the test machine, in front of the storage tierstore: a second tierstore whose only tier is a local cache. A fifth path, the cold-only view, reads the HDD MinIO through tierstore with an empty hot tier. The NVMe gives the local minimum. The test machine’s link is the limit for every network path, but the nodes’ own NICs run at 10 Gb/s.

3.1 What a store must provide

A tier is an S3 store. The store under each tier can be any S3-compatible store that gives atomic create-only writes, conditional writes and ranged reads, or a directory. The hot tier is optional. Without it, a local_cache sits directly over one object store, and every put goes to that store.

One node, all three tiersthe layout measured in section 3tierstorelocal_cachenode NVMe, serves repeat readshot_storeflash, absorbs every writecold_storehard disks, keeps everythingCache over a single object storethe farm’s layout (section 6)tierstorelocal_cachenode NVMe, serves repeat readsno hot_storeputs go straight to coldcold_storea single object store
Two ways to configure tierstore. Left: one process with all three tiers, as measured in this section. Right: a local_cache directly over one object store, the farm’s layout in section 6. Reads are cached, and puts go to the store below, which must then absorb small writes itself (section 4).

3.2 Cache coherence

tierstore keeps the tiers coherent with a marker for each key. The marker records what the tiers owe each other. It is an object in a second bucket of the hot store, with exactly the same name as the key. It is created create-only and changed only with If-Match. The marker is DIRTY while hot has a change that cold does not have. It is LOCK while one process deletes or replaces the key. It is absent when the tiers agree. A put of a new key never takes a lock. The listing below follows one key through a put:

# bucket names are illustrative: data holds objects, marks holds markers

# 1. the put of cas/7d3f… has just been acknowledged
hot_store   data/cas/7d3f…     the object
hot_store   marks/cas/7d3f…    its marker: DIRTY (cold lacks it)
cold_store  data/cas/7d3f…     not there yet

# 2. the reconciler has copied it to cold
hot_store   data/cas/7d3f…     the object
cold_store  data/cas/7d3f…     the copy
            marks/cas/7d3f…    deleted: the tiers agree

3.3 Put

ClientProxyhot_storeobjects, markerscold_storedisks1 PUT K (body streamed)2 HEAD K: absent3a PUT K, create-only, streamed3b PUT marks/K, create-only: DIRTYat once4 200 OK: the acknowledgementCold is not asked. Later, in the background: the leader copies K from hot to cold (create-only),moves the marker to CLEARING and deletes it. The client never waits for it.
PUT. tierstore answers the client when the object and the DIRTY marker are in hot. It does not ask cold.

A put first checks if the key is already in the hot store. If the key is new, tierstore writes the object and its DIRTY marker at the same time, each only if the key is still new, and answers the client. If the key exists, the put is an overwrite: it takes the key’s lock, replaces the object and releases the lock. When two clients put the same key, both succeed, and the later put wins.

Why check first? The check selects which of the two paths the put takes. tierstore cannot simply try the new-key write and change to an overwrite if it fails. When the store reports that the key exists, it can already have read the client’s upload, and the client cannot send it again. An overwrite needs the lock because the store cannot delete an object conditionally. The check is one more request to the hot store, a small part of the 15.1 ms put (below).

A client can also ask for a put that must fail if the key exists. Then tierstore also checks the cold store before it answers. The budget of the hot store is less than its capacity, so a put always goes to hot, and the reconciler evicts older objects to make space. An emergency option writes directly to cold when hot is full. It is off by default.

3.4 Get

Clientlocal_cacheoptionalProxyhot_storeobjects, markerscold_store1 GET K2 hit: from local NVMeon a miss3 GET K4 GET K: a hit ends hereon a hot miss5a GET marks/K5b GET K, with 5a (only the range asked for)6 bytes (the cache keeps a listed prefix)Marker says gone: HEAD K on hot once more, then 404; cold's old copy is never served.Best effort after the answer: a whole-object cold read creates a WANT marker; the leader copies cold to hot later.
GET. The fastest tier that holds the key answers. A hot hit is one round trip.

A hit in the local_cache is answered locally. If not, hot answers. On a hot miss, tierstore reads the marker and the cold object together, and a ranged read moves only the requested range. A marker that says gone means that a delete is not yet complete in cold. One more HEAD on hot then decides between 404 and a put that has just arrived.

3.5 Delete

ClientProxyhot_storeobjects, markerscold_store1 DELETE K2 GET marks/K3 lock marks/K (create-only or If-Match)4 HEAD K, under the lock5 If-Match PUT marks/K: gone = true6 DELETE K (if the HEAD found it)7 204: the acknowledgementin the background8 leader: DELETE K in coldThe marker goes back to DIRTY, gone. After tombstone_hold the leader checks hot and cold once more and clears it.No cold request is on the acknowledgement path, and the delete never waits for a copy.
DELETE. The lock and the gone mark are two conditional marker writes on the acknowledgement path. (When no marker exists, the lock is create-only.)

A delete takes the key’s lock, marks the key gone in its marker, removes the object from hot and answers the client. It does not wait for cold. tierstore removes the copy in cold later, in the background.

Why an old copy in cold is safe. The gone mark, not the order of the deletes, prevents readers from seeing old data. A read that misses hot finds the key marked gone and answers 404 without a request to cold. (It first looks at hot one more time, in case a new put has just arrived.) So the old copy in cold can stay a little longer, and no client sees it. The reconciler deletes it in the background and clears the marker after tombstone_hold (120 s by default). If tierstore deleted from cold first, cold would be on the acknowledgement path. This design keeps cold off the acknowledgement path of every put, overwrite and delete, and lets cold catch up by itself.

3.6 The asynchronous design

The copy to cold occurs after the acknowledgement. Only one reconciler runs at a time: the process that holds a lease object in the hot store. Its work queue is the marker bucket. A new leader lists that bucket and continues, at a cost that is proportional to the backlog. Every step is create-only or conditional, so a retry finds the work already done.

Put of a new keyno markerDIRTYCLEARINGno markerput: the ackcopied to coldmarker deletedOverwrite, deletedelete also sets goneDIRTY / noneLOCKDIRTYlockchange madethen as a putEvictcold already has itno markerLOCKCLEARINGno markerlockhot copy freedmarker deletedCopy-backafter a cold readWANTLOCKCLEARINGno markerlockcopied to hotmarker deleted
The marker of one key, one row for each operation. A put creates the marker as DIRTY, and this is the acknowledgement. The reconciler copies the object to cold, changes the marker to CLEARING and deletes it. Any operation that replaces or removes a copy (an overwrite, a delete, an eviction, a copy-back) first takes the key’s LOCK. An overwrite or a delete goes back to DIRTY, because cold must still catch up. A delete also sets the gone flag, which stays until the marker is deleted. After an eviction or a copy-back the tiers agree, so it goes directly to CLEARING.

Does the buffer pay off?

The measurements test five claims. Each claim is compared with the baseline stores of section 2:

Method: the test machine’s 1 GbE link limits every network path to about 105–111 MiB/s. (The nodes’ NICs are 10 Gb/s.) Cache hits come from the test machine’s own disk, so the link does not limit them. We measured reads and warp with tierstore (no cache) on the test machine, and writes with tierstore on the storage node, on the machines of the setup above. Each write cell has one discarded pass and three measured passes. The bars show the median.

Read latency

Reads behave as the hierarchy predicts: the closer the tier, the faster the answer. A local_cache hit is much faster than all other paths. It takes 0.1 ms for 4 KiB and 0.6 ms for 1 MiB with a warm page cache, and 0.3 ms and 2.0 ms with the page cache dropped. A hot hit takes 4.7 ms and 20.2 ms. A read from the hard disks takes 32.4 ms and 40.0 ms. A cache miss costs a hot read plus the fill: 16.2 ms and 34.4 ms.

The gap between the hot tier and the cold tier becomes smaller as objects become larger. For 4 KiB, the hard disks are 7 times slower than the SSDs (32.4 ms against 4.7 ms), because the disk’s seek time is most of a small read. For 1 MiB, they are only 2 times slower (40.0 ms against 20.2 ms), because the transfer time becomes more important.

Large reads: the network is the limit

For large objects, the tier is almost not important. With 128 MiB objects at 16 in flight, hot hits (111.2 MiB/s), cache misses (110.0 MiB/s) and cold-only reads (104.9 MiB/s) all run at the speed of the test machine’s 1 GbE link. The baseline stores run at the same speed (111.1 and 103.8 MiB/s). For one large transfer, the network card limits the speed, not the disks and not tierstore. Cache hits do not use the link, and they reach 1,115–1,732 MiB/s. This limit comes from the single Python client: the same client reads the NVMe directly at 2,558 MiB/s.

128 MiB reads, 16 in flight, MiB/s (log)1001,000MiB/s1 GbE ceilinglocal_cache hit, warm1,115local_cache hit, dropped1,732hot hit (SSD MinIO)111local_cache miss110cold-only (HDD MinIO)105
Every tierstore path that uses the 1 GbE link stops at 104 to 111 MiB/s. Cache hits come from the test machine’s own disk, and the single Python client limits them.

The overhead of tierstore

tierstore cannot be free. Every request goes through the proxy, which is one more step. Some requests also send more requests to keep the tiers coherent: a put first checks the key and writes a marker next to the object, and a read that misses hot also reads the key’s marker. Compared with the baseline store, this adds less than 1 ms to a read from the hot SSD tier, about 4 to 6 ms to a read from the hard disks, and 4.4 ms to a 4 KiB put. On large objects the link hides the cost: 128 MiB reads and puts run within 3% of the baseline store’s rate. The overhead is extra round trips, so it should become smaller when the round trip between nodes becomes shorter, with faster links. We did not measure this.

010203040milliseconds, p50, 1 in flightWhat tierstore adds to the bare storebare MinIOthrough tierstore4 KiB read, SSD4.04.7+0.7 ms1 MiB read, SSD19.520.2+0.7 ms4 KiB read, HDD28.632.4+3.8 ms1 MiB read, HDD34.240.0+5.8 ms4 KiB put, SSD10.715.1+4.4 ms
The cost of tierstore. Each pair is the baseline MinIO and the same request through tierstore: p50 at one request in flight, with the nodes’ page cache dropped for reads. Hot reads go to the SSD MinIO. Cold-only reads go to the HDD MinIO.

Writes

With both a hot store and a cold store, tierstore absorbs puts much better. To show this, we ran a cache tierstore with a 30 GiB local_cache on the test machine, in front of one of two upstreams:

One client sent 4 KiB bodies: 100 trials per cell at one request in flight, and 30 s at 16 in flight. The tierstore configuration ran two rounds. During the test, the test machine and the nodes also ran real builds.

New 4 KiB key, put p501 in flight, ms (log)101001000before8621 node46.9 / 38.54 KiB puts per second16 in flight, 30 s0100200before22.81 node185 / 17964 MiB put1 in flight, MiB/s050100before20.21 node90.1 / 82.1Delete p501 in flight, ms020406080before7.41 node46.5 / 46.4before: the cache straight over the HDD MinIO (the old farm layout). 1 node: the cache over one storage tierstore. Two values: one per round.
Writes through a cache tierstore on the test machine, for each upstream. With tierstore behind the cache, a new key is acknowledged about 20 times sooner than in the old layout. A delete is slower. The old layout ran one round.

A new key is acknowledged in tens of milliseconds. The old layout needs most of a second. The difference is that the put goes to the SSDs and does not wait for the hard disks.

Overall performance, measured with MinIO warp

warp get, 4 KiB16 in flight, objects/s (log)warp put, 4 KiB16 in flight, objects/s (log)1,00010,000100,000objects per second101001,000objects per secondbare SSD MinIO4,786810bare HDD MinIO3,34529.5tierstore4,38663.0tierstore + cache92,813104warp put, 1 MiB16 in flight, MiB/swarp list, 1000 objects16 in flight, objects/s0255075100MiB/s08,00016,00024,000objects per secondbare SSD MinIO81.219,546bare HDD MinIO30.916,670tierstore70.610,153tierstore + cache51.610,245
MinIO warp v1.3.1, 30 s per cell. The 4 KiB panels use log axes. The cache wins on repeat gets. It loses to the baseline SSD store on list and on 4 KiB-put throughput. Warp’s small working set stays in the nodes’ page cache, so the baseline HDD reads are warm. Cache gets go over loopback, not over the 1 GbE link.

A cached 4 KiB get runs at 92,813 objects/s, against 4,786 objects/s on the SSD store. A 1 MiB get runs at 12,127 MiB/s (over loopback, not over the link). 4 KiB puts at 16 in flight reach 63.0 objects/s through tierstore alone and 104.3 objects/s through tierstore with a cache. This is 2.1 to 3.5 times the HDD store (29.5), but 7.8 to 12.9 times slower than the SSD store (809.6). A list of 1,000 objects at 16 in flight (4 KiB and 1 MiB cells) runs at 10.1–10.7 thousand objects/s through tierstore, against 16.7–20.8 thousand on the baseline: 49–61% of the baseline rate. Thirteen cache cells started at a host load of 21–42, so their rates can be low. The 4 KiB stat at 16 in flight (3,923 against 6,450 objects/s on the SSD store) is one of them.

Applied to a build: the Zig toolchain

The Zig toolchain shows what the buffer does for a real build output. On the old store, its 15,189 files, written as one object per file, took 43 minutes to upload, and then the upload failed. Through tierstore, the writer is released after 2.5 minutes, when every file is on the SSDs. The reconciler then copies the files to the hard disks in the background, and finishes after 36–38 minutes. No build waits for that copy.

0153045minutesold store43 min, then failedSSD write bufferwriter released: 2.5 minon disk: 36–38Uploading the Zig toolchain, 15,189 files, one object per file
The SSD write buffer at work: the build is released 17 times sooner, and the hard disks catch up in the background (dashed). Measured on the SSD MinIO and HDD MinIO of section 2, with tierstore on the test machine.

4. Choosing the right object store

Section 3 shows that flash absorbs small writes much better than hard disks. That is half of the story. The other half is that the farm used the wrong object store for its hard disks. Hard disks work best with large sequential writes. A store that changes every small object into several small writes on several drives makes the disks seek for each write. tierstore does not decide how the bytes are kept on disk. The object stores below it decide. That choice is important, because different object stores suit different hardware, and the farm learned this on its own drives. With tierstore, an operator can put any S3-compatible store with atomic create-only and conditional writes below it: a different store for each tier, or several endpoints of one store. Nothing above tierstore changes.

What this section shows.

The rest of the section gives the evidence for these points and the choice we made for each tier.

MinIO on drive-managed SMR disks

The farm’s original cold store was MinIO, in two deployments: in Kubernetes, and as a MinIO-compatible fork that ran natively. It used the six nodes’ twelve 8 TB hard disks. These are drive-managed SMR drives at 5,400 rpm, two in each node, in one erasure set of 8 data drives and 4 parity drives. So the data and parity of each object were spread over all twelve drives. On one node, one sequential stream ran at about 120 MB/s on one drive and at 91–93 MB/s on the other. A scattered 1 MiB read took a median of 22–23 ms, and 13.5 ms of that was positioning. We also saw, outside the benchmarks, that the store itself made 2 to 12 small writes per second on every drive, for its metadata and healing, also when no builds ran. This kept each drive 8 to 43% busy. Benchmark cells that ran during more than about 20 of these writes per second were clearly slower. When we retired the store, we read it from the drives: it held 1,526,337 objects and 1.35 TB. 90.7% of the objects were 64 KiB or smaller, but 95.9% of the bytes were in packs of 1 to 256 MiB. Its own listing ran at about 14 objects per second. Small objects spread over twelve slow drives are the worst case for this hardware: a small read or write must position several drives at the same time. (This is our interpretation of the design and of these observations, not a benchmark result.)

The move to SeaweedFS

The new cold store was SeaweedFS 4.54 on the same drives. It has three masters, a volume server on the two hard disks of each node (with its index on the node’s SSD), and a filer and S3 gateway on every node. The tierstore on each node uses its own gateway. SeaweedFS keeps two copies of every object, on two nodes. Erasure coding is not enabled, and each chunk of an object is stored complete on one drive, not spread over several drives. We did not copy data from the old store. The build service started again with an empty store. After we cleared its records of the old store, jobs started without failures: more than 4,000 jobs in the next 20 minutes.

Same disks, different store

The clearest evidence comes from the farm’s own drives, on the same hardware before and after the change. Under MinIO, the drives were the bottleneck. Under SeaweedFS, they were almost idle, and they wrote more.

The nodes’ own system statistics (sysstat, one sample per drive every 10 minutes) cover the same hard disks under all three stores: MinIO in Kubernetes, the native MinIO-compatible fork, and SeaweedFS. (The MinIO periods cover ten of the twelve drives.) To compare equal conditions, we pair each drive sample with the node’s CPU use in the same 10 minutes. At 20–50% CPU:

Drive busy, median050100%63%36%0.8%Median request a drive served1101001,000 kBabout 10 kBabout 10 kBabout 370 kBWritten per drive, 90th pct.012 MB/s0.67 MB/s0.65 MB/s2.05 MB/sMinIO, KubernetesMinIO fork, nativeSeaweedFSThe same twelve hard disks under three stores, at 20–50% node CPU, from the nodes’ own sysstat.
Same disks, different store. Under MinIO, the drives were busy with small requests and wrote little. Under SeaweedFS, each request was about 37 times larger, the drives were almost idle, and they wrote three times as much.

On SeaweedFS, the drives were no longer the bottleneck. They wrote more and stayed almost idle, and the farm did more work than before. 852 drive samples are in intervals of 50–80% node CPU, and 392 are in intervals of 80–100%. The MinIO period has none, and the fork has 18 and 10. In these intervals, the drives were still about 1% busy. The I/O pattern also changed. The median request on a drive increased from about 10 kB under both MinIO stores to about 370 kB. The median number of I/Os per second on a drive decreased from 3–6 to 0.3.

Dropping the SSD write buffer

tierstore needs only three things from each tier: S3 with atomic create-only writes, conditional writes, and ranged reads. So the store under each tier can suit the hardware and the data, and tierstore keeps the tiers coherent with any of these stores. On the farm, the cold store changed from MinIO to SeaweedFS with a change to tierstore’s configuration. tierstore’s S3 client needed one small fix: it refuses a PUT whose body is too short, and does not keep it as an object with the wrong size.

With SeaweedFS below it, the hard disks absorb small writes themselves. SeaweedFS appends each small object as a needle to a large volume file, and keeps the index on the node’s SSD. So the drives get long sequential writes, not many small ones. The SSD write buffer of section 3 was no longer useful: the farm performed better on the hard disks alone than with the buffer in front. So we removed the hot tier. Each node’s SSD is only its local_cache (section 6).

5. The file system as an interface

S3 is a common interface, but only for programs that have an S3 client. Something must speak the protocol, sign requests and change keys into bytes. A file system is a more general interface. Every compiler, linker, script and test runner can already open a path and read it, with no client, no SDK and no code change. A build action needs exactly that: a directory that holds its sources, its toolchain and the outputs of its dependencies, as files at known paths. So tierstore also gives the same stored bytes through a file system, without a copy. This makes tierstore useful for more than one client library. You do not need to add an object store client to every tool: any program that reads files can read from tierstore directly.

Prior art

Lazy, content-addressed trees are a known technique. On Linux, composefs describes a tree as a small EROFS image that holds only metadata. Its files point to content-addressed objects by digest, and the kernel mounts it directly. Nydus and stargz load container images lazily from a table of contents. The remote execution API sends a full input tree in one Tree message. Buildbarn serves build inputs through one virtual file system core with two thin fronts. These fronts are the two standard ways for a process, not the kernel, to serve a file system. With FUSE (Filesystem in Userspace), the kernel sends each file system call on the mount to a user-space process and returns its answer. With NFS, a network file system protocol, the operating system’s own NFS client mounts a server. The server can run on the same machine, over loopback. tierstore uses these ideas, but its manifest is simpler: a binary list of fixed records, one 32-byte record and one 32-byte SHA-256 for each entry. Each file points to its byte range in a pack. tierstore checks the list in one pass and then reads it in place, with nothing to parse.

FUSE on Linux

On Linux, tierstore serves trees as a FUSE file system, from the same process as its S3 front. It uses tsfuse, our own FUSE library in the tierstore repository. The program that reads the tree makes the same calls that it makes on any disk. The kernel sends each call to tierstore, which answers from the tree in memory and the node’s cache.

FUSE mounts of S3 are not new. s3fs-fuse, goofys, rclone mount and Mountpoint for Amazon S3 all serve a bucket this way. We used what these tools had learned, and did not start again.

USER SPACEKERNELBuild actioncc, ld, a script, any programno S3 clienttierstorea process in user space;answers from manifest + cacheObject storehot_store, cold_storebytes fetched by rangeKernel VFSsame calls as any file systemFUSE modulehands each call to user spaceopen(), read()/dev/fuseS3The answer goes back the same way.The program sees an ordinary file.
FUSE in one picture. The program makes the same calls that it makes on any disk. The kernel sends them to a user-space process, here tierstore itself. tierstore answers from the tree and the node’s cache, and gets over S3 any bytes that are not local. One process, in one systemd unit (one launchd daemon on a Mac), serves both the file system and S3. A Mac has no FUSE, so an NFS server on loopback does the same job (below).

NFS on a Mac

macOS has no FUSE in the kernel and no overlay file system. So on a Mac, a different kind of file system process must serve a lazy tree, or the tree must be copied. We considered five routes on a farm Mac (Mac Studio, M3 Ultra):

RouteOutcome
Copy the tree with clonefileNot lazy: every file is cloned before the action starts
NFSv3 on loopbackChosen: Apple’s own NFS client, no kernel extension, no root
NFSv4.1 on loopback63% more requests than NFSv3 for the same read pass, and no faster
FSKitNeeds a signed entitlement and a person to switch it on
macFUSE / FUSE-TA kernel extension approved with a reboot, or a non-permissive licence

With NFSv3, tierstore serves each tree read-only over loopback, and mounts it itself as an unprivileged account. The server uses our fork of the nfsserve crate (github.com/komira-ai/nfsserve). A build is a little slower than on the native disk: 4–7% for ripgrep, and 15% for clang’s header parse when the mount is warm. But nothing is copied:

Build time, relative to native APFS0.01.0 = APFS2.0cargo build of ripgrep4–7% slowerclang, SDK headers, warm15% slowerclang, SDK headers, fresh mount2.1×Files fetched before the action startscopy (clonefile)46,362tierstore NFS mount0: each file on first readOne read-only mount per Mac: every actionshares it, so the tree is never duplicated.
The trade-off on a Mac: builds run a little slower than on the native disk, and nothing is copied before the build. Measured on a farm Mac Studio with a 46,362-file tree (the macOS SDK and a Rust project), median of five runs, with a proof-of-concept server on the same NFS library as tierstore. We did not benchmark the shipped server.

Packing

Packing prevents thousands of small writes. One object holds many files, so the store gets one large PUT and not one PUT for each file. With one object for each file, the Zig toolchain’s 15,189 files kept the old store busy for 43 minutes, and then the upload failed (section 3). The cost of a pack is that it must be unpacked. To get one file from a compressed archive, you must read and decompress the archive. So these packs are not compressed, and the application packs and unpacks them itself: kbf writes the outputs of each action one after the other into 32 MiB packs, and records the offset and length of each blob.

A pack does not need a new interface. It is an ordinary object: it is written with a whole-object PUT and read with a ranged GET. tierstore adds only one thing: a file can be a segment of a pack. The pack is not unpacked into thousands of files. The manifest below names each file by its pack, offset and size. tierstore caches the pack and mounts each segment as a file, and checks each segment against its SHA-256.

The mechanism: a manifest becomes a directory

The FUSE mount on Linux and the NFS mount on a Mac serve trees from the same description, a manifest. A manifest is a list that defines a file system. Each entry names a path. For a file, the entry also tells where its bytes are: an object in the bucket, an offset and a size. So any set of files, from anywhere in the bucket, can be mounted as one directory. This is the readable form, in JSON Lines:

# one object: cas/l/<sha256 of these bytes>, written create-only
{"format":"tierstore.tree-list","version":1}
{"path":"bin/cc","kind":"file","mode":493,"size":1048576,"key":"out/a1/0","offset":524288,"sha256":"2222…"}
{"path":"include/empty.h","kind":"file","mode":420,"size":0}
{"path":"lib","kind":"symlink","target":"bin"}
{"path":"share/doc.txt","kind":"file","mode":420,"size":12,"key":"cas/l/3333…","offset":0,"sha256":"4444…"}
{"path":"tmp","kind":"dir","mode":1023}

A file is the size bytes at offset of the object key. This is a segment of a pack, or a whole object at offset 0. tierstore checks it against its sha256 when it fills it. The manifest is also an object, named by the hash of its bytes, so the same tree is written only once. The build farm uses a binary form of the same list. The node reads it in place, with nothing to parse. The binary form also lists the reads that the tree will make, and merges nearby spans of one pack into one range. For a tree of 56,093 entries, it is 4.2 MB, against 12.4 MB as JSON Lines. Its first file is ready after 0.07 ms, against 225 ms. tree-manifest.md specifies both forms.

tierstore serves a manifest as a read-only directory. Listings, lookups and attributes come from the tree in memory. The first open of a file fills its byte range into the node’s local_cache. Every later open is served from that copy, in any tree that names the same bytes.

Mounting a tree: one small API

The control path sets up a tree for one job. It uses a small API that tierstore serves on each compute node: four calls that the job scheduler’s agent makes over a Unix socket. The caller stores the manifest as an ordinary create-only object. It then submits a job that names the manifest’s key, {provider: "tierstore", ref: <manifest key>}. So the scheduler does not need to know what a tree is. Prepare builds the tree and starts the prefetch, which continues in the background. Mount returns the directory immediately. Then the job runs. Release removes the tree when the job ends. Sweep cleans up after the agent restarts.

Callerbuild frontendJob scheduleragent on the nodetierstoremount API, local_cacheObject storeS3: hot, cold1 put the manifest: S3, create-only2 submit job: ref = manifest key3 Prepare(key)read manifest, build the treestart prefetch: every file, in the background4 Mount: the directory, at oncethe job runs: its reads take the data path (next figure) while the prefetch goes on5 Release, when the job ends
The control path. Nothing waits for the prefetch. Mount returns when the tree is in place. Between Mount and Release, the job’s reads take the data path below.

The data path is what the job’s reads do between Mount and Release. On Linux, the job’s root is an overlay file system. The job’s writes go to an upper layer on the node’s disk. The mounted tree is the read-only lower layer, and tierstore serves it. Metadata comes from the tree in memory. When a file opens for the first time, one of three things occurs: its bytes are already in local_cache from the prefetch, or the open waits for the read in flight, or the open fills the bytes itself. Later reads come from the page cache or the cached file. A Mac has no overlay, so the tree is linked into the job read-only.

Build actionany programJob root: an overlay (Linux)upper: its writes, on the node’s disklower: the tree, read-onlytierstorelookup, stat, list fromthe tree in memoryreadslocal_cacheone copy per nodebytesObject storeprefetch, or fill on first openFirst open: already prefetched, wait for the read in flight, or fill now.Later reads: the page cache, else the cached file. The tree is never written.
The data path of one job on Linux. The bytes of each file are fetched once per node, by the prefetch or by the first open. Every later read is local.

Reducing copies

A tree does not copy its inputs. On Linux, the overlay file system is on top of tierstore. The job sees one root, and its writes go to the upper layer on the node’s disk. The tree below is read-only. So nothing is copied before the job, and a file of the tree is copied only if the job changes it. A Mac has no overlay. The agent links the job’s path to the tree in the NFS mount, read-only. It does not clone the tree with APFS clonefile, which makes one clone for each file before the action starts.

Below the tree, tierstore caches each object once per node. A pack is fetched once and kept in local_cache. Every file that points into the pack, in any tree or job on the node, is served from that one copy. A blob is one cache entry, named by its digest, for all the trees that name it. The kernel’s page cache then keeps the most-used data in memory. Every action on a node reads the toolchain: each distinct byte is read 111–133 times (section 1). After the first use, the toolchain is served from RAM. The read numbers in section 3 drop the page cache before each measured pass. So they show the worst case for a repeat read, not the usual case.

Case study

6. The build farm, improved

The farm’s storage combines all the parts above into one system. Each build node runs tierstore as a local_cache in front of a SeaweedFS cold store on the nodes’ hard disks. This is the right-hand configuration of section 3.1. tierstore also serves the jobs’ inputs as a file system. Each capability removes one cost:

LINUX NODE: FROM THE JOB TO THE OBJECT STOREBuild jobin a crun container;root = overlay:upper on the local disk,lower = the treetierstoreone FUSE mount,/run/tierstore/fs:trees/ read-only,put/ for outputstierstoreone systemd unit:FUSE and S3;local_cache,no hot tierObject storeS3: SeaweedFSon the hard disks(or MinIO)readfillGETput/putPUTBlack: a read, filled on first open (or by the prefetch). Orange: outputs, committed by rename in put/ and stored as create-only objects.
The farm’s storage on a Linux node, from the job to the hard disks. Black: a read, from the prefetch or from the first open. Orange: outputs, stored as create-only objects.

On a Mac, the same parts apply. NFS replaces FUSE, and a read-only link into the job replaces the overlay. A Mac’s tierstore uses the tierstore of the Linux nodes as its cold store.

The cost

tierstore does not make storage faster than flash. It makes storage at the price of hard disks behave much more like flash where a build needs it. Each Linux server of the farm has one 1 TB SSD and two 8 TB hard disks. The SSD is only tierstore’s local_cache. A 4 KiB read takes 0.1 ms from the cache. It takes 28.6 ms directly from the hard-disk store, and 32.4 ms through tierstore on a miss. Writes go through to the hard disks, so the store below (section 4) and packing (section 5) set their speed. On large objects, every path runs at the speed of the link.

Store4 KiB read, p504 KiB writeDrive cost, six servers
Hard disks only (HDD MinIO)28.6 ms956 ms (p50)12 × 8 TB HDD: about $1,920
tierstore: an SSD local_cache over the hard disks0.1 ms cache hit, 32.4 ms missthrough to the hard disks; packed, the 15,189-file Zig tree is durable 27.4 s after the action (below)the same disks plus 6 × 1 TB SSD: about $2,520

The SSD cache costs little for the speed that it gives. SeaweedFS keeps two copies, so the farm’s 96 TB of hard disk hold about 48 TB. Divided over those usable terabytes, at approximately $20 per TB for hard disks and $100 per TB for SATA SSDs:

The cache adds almost a third to the cost of the disks. Flash for all data costs four times as much. We measured the 0.1 ms cache hit on the test machine’s NVMe. We did not benchmark the farm’s SATA SSDs alone.

The Zig toolchain

The Zig toolchain shows the full system on one real build output. On the old store, its 15,189 files took 43 minutes to upload, and then the upload failed. With the SSD buffer of section 3, the writer was released after 2.5 minutes, and the files were on the hard disks only after 36–38 minutes. On the farm, we used a copy of the tree with a salt, so that no node had its bytes, and took the median of three runs. The job packs the tree in one pass (15.6 s: walk, hash, write one pack) and commits it (11.8 s). The writer is released 27.4 s (26.7–29.1) after the action exits. At that point, the pack is durable in SeaweedFS. The store receives one pack object, one copy of the one file larger than 64 MiB, and up to 989 tree manifests, one for each directory. The old method made 15,189 PUTs. (We counted these from the writer’s code, not at the store.)

Uploading the Zig toolchain: 15,189 files, 307 MBold store: one PutObject per file, 16 in flight, from the start of the upload; today: one pack per action, from the action’s exit010203040minutesOld store43 min, then failedtierstorethree runs, salted tree27 s (26.7–29.1): packed 15.6 s, committed 11.8 s; durable in SeaweedFS when released
One real build output, two methods. On the old store, every file was its own PutObject, and the upload failed after 43 minutes. With tierstore, the writer packs the full tree into one object, and tierstore on the node commits it. The writer is released only when SeaweedFS has acknowledged the pack, so “released” means “durable”. Measured on the farm nodes (10 Gb/s), which were almost idle.

A read of the full tree takes 176–179 s directly from the HDD MinIO. With SeaweedFS below, a cold read of the full tree takes 9.24 s (8.94–13.14) on a node that never had it. A new job on the same node, with the blobs in its local cache, reads it in 1.60 s (1.55–2.05).

Read the whole tree backs (log); direct rows on the MinIO test topology, tierstore rows on the farm nodes1101001,000secondsdirect to HDD MinIO176–179direct to SSD MinIO8.4–12.0tierstore: cold, farm node9.2 (8.9–13.1)tierstore: warm, same node1.6 (1.55–2.05)
Read of the tree: 15,189 files. Direct rows: measured on the MinIO test topology (test machine over 1 GbE), with the page cache dropped. tierstore rows: farm nodes (10 Gb/s), a copy of the tree with a salt, median of three runs.

Two problems remain. On the writer’s own node, a first read took 10.6 s (two runs), about the same as a cold read. The write-through copy of the pack does not serve the reader’s per-file reads (we inferred this from the times). On a Mac, the writer is released 4.0 s after the action exits, and the put ingest stores the pack immediately after. A tree that is already local reads in 0.89 s. But the cold input fetch before the build takes 39 s (17.5–43.1), and this is most of the time.

7. The next build farm: storage nodes and compute nodes

On the current farm, every node does two jobs: it runs builds, and its drives hold the object store. Each Linux server has one 1 TB SSD and two 8 TB hard disks. The SSD is only the local_cache, and there is no hot tier. The next farm puts the two roles on separate machines. This design is planned, not built.

tierstore still keeps its own hot_store and cold_store, because they are useful on top of S3. On a cloud instance, a local_cache on the instance’s NVMe, a hot_store on S3 Express One Zone and a cold_store on S3 Standard would give the same tiers (section 8).

This is the right-hand configuration of section 3.1, on separate machines: the cache is next to the jobs, and the store is next to its drives. For a build, nothing above changes. Jobs still read trees through the file system and write packs through put. The store under each tier can still suit its hardware (section 4).

8. What’s next

  1. Amazon S3 as a tier. The tiers measured here are self-hosted S3-compatible stores (MinIO and SeaweedFS) and directories. tierstore’s own S3 client uses plain HTTP with path-style addressing, and it has no S3 Express sessions. So Amazon S3 cannot be a hot store or a cold store. The first next step is to move the tiers to Apache object_store, which has TLS, virtual-hosted addressing and S3 Express One Zone sessions. This step waits for the release of its create-only multipart completion (apache/arrow-rs-object-store#899). Then a VM in AWS can run with a local_cache on NVMe, a hot_store on S3 Express One Zone and a cold_store on S3.
  2. More object-store backends. Stores that are not S3-compatible, such as Google Cloud Storage and Azure Blob Storage, behind the same tiers. This is designed, not built.