Repository navigation
Description
Context. A model of when spin should run workspaces on EC2 bare metal rather than nested instances (published page: https://claude.ai/artifact/K6wMFnb6ow11LBBax3Ywyf, for the blog post aledbf/blog#3) has two inputs nobody has measured. The decision is spin's infrastructure's (spin-stack/spin-terraform-aws, spin-stack/spin). The measurement is the machine's, because it is the machine's I/O path that crosses two hypervisors.
What is measured (v20261122.06, spin's shape, 20 boots each): the cold first login is 418 ms nested (c8id.4xlarge, lab 45074465204) against 363 on metal (c8i.metal-48xl, lab 45074680619). The gap sits in the kernel's boot and before it, where VM exits cluster. systemd's CPU-bound stretch runs at the same speed on both. A restore is 84 against 81 ms. What a running workspace pays for nesting is not measured, and neither is how many workspaces a metal host carries (#273 measured density nested only, idle, up to 16).
Why it decides something. In us-east-1 a metal-48xl costs exactly six 8xlarges on demand. On spot (30-day median, 2026-10-23 to 2026-11-22) c8id.metal-48xl is $2.73/h against $0.49 for c8id.8xlarge, 5.5 of them. With the website's 8 workspaces per runner, a metal host must hold 44 of its 48 to cost no more per workspace (spot), and all 48 on demand. The model takes the nested tax as extra host CPU per workspace. That tax moves the break-even from 44 to 39 at 10% and to 33 at 30%, and on demand it is metal's only gain. Density on metal decides whether 44 is reachable at all.
1. The I/O tax, nested against metal
Arms. One release, one image, spin's shape (1 vCPU, 2048 MiB plugged, login as spin), and the same storage type under the overlay on both hosts. Today they differ: the bench's scratch is local NVMe (/dev/md0) and bench-metal's is its EBS root (/dev/root), and restore's read-ahead took 68-81 ms against 909-1185 ms (labs 45074649532, 45075096303). So, either of these, and say which on every table:
- local NVMe on both: bench (c8id.4xlarge) against a metal type with an instance store (c8id.metal-48xl). That needs a fleet in spin-stack/ci, as bench-metal is c8i.metal-48xl.
- EBS gp3 on both: bench on an EBS scratch volume against bench-metal on an EBS scratch volume, each provisioned with the same size, IOPS and throughput, so the volume is not the limit.
Measure each with 1 vCPU and with 4, since the tax is per exit and a busier guest exits more.
Probes needed (in internal/lab, one each, so the next person runs the same thing):
io: fio inside the guest against its own disk (the overlay, as spin serves it) and against a disk attached after boot, as spin attaches extensions. Jobs: 4 KiB random read and write at QD1 and QD32, 1 MiB sequential read and write, each 30 s after a 5 s ramp. Report IOPS, MiB/s, p50/p99 completion latency, and the guest's and QEMU's CPU time per GiB moved. The CPU per GiB is the number the model needs. Throughput alone can tie while one side burns twice the CPU.build: a fixed, cached workload a workspace actually runs, timed from start to exit: adocker buildof a pinned Dockerfile with its base layers on the disk, or a Go build of a pinned tree if the image carries no Docker. Report wall time and the host CPU time QEMU's threads used (/proc/PID/task/*/schedstat, asrun-delayreads it).- A network row, if the probes can drive one cheaply: iperf3 from the guest to the host over the workspace's network path, reporting CPU per GiB as above.
Rows. nested and metal × the storage arm × 1 and 4 vCPUs, 20 runs a cell, interleaved within a host. Nested and metal are two runs, so their difference is a lead sized against the bench's ~8 ms run-to-run drift for latency, and against each cell's own spread for throughput and CPU.
What it gives the model. The tax is (host CPU per unit of work, nested) ÷ (the same, metal) − 1, for each workload. The model's dial is that number.
2. Density on metal
Arms. density (#273, internal/lab/density.go) as it stands, on bench-metal: crowds of 0 16 32 48 64 96, with load=idle and with load=cpu, spin's shape with 2048 MiB plugged. And the same crowds scaled to the bench's 16 vCPUs (0 4 8 16 24), load=cpu, which #273 has not run.
Read. The largest crowd whose first login p95 stays within 25% of the empty host, per host and load, and the crowd's own boot-and-login time. Add the io probe as a load (load=io, every crowd member running the 4 KiB random-write job) if the first round shows CPU is not the limit, since a metal host shares one disk and one NIC across six times as many workspaces.
What would change the answer
- The tax under ~5% for the build and fio's random 4 KiB jobs: nesting costs a running workspace nothing the model can see, metal pays only on spot and only above ~44 of 48 workspaces (c family), and spin stays nested.
- The tax at 10% or more: metal's break-even falls under ~40 of 48 (80% full) on spot, and on demand metal wins at any fill above six times what a nested host holds after the tax (42 of 48 at 10%). Then a metal runner type is worth adding to spin-terraform-aws for fleets that keep it full.
- Metal density under ~44 workspaces at 4 host vCPUs each (p95 past the 25% line, CPU-bound): metal never reaches break-even at the website's density, whatever the tax.
- Storage held equal moves restore or the build by more than the noise: the storage choice (instance store against gp3) is a variable of its own in the model, and the d-variant's 18% premium is priced against that number.
Each result lands as a row in docs/boot-time.md and a dated entry in docs/log.md with its run, and the model's dial is set from it.
🤖 Generated with Claude Code
Activity
aledbf commentedon Nov 22, 2026
The candidate search, us-west-2 (2026-11-22). The first model compared c8id/c8i in us-east-1 only. The model now ranks 118 us-west-2 types: every type whose processor reports
nested-virtualizationin the families and sizes a fleet of 8-48 workspaces runs on, and every x86 metal type from the 6th generation on, minus GPU hosts and the x families. Page: https://claude.ai/artifact/K6wMFnb6ow11LBBax3Ywyf. us-west-2 is also where spin-stack/ci'sbenchandbench-metalfleets run, so the two measured latencies are from the same region.Inputs. On demand from AWS's public price list (published 2026-11-21). Spot from
DescribeSpotPriceHistory, 2026-10-23 to 2026-11-22, time-weighted over zones. Interruption bands from the Spot Instance Advisor.GetSpotPlacementScoresfor the metal types only, because the API refused new configurations after 50 in a day. gp3 costs $0.08/GB-mo, $0.005/IOPS-mo and $0.04/MiB/s-mo in us-west-2, the same as us-east-1. Everything was read-only.Nested candidates. The API and the EC2 user guide agree: C7i, M7i, R7i, C8i, M8i, R8i, the 8th-gen d variants, I7i, I7ie, R7iz, X8i and the flex types. No AMD type supports nested virtualization. So every AMD option is a metal option.
Ranked, spin's website shape (4 host vCPUs, 2 GiB), spot p50, $/workspace-hour. Today's runner is c8id.8xlarge at $0.0763.
With the filter set to interruption under 5%, c8i.metal-48xl ranks first at 48, 96 and 480 ($0.0538, 29% under today's runner), and at 8 the first is c8i.4xlarge ×2 ($0.0838).
On demand at 4 vCPUs, nested c7i.8xlarge wins at 8 ($0.1822). From 48 up the first is c6a.metal ($0.1584), an AMD host that nested cannot use. With 1 vCPU or less per workspace, nested d types (c8id.12xlarge and 24xlarge, m8id) win up to 96. Metal first wins at 480 (m8idn.metal-48xl, $0.0148 against $0.0160). At 0.5 vCPU, a 30 GiB cache per workspace on the instance store is what limits the d types.
What moved from the first model.
docs/log.md's 11-13 entry, where bench-metal spot failedUnfulfillableCapacityin every zone.DefaultThreadsPerCore1), so the page has an AMD vCPU speed dial, flagged unmeasured, at 1.0. At 1.0, AMD metal is never first on spot. On demand, c6a.metal is first from 48 up.The options worth measuring next.
bench-metalfleet). It is the only metal type with both a measured boot and an interruption band under 5%. Changes the answer if 33 or more workspaces fit within the 25% p95 line. Then metal beats today's runner on spot at 48 or more. Under 33, it never does at 4 vCPUs.bench-metal-nvmerunner in spin-stack/ci (familyc8id.metal-48xl, no nested-virt, scratch on the instance store). Changes the answer if restore or the build moves by more than noise. Then the NVMe premium (break-even 42 against 33 for gp3) buys latency, and the model prices it. If not, gp3 metal is the cheaper metal.family = ["c8in.metal-48xl"], spot only, and a record of pending time and fulfilment failures over a week of lab runs, plus one cold-login run. Changes the answer if spot fills in most attempts and cold login matches c8i.metal-48xl's 363 ms. Then it replaces c8i.metal-48xl as the metal candidate. If spot rarely fills, the price is not real.bench-metal-amdrunner, cold login plus section 1'sbuildprobe for CPU time per build. That measures the AMD speed dial. Changes the answer if an AMD vCPU does 1.4 or more Intel vCPUs' work. Then c8a.metal-24xl holds 33 or more at 4 vCPU-equivalents and costs under c8i.metal-48xl per workspace, on a 24-workspace step. On demand, c6a.metal is already first from 48 up at 1.0, so only its cold login stands between it and a runner type.bench-c7irunner (c7i.4xlarge, nested-virt, which AWS added to 7th-gen Intel on 2026-06-18) and one cold-login run. Changes the answer if 7th-gen nested is within noise of bench's 418 ms. Then spin-terraform-aws's runner types can add c7i for small fleets.Two runs are two machines, so each comparison is interleaved against bench in one run, as
docs/measuring.mdsays.Scripts, all rerunnable and read-only:
fetch_usw2.sh(describe, prices, spot, advisor, gp3),candidates.py,placement.sh,prices_usw2.py,model.js,rank.jsandbuild.py.🤖 Generated with Claude Code
aledbf commentedon Nov 23, 2026
The research's scripts, to rerun the model (us-west-2, read 2026-11-22). They are read-only:
describe-instance-types, the public on-demand list,describe-spot-price-history, the public Spot Advisor data, gp3 from the Price List API, andget-spot-placement-scores(capped at 50 distinct queries a day). Each needs AWS credentials from the environment and names no account. The page's source is the published artifact (page.src.html, built bybuild.py).Order:
fetch_usw2.sh OUT→prices_usw2.py→node rank.js(rankings) →build.py(the page).placement.shreads "type hosts" lines on stdin.prices.pyis the first model's us-east-1 reduction.fetch_usw2.shcandidates.pyprices_usw2.pyplacement.shmodel.jsrank.jsbuild.pyprices.pySpot placement scores, metal types (type, hosts, score of 10)
aledbf commentedon Nov 23, 2026
Section 2, density on metal: measured (2026-11-23)
densityran as it stands: v20261123.04, spin's shape (1 of 16 vCPUs, 2048 MiB plugged) and spin's login. The cell is the first login's p50/p95 in ms. "Within 25%" means a p95 within 25% of the empty host's in the same run.cpus=4would answer that one.The rows are in docs/boot-time.md ("The bench fleet is nested, not metal") and docs/log.md via #633.
Section 1, the I/O tax: still open
Nothing has been run for it. It needs new
ioandbuildprobes in internal/lab. It also needs equal storage on both hosts, either an NVMe metal fleet in spin-stack/ci or EBS scratch on both. The issue stays open for that.docs: density on metal, and a CPU-bound crowd on the bench (#563)
lab: io's parsers held by tests, its host-only helpers by the KVM lane (
lab: io and build, what a running workspace's I/O and build cost the …
lab: io's parsers held by tests, its host-only helpers by the KVM lane (
aledbf commentedon Nov 27, 2026
Section 1, the nested tax on a running workspace's I/O and build: measured (2026-11-23)
Measured by #671's
ioandbuildprobes on its branch, with release-era parts of 2026-11-23. Shape: 1 of 16 vCPUs, 2048 MiB plugged, spin's login. The disk sits on the host's tmpfs in both hosts, so what differs is one hypervisor against two and not the device. The cell is the p50 of the tree with 1 vCPU.go build cmd/go, empty cache, wallRuns: io on metal lab 45237396777, io nested lab 45243154692 (10 a row); build on metal lab 45247518766, build nested lab 45250242635 (15 each). Each run's result.json also has the four-vCPU tree, completion latency p50/p99 and QEMU's host CPU.
Reading for the cost model: nesting costs a small random I/O about half its IOPS and about twice its guest CPU. Large sequential I/O and a CPU-bound build lose 0-10%. The machine has changed since then only in its boot (PVH, jemalloc), not in the I/O path, so the reading stands until a release changes the block path (inferred).
The probes stay on branch
archive/lab-563-io-tax, not on main: one question's tool, which spin's cost model asks only when it is recomputed. To run it again, rebase that branch and dispatch lab.ymlioorbuildon bench and bench-metal.With section 2 (density, above), both of this issue's sections are measured. The decision is spin's (spin-stack/spin#1652).
aledbf commentedon Nov 27, 2026
Both sections measured (density on metal above, the nested I/O and build tax in the last comment). What to do with them is spin-stack/spin#1652's.
docs: density on metal between 64 and 96 busy vCPUs, and at 4 vCPUs