roadmap NOT-STARTED

1070. The placement curve: what moving one component across the kernel boundary costs, in cycles

Raised by lane proposal/the-placement-curve, at the architect's request. It replaces a heavier idea that would have built four whole operating systems from one set of components.

Reuse: the kernel bench (kernel/src/bench/, cargo xtask bench, script/board-image --bench). The cycle counters of milestone 74 (cycle counters) and milestone 309 (unhalted core cycles on x86_64). The repeat discipline of milestone 168 (a multi-tasking workload benchmark). The manifest readers capability_manifest_note and program_asks, and the in-memory disk in vendor/redoxfs/src/disk/memory.rs. No new dependency.

Background

nife runs its services as processes. A file server, a block driver or a network stack each lives in its own address space, and a client reaches it by a synchronous call through the kernel. §10 (the capability-based microkernel process model) chose that shape for fault isolation and least authority, not for speed. Its own table says where the price sits: capabilities as a naming model cost about nothing, and servers in userspace carry "the entire cost". It adds that the real bite is cache and TLB pollution, not the trap itself.

The tree has never measured that price on its own code. Risk 4 (the per-crossing cost) ran its decisive experiment on radon and held, but its entry lists one bound that no instrument here can lift: "One kernel model, so there is no ratio". Every bench row compares nife with itself or with Linux, never the same component inside and outside the kernel.

The placement curve is that ratio. Take one component's code unchanged. Run it as a process, as today, and run it as a kernel-side thread behind the same runtime API. Then place components one at a time and record cycles per request at each step. The curve shows what each crossing costs once real code, with a real cache and TLB footprint, sits on either side of it.

A second, separate measurement asks what each component can reach. It is a static census, run on no machine, and it answers §82 (ambient authority is the problem)'s open line: "Nothing measures grant width."

Recommendation

Build the smallest first experiment below, on radon, and let its decision rule say whether the rest of the curve is worth building. Build the authority census beside it, since it costs no machine time and its result stands whatever the curve shows. Keep every kernel-side placement behind a bench feature that no shipped image enables, as disk_throughput and network_bench already are.

What is measured, and how

The unit is core cycles per request, read on bare metal. QEMU's -icount mode counts guest instructions, and the committed baselines (bench/baseline-*.txt) are in those units. An instruction count cannot see a cache miss or a TLB refill, which is the cost §10 says dominates. So an emulator run proves the build works and nothing about the curve.

The kernel-side form has two depths, and the curve names which one each point uses.

  1. A kernel thread, IPC kept. The component runs in the kernel's address space and still receives its requests through a rendezvous. A runtime crate offers the user_mode_runtime API (crates/user_mode_runtime/src/system_call.rs, invoke), with each call entering the kernel's capability dispatch as a function call and checking the table as before. This isolates the trap, the address-space switch and the cache and TLB effects. The name of that crate is the architect's; this proposal mints none.
  2. A direct call. The client calls the server's handler with no rendezvous. That needs each component's handler split from its serve loop. redoxfs_server already has one (Server::handle in redoxfs_server/src/dispatch.rs); I did not check which others do.

The ends of the curve already exist as rows. ipc_rtt and call_reply in kernel/src/bench/ipc.rs time a round trip between kernel threads, and the EL0 rows in kernel/src/bench/el0.rs time one between processes, with ipc_rtt_el0_cycles reading core cycles directly (notes/benchmarks/kernel-bench-harness.md). Their difference is the bare crossing with no work behind it. The curve asks how much a real component adds to that difference.

The smallest first experiment, and its decision rule

One component, two placements, on radon, one hart.

Call the bare crossing difference D_ipc, from the ipc_rtt rows taken in the same boot. Call the component's difference D_fs, cycles per request at P0 less those at P1. The ratio is D_fs over D_ipc.

The rule, a provisional maintainer decision written before any number exists, so a result cannot choose its own threshold:

The bounds change only by a new dated decision made before results arrive.

The second measurement: what each component can reach

A static census over every shipped program, run on the host. It reads each program's manifest note (crates/capability_manifest_note) and its asks (crates/program_asks) and prints, per program:

The census and the curve stay separate measurements. Placement changes both at once, though, so the written result sets them side by side: each point on the curve buys its cycles with a known widening of authority.

Confounds

  1. Instrument blindness. Instruction counts miss cache and TLB cost, so only silicon counts.
  2. Per-core counters. ipc_rtt_el0_cycles refuses to run with more than one core online, while the file system rows fs_read and fs_throughput (kernel/src/bench/filesystem.rs) run only with --real --smp. The first experiment therefore needs its own single-hart row, which the memory disk makes possible.
  3. Code placement. Moving radon's kernel text by a few bytes moves the null system call by up to 8 ticks (7%), per risk 4's entry. Compare placements across several builds, not one.
  4. Untuned components. A slow component hides boundary cost behind a large denominator. The NVMe server keeps one command in flight, and radon's board images carried debug userspace until milestone 797 (release userspace in board images). Use release builds and state each component's known limits beside its point.
  5. Uneven glue. The kernel-side runtime is new code and can be tuned more than the trap path, or less. Freeze it before measuring and publish its size.
  6. Not a textbook microkernel. Device control planes already live in the kernel (for example kernel/src/e1000e.rs and kernel/src/non_volatile_memory_express.rs). P0 is nife as it is, and the written result says so.
  7. DMA confinement. Once a device path joins the curve, a kernel-side driver loses its IOMMU or virtio validation. That is a third variable on the same axis; report it, do not net it out.
  8. Kernel-thread address space. I did not check whether switching to a kernel thread on radon or xenon changes the page-table root or the address-space identifier. The answer decides what P1 saves, so the first lane reads it before measuring.
  9. A strawman ambient policy. The census models a policy that capability advocates wrote. Define it from POSIX, cite it, and publish the model beside the numbers.

Prior art

Every item here comes from memory, and none was read for this proposal. Dates and figures are unverified.

Where nife differs: its components already take every resource as passed-in state, which §4 (the kernel shape) rule 2 required from the start, and one choke point carries all authority (invoke). So the move costs a runtime and a window seam, not a port. I know of no published system that measures the curve one component at a time on the same code; I may be wrong.

A concrete example of the result's shape. Today a warm file read crosses twice: client to file server, and file server to block server. With the block server kernel-side, the read crosses once into a process; with both kernel-side, it never leaves the kernel. Three points, the same code at each, cycles per request on one axis.

The seven questions

  1. Other options. Four whole operating systems lost: one per cell of capability or ambient authority, and microkernel or monolithic. Two of those cells need ambient authority, which §10 forbids on main. And §10 predicts the cost of capabilities against ambient authority is about zero, so that axis would likely show only noise. Comparing nife with Linux alone lost too: it varies every component at once.
  2. The tree's analogous case. Milestone 8 (the console driver leaves the kernel) moved a kernel-thread server out to a process (notes/capabilities/ipc-endpoints.md), and disk_throughput already runs its client in the kernel's boot thread against a process server. Neither timed both placements of one server.
  3. Prior art. Above, all from memory.
  4. The premise. §10 states the cost lives in the boundary and in cache pollution, and also that "We will never measure it". This proposal measures it and does not edit §10. A result that contradicts its table goes to the architect as its own proposed amendment.
  5. Cost. The effort guesses below; the machine time is one radon evening with a person for the first experiment.
  6. Reversibility. The code is a bench feature and can go. The published number cannot: see the doors.
  7. Same cost both ways. Yes. The census and the single-component experiment are also the cheaper options, but they win on what they isolate, not on effort.

Doors

Effort, guessed

All three figures are guesses with no measurement behind them.

What it depends on

The written result

One figure per machine: cycles per request on the vertical axis, components placed kernel-side on the horizontal, with the bare-crossing anchors drawn in. Beside it, one table per program: granted, ambient, kernel-side. The claim it can support is narrow and checkable: on this silicon, with this code, moving one component across the boundary costs this much, and buys this much authority. That is a workshop-length paper, and its text and numbers go to the architect before it leaves the tree.

Not in scope

What is not verified

Index row

Nothing in the tree compares one component inside and outside the kernel. This measures, in cycles on silicon, what placing each component kernel-side costs, beside a census of what each can reach.