notes

Throughput, and where the milliseconds actually go

An appendix to notes/fs-server.md. It holds milestone 38 (filesystem throughput, and the comparison): what a read costs and why, the cache that was not there and then was, the transfer unit, and the throughput BUGS.

The per-request number, and the record behind it

The per-request number has been here since milestone 32 (a real filesystem: RedoxFS behind a capability FS server) built this server: fs_read, ~204 us. There was no MB/s figure at all, which is what milestone 38 was for. The four phases now live in fs_test_client's throughput role and kernel/src/bench.rs's fs_throughput. The cross-OS side is in notes/benchmarks.md. Two results belong here, next to the server they are about.

Every 4 KiB read of an ordinary file fetches the whole record, whatever offset it asked for. At milestone 38's 128 KiB record that was 32 blocks for 4 KiB of use. fs_read reads motd, 69 bytes, which RedoxFS keeps inline in the node. That is the cheapest read this server can serve, at ~207 us, and it is a tree walk with no record at the end of it. A 4 KiB read of an ordinary file was ~1.51 ms. Dividing by 32 gave 46.2 us per 4 KiB block through the block server. That constant then explained every other figure: an inline read is 4.5 blocks, a sequential write is 55, a random write is 74.

Two things in that paragraph no longer hold, and it is kept because the reasoning is why. The 46.2 us was an average that charged the per-request tree walk to the blocks. The sweep of milestone 138 (close the read gap: a 4 KiB request must stop moving 128 KiB) separated the two with six points and a slope. The marginal cost of a block is 39.0 us, with a separate ~208 us walk per request. And the record is no longer 128 KiB. Step 1 took it to 8 KiB, so a 4 KiB read is now ~284 us and fetches two blocks. See notes/benchmarks.md.

The mechanism is one level below where it looks

Milestone 38's bench found that out by predicting the wrong thing and measuring. read_node_inner asks for the record at BlockLevel::for_bytes(offset_within_record + len). That is level 0 at the start of a record and level 5 at the end, so a read at a record boundary should have been cheap. It is not. read_record reads the block the pointer stores, and only then checks whether that is as large as the level requested. A fully written record is stored at level 5. The bench keeps the phase that refuted the prediction (fs_record_read) for exactly that reason.

None of this is the isolation. relay_rtt prices one confined intermediary at about a microsecond, three orders of magnitude below a read. 46.2 us per block is the same as Linux gets on the same virtio device at the same tier (notes/benchmarks.md has that comparison).

There was no cache, and then there was

There was no cache anywhere in this path, and the throughput numbers are how we finally proved it. redoxfs_server's IpcDisk was a bare Disk with no DiskCache wrapped around it, so a re-read went back to the device. That had been stated and never demonstrated. Milestone 38 demonstrated it by measuring sequential, random and record-aligned reads of the same file, and getting the same per-request cost to within 3% (1.51, 1.48 and 1.48 ms). A path with a cache or a readahead cannot do that. It also finally retired a comment in fs_test_client that had claimed fs_read was a warm measurement.

Milestone 138's step 2 wraps IpcDisk in CachedDisk (redoxfs_server::CachedDisk, redoxfs_server/src/block.rs). It is a small direct-mapped write-through cache of single-block reads: 64 slots, ~257 KiB. It answers exactly the repetition milestone 38 found and this section names above. That is Transaction::read_tree_and_addr's five-block tree walk, answered from memory when the walk resolves the same node it last resolved. It does not cache a record body. Any Disk::read_at wider than one block bypasses it entirely, still batched instead per step 4. It never serves stale bytes. A write updates or invalidates the relevant slot only after the inner disk confirms the write landed. RedoxFS's copy-on-write allocator means a live address's content can only ever change through that same write path. redoxfs_server::CachedDisk's own doc argues the invariant in full. Six host tests, including a stale-read regression, check it in milliseconds with no emulator.

What this means for the "no cache" claim above, stated exactly rather than softened. It was true of the build milestone 38 measured, and it is not true of the build this tree ships today. A repeated fs_read now answers from the cache after the first request in a session. (motd is stored inline in its node, so its entire content rides on the tree walk, with no separate record read at all.) That is the case a cold-vs-warm distinction was previously impossible to make: 210,490 ns median to 9,474, 22.2x, eight interleaved rounds at each point (sh bench/cache-slots-sweep.sh 8 1 64). bench/cache-slots-sweep.sh is the instrument that isolates it. Its own doc explains why capacity 1 is "approximately off" rather than a true zero.

Sequential, random and record-aligned reads of a different file, or the first access of any file in a fresh session, still pay the uncached cost this section describes. Every earlier number in this file and in notes/benchmarks.md was taken against the uncached build. Each is a fact about that build, not a fact this section now retracts.

The transfer unit: one page until milestone 138 step 3, sixteen since

A READ or WRITE moves its bytes through the region the client and the FS server share, and that region was one page. Nothing in the wire word ever required that: file_system::request has carried a 40-bit length since milestone 32. So the multi-page transfer milestone 38's BUGS entry called for turned out to be one constant, file_system_contract::file_system::TRANSFER_PAGES. There was no new opcode, reply word, descriptor or changed field.

What a party maps, and the one rule that makes old clients safe. The FS server maps the whole channel, because it serves whatever length a request asks for. A client maps as much as it intends to use. swish, the three caretakers, the sinks and the std PAL still map exactly one page, and still ask for one page. They are untouched by the step and cannot tell it happened. That is a property rather than a convention, and the serve loop is where it is enforced:

What is not checked, marked because it is rung four of CLAUDE.md's ladder and not rung one: nothing stops a client asking for more than it mapped. It gets a data abort on its own second page, after the server has already done the work. It is the same agreement a client already has with its wiring about where the region lives. Every FS client hardcodes its FILE_VA, and kernel/src/user/fs_service.rs carries a comment saying it must match. This is one number wider, rather than a new category. Making it unrepresentable needs the channel size to travel on the wire, which is a new concept on this contract, and was deliberately not taken.

The kernel wiring allocates the channel as a contiguous run of frames (file_channel). So both halves of the agreement still pass it around as one physical base address, and each mapping site is a loop rather than a signature change. The block server's DMA region was already wired this way.

BUGS