Tuned · settings changed for speed

Can settings fix what a sandbox costs?

The Compare page shows each sandbox as it ships. In iteration 6 the same tests ran again on one node with each sandbox's settings changed for speed, and the as-shipped setup ran beside it in the same pass. Everything on this page is tuned data. The default numbers on the Compare page are unchanged; this page stands beside them.

Node: m8id.xlarge (4 vCPUs, Xeon 6975P-C, local NVMe, us-east-2), nested virtualization · Pods: 1 CPU / 2 GiB · containerd · Kata 4.3.1 (Rust runtime), gVisor release-20261102.0 · 2–3 measured rounds per cell after a warm-up, 8 in the repeat run · every number is against the runc pod in the same group, same hour · Sysbox and plain host containers were out of scope

Verdict

What tuning fixes, and what it doesn't

fixedKata's slow filesUnpacking node_modules took 11.0 s through Kata's shared folder against 0.20 s on runc (54× slower). With the container's disk handed to the VM as a block device it takes 0.10 s (0.50×). Volumes get the same fix: 72× down to 1.11×.
fixed for 1-CPU podsKata's slow wake-upsA 1-CPU pod got a 2-vCPU VM, and waking a process on the other vCPU means leaving the VM. With one vCPU, passing a message between two processes drops from 37.8 to 1.46 microseconds (7.4× down to 0.29×). A 2-CPU pod gets the cost back (3.6×).
halves the gapThe CPU limit pays for the sandboxgVisor's own kernel and Kata's helper processes run inside the pod's 1-CPU limit. In a loop of kernel calls gVisor was paused for 27.3 of 41.0 seconds; runc never. Telling Kubernetes about the overhead takes gVisor's unpack from 3.6× to 1.84×.
better, not closedNetworkKata QEMU sends 8.2× slower than runc as shipped and 3.2× tuned; receiving goes from 3.4× to 1.02×. Cloud Hypervisor stays far behind (42× as shipped, 38× tuned).
not fixedSaving writesA Kata block disk saves 2,490 writes a second against runc's 19,897 (8.0× slower). The storage pool under the VMs explains a part (runc on the same pool: 12,166); crossing the VM boundary on every save is the rest.
not fixedStartupMeasured below Kubernetes, a tuned Kata QEMU pod takes 2.5 s to start, Cloud Hypervisor 1.1 s, runc 0.2 s. Almost all of it is the guest booting, and none of these settings touch that.

As shipped against tuned

Scorecard: times slower than runc

1.0 is runc's speed in the same group of pods. 5× means five times slower, 0.5× twice as fast. "Shipped" is the default setup, "tuned" the full set of settings listed further down. Kata Firecracker ships with a block disk and one vCPU already, so it has one column. Tuned includes a pod overhead of 1 CPU and 512 MiB, so a tuned sandbox pod can use 2 CPUs where runc's has 1. The network and gVisor rows depend on it; the disk rows do not.

fastersame or within 25%1.25–3×3× or more– not measured
TaskKata QEMUKata Cloud Hyp.Kata DragonballgVisorKata Firecracker
shippedtunedshippedtunedshippedtunedshippedtunedshipped
Start a pod, below Kubernetes (seconds added)+2.1 s+2.3 s+0.8 s+0.9 s+2.2 s+2.3 ssamesame+2.3 s
Cheapest kernel call0.58×0.60×0.61×0.62×0.58×0.61×59×29×0.59×
Open and close a file153×0.33×181×0.38×0.58×0.36×6.5×3.1×0.37×
Pass a message between two processes7.4×0.28×5.0×0.31×2.68×0.28×7.3×3.5×0.30×
Start a process (fork + wait)2.30×0.33×2.48×0.35×1.47×0.32×11×5.5×0.32×
Run a program (exec)18×1.59×21×2.21×8.3×2.06×12×6.4×1.59×
Unpack node_modules (container disk)54×0.49×69×0.58×136×0.55×3.6×1.84×0.51×
Unpack node_modules (volume)72×1.10×93×1.49×187×1.11×5.9×2.22×0.66×
Delete that tree (volume)50×1.34×59×1.28×150×1.12×4.0×2.35×0.66×
Clone a repo from a local copy (volume)32×1.21×44×1.33×96×1.44×7.0×3.4×0.95×
Send to the node, one stream8.2×3.2×42×38×22×–5.1×2.96×9.9×
Receive from the node, one stream3.4×1.02×14×12×5.0×–5.5×2.83×3.5×
Save each write before the next (container disk)4.1×8.0×––––––7.7×
  • Tuned Kata beats runc on kernel calls and on files on the container disk. The guest kernel runs without the node's seccomp filter and audit hooks, and its disk is a plain ext4 block device where runc's is an overlay.
  • The save-each-write row gets worse with tuning on Kata QEMU: the shared folder it ships with saves 4,814 writes a second, the block disk 2,490.
  • The disk row for tuned Kata QEMU was measured without the extra CPU allowance. gVisor has no disk row: its sandbox answers from its own cache, so the number is not a disk number.
  • A repeat run with 8 measured rounds matched the tuned columns within 3% on the unpack and kernel-call rows. The short delete and clone tests move up to 10% between runs.

Kata QEMU

One change at a time: times slower than runc

Each column is its own pod, measured in the same pass. Two causes account for nearly all of Kata's cost on these tests: files travel through a folder shared from the node (virtio-fs), and a 1-CPU pod gets two vCPUs.

TaskAs shippedBlock container disk+ block volumesBlock disk + 1 vCPUAll of itKata Firecracker
Unpack node_modules (container disk)54×0.54×0.55×0.50×0.50×0.51×
Unpack node_modules (volume)72×71×1.44×44×1.11×0.66×
Delete that tree (volume)50×51×2.33×31×1.61×0.66×
Clone a repo (volume)32×29×2.58×19×1.11×0.95×
Open and close a file153×0.38×0.35×0.33×0.33×0.37×
Pass a message between two processes7.4×7.7×6.1×0.28×0.29×0.30×
Start a process (fork + wait)2.30×1.46×1.46×0.31×0.32×0.32×
Run a program (exec)18×2.17×2.16×1.59×1.59×1.59×
  • The block disk fixes the container's own files and nothing else. A volume (emptyDir) still goes through the shared folder until volumes are block devices too.
  • One vCPU fixes wake-ups and process starts. It does not fix files, and the block disk does not fix wake-ups: the two are separate causes.
  • Tuning the shared folder itself (more server threads, caching, DAX) moved the unpack by about 5%. The folder is the cost, not its settings.
  • Tuned Kata QEMU lands on Kata Firecracker's numbers, which uses a block disk and one vCPU as shipped. Tuned Cloud Hypervisor and Dragonball land there too.
  • The file work also stops burning CPU: one pass of the file tests used 18.9 s of CPU as shipped and 0.81 s tuned.

1-CPU limit

The CPU limit pays for the sandbox, not only your process

Kubernetes enforces a pod's CPU limit on everything in the pod's group: the process, and also gVisor's kernel, or Kata's VM and its helpers. When they add up to more than one CPU, the pod is paused until the next 100 ms period. "Paused" below is the time the kernel reports the pod spent held back.

Loop of kernel calls, as shippedTookPausedCPU used
runc2.86 s0.00 s2.73 s
gVisor41.0 s27.3 s40.6 s
gVisor, 2-CPU limit20.4 s1.01 s40.0 s
gVisor KVM mode14.1 s3.47 s14.0 s
Kata QEMU49.6 s26.2 s49.2 s
Kata QEMU, 2-CPU limit32.6 s2.85 s60.1 s
Kata Cloud Hypervisor67.4 s41.0 s66.7 s
Kata Dragonball10.5 s5.70 s10.5 s
Kata Firecracker2.02 s0.00 s1.97 s
File tests, as shipped and tunedTookPausedCPU used
runc0.45 s0.01 s0.39 s
gVisor2.18 s1.40 s2.15 s
gVisor, tuned0.98 s0.10 s1.86 s
Kata QEMU19.1 s14.3 s18.9 s
Kata QEMU, tuned, no overhead0.85 s0.07 s0.81 s
Kata QEMU, tuned0.79 s0.00 s0.82 s
Kata Cloud Hypervisor, tuned0.97 s0.03 s0.93 s
Kata Firecracker0.75 s0.03 s0.70 s
  • gVisor spends two CPUs' worth of work per CPU of yours on kernel-call loops, so under a 1-CPU limit it runs at half speed. A 2-CPU limit halves the time and uses the same CPU.
  • The fix that keeps the pod's own limit at 1 CPU is pod overhead: a RuntimeClass that declares 1 CPU and 512 MB for the sandbox. Kubernetes adds it to the limit and counts it when placing pods. It measured the same as a 2-CPU limit.
  • For Kata the block disk removes the load instead: no shared-folder server, nothing to pause. Kata Firecracker was barely paused.
  • This applies to the default numbers too. The gVisor and shared-folder Kata results on the Compare page include this pausing, which is what a 1-CPU pod gets as shipped.

gVisor

gVisor: about half the gap closes

Times slower than runc. The overlay keeps file changes inside the sandbox. Pod overhead gives gVisor's kernel its own CPU allowance. KVM mode swaps how gVisor catches kernel calls and needs nested virtualization or bare metal.

TaskAs shippedOverlayPod overheadBoth (tuned)KVM modeKVM + overlayKVM + both
Cheapest kernel call59×60×30×29×4.8×4.8×4.8×
Open and close a file6.5×6.1×3.2×3.1×2.18×2.16×1.99×
Pass a message between two processes7.3×7.2×3.6×3.5×2.03×2.03×1.56×
Start a process (fork + wait)11×11×5.5×5.5×5.1×5.0×4.0×
Run a program (exec)12×12×6.4×6.4×7.9×7.9×6.9×
Unpack node_modules (container disk)3.6×3.6×1.92×1.84×4.5×4.6×4.3×
Unpack node_modules (volume)5.9×4.5×3.1×2.22×13×6.1×5.8×
Clone a repo (volume)7.0×8.9×3.5×3.4×11×6.4×5.8×
  • Pod overhead does nearly all the work: the cheapest kernel call goes from 59× to 29×. The overlay alone only helps the unpack on a volume.
  • What is left is gVisor's design. Every kernel call is caught and handled by a second kernel written in Go, and that costs a few microseconds each time.
  • KVM mode is the other route: the cheapest kernel call is 4.8× runc's time in place of 29×. Files are slower on this nested node (4.6× on the unpack), and the overlay matters more there: the volume unpack goes from 13× to 6.1×. Pod overhead adds little, because KVM mode was barely being paused.
  • So there is no single best gVisor setup. Work made of many small kernel calls wants KVM mode; file-heavy work wants the default mode with overlay and pod overhead. On bare metal KVM mode's file cost is lower (see the Bare metal tab).

Pod to node, one TCP stream

Network

RuntimeSendReceive
MB/sslower than runcMB/sslower than runc
runc6,4311.00×6,4891.00×
Kata QEMU, as shipped7828.2×1,9103.4×
Kata QEMU, tuned, no overhead1,1875.4×2,9302.21×
Kata QEMU, tuned2,0293.2×6,3321.02×
Kata Firecracker, as shipped6499.9×1,8673.5×
Kata Firecracker + pod overhead8267.8×3,0982.08×
Kata Cloud Hypervisor, as shipped15342×47014×
Kata Cloud Hypervisor, tuned16838×55912×
Kata Dragonball, as shipped28822×1,3035.0×
gVisor, as shipped1,2615.1×1,1725.5×
gVisor, tuned2,1712.96×2,2952.83×
  • Two things helped Kata QEMU: a second queue on the virtual network card, and the CPU allowance from pod overhead, because the node-side half of the virtual network card runs inside the pod's limit. Together receiving comes within 15% of runc.
  • Sending stays at about a third of runc. Each batch of packets still crosses the VM boundary, and on a nested node every crossing passes through two hypervisors.
  • Cloud Hypervisor's network is slow for a reason of its own. A larger packet size (MTU 9001) made it 3.6× faster and it was still the slowest; the Bare metal tab shows the same on metal.
  • The small-message test swung too much between runs to publish.

Container disk

Saving writes

"Saves a second" writes 4 KB and waits for the disk to confirm before the next write, as a database does. The node disk is local NVMe. Kata's block disks are carved from a storage pool (devicemapper thin pool) on the same NVMe.

SetupSave each writeWrite a big fileSmall random reads and writes
saves/sslower than runcMB/sslower than runcper secondslower than runc
runc, node disk19,8401.00×6221.00×16,2571.00×
runc on the VMs' storage pool12,1661.63×5961.04×16,0571.01×
Kata QEMU as shipped (shared folder)4,8144.1×3112.01×14,1631.15×
Kata QEMU, block disk2,8307.0×2033.1×20,4530.79×
Kata QEMU, tuned2,4908.0×2342.72×21,1420.77×
Kata QEMU, block disk, direct I/O2,3098.6×3981.03×8,8251.84×
Kata QEMU, tuned, direct I/O2,4648.1×6350.65×9,0621.80×
Kata Firecracker2,5627.7×2272.74×19,8410.82×
  • runc on the VMs' storage pool is the control: the pool alone costs runc 1.63×. The VM boundary costs a further 4–5× on top.
  • Changing the virtual disk type (virtio-blk in place of virtio-scsi), the I/O engine (io_uring) or the flush setting did not raise it. The pool on raw NVMe in place of loop files took it from about 1,600 to about 2,600.
  • Direct I/O (the node opens the VM's disk without its own cache) is an option outside the tuned set. Big writes go from 232 to 635 MB/s. That is not a measured advantage over runc: runc in the same group of pods wrote 412 MB/s over two rounds, and runc's own big writes swing between about 410 and 700 MB/s across groups. Small random reads and writes drop from 20,664 to 9,062 a second (runc: 16,276), which shows the higher figure was the node's cache. Saves per second stay at 2,464. File and kernel-call tests did not change.
  • runc's own big-file write swung between about 410 and 700 MB/s across groups, so read that column as approximate.

Create a pod, run one command

Startup

"Through Kubernetes" is from creating the pod to its command finishing. "Below Kubernetes" asks containerd directly, which removes the kubelet's own waiting. The last column is the part spent creating the sandbox, which for Kata is booting the VM.

RuntimeThrough KubernetesBelow Kubernetesof which sandbox
runc1.7 s0.17 s0.08 s
gVisor, as shipped1.9 s0.19 s0.09 s
gVisor, tuned2.6 s0.18 s0.08 s
Kata Cloud Hypervisor, as shipped3.9 s0.97 s0.88 s
Kata Cloud Hypervisor, tuned3.2 s1.13 s0.98 s
Kata QEMU, as shipped5.0 s2.29 s2.19 s
Kata QEMU, tuned5.1 s2.45 s2.21 s
Kata Dragonball, tuned–2.50 s2.34 s
Kata Firecracker4.8 s2.44 s2.31 s
  • Kata's time is the guest booting, not the runtime waiting. The VM process is up in about 0.16 s. A probe that knocked on the guest every 5 ms never got in before the runtime did.
  • The boot splits in half. On QEMU, Firecracker and Dragonball the guest kernel answers about 0.9 to 1.0 s after the pod is created and the agent about 1.0 to 1.4 s after that. On Cloud Hypervisor both halves take under 0.5 s. Why its guest is twice as fast is not known yet.
  • The kubelet adds 1.5 to 2.7 s of its own to every runtime here, runc included.
  • Through Kubernetes, differences of under a second are not the runtime: gVisor shows 1.9 s as shipped and 2.6 s tuned there, and the same 0.2 s below it.
  • The real fixes are a faster-booting guest (find what Cloud Hypervisor's guest skips, or boot a smaller image) or VMs kept ready in advance (templates, warm pools). Neither was measured.

One idle pod

Idle memory

What the node charges to one idle test pod, read from the pod's group a minute after it started. For Kata this includes the VM and its helpers; for gVisor its kernel.

RuntimeCharged to the podProgram memoryFile cacheShared memory
runc0.55 MB0.13 MB0.00 MB0.00 MB
gVisor14.0 MB11.1 MB0.46 MB0.45 MB
gVisor, tuned14.4 MB11.2 MB0.83 MB0.45 MB
Kata QEMU, as shipped194 MB16.2 MB174 MB174 MB
Kata QEMU, tuned227 MB17.4 MB204 MB193 MB
Kata Cloud Hypervisor, tuned202 MB3.41 MB195 MB185 MB
Kata Dragonball, tuned286 MB0.98 MB280 MB183 MB
Kata Firecracker165 MB158 MB5.01 MB0.02 MB
  • A plain container costs the node 0.55 MB, gVisor 14.0 MB, a Kata VM 165 to 286 MB. For the VMs it is mostly the guest's own memory that booting touched.
  • Tuning does not shrink it: Kata QEMU holds 194 MB as shipped and 227 MB tuned.
  • One sample per runtime, so read these as rough sizes.

What "tuned" means

The settings

  • Kata, container disk as a block device. containerd's devmapper snapshotter for the Kata handlers, with the thin pool on a raw NVMe partition.
  • Kata, volumes as block devices. emptydir_mode = "block-plain".
  • Kata, one vCPU for a 1-CPU pod. static_sandbox_resource_mgmt = true and overhead_vcpus = 0.
  • Kata QEMU, disk and network devices. block_device_driver = "virtio-blk-pci", block_device_aio = "io_uring", network_queues = 2.
  • gVisor. overlay2 = all:dir=… so every mount is overlaid inside the sandbox.
  • Both. A RuntimeClass with overhead.podFixed of 1 CPU and 512 MB.
  • Options outside the tuned set. Kata direct I/O for big writes (block_device_cache_set = true, block_device_cache_direct = true). gVisor KVM mode (platform = kvm) for work made of small kernel calls.

Every tuned setup is its own containerd handler next to the stock one, so both ran in the same pass. The script is lab/install/70-tuned.sh; the raw rows and the tables are in bench/results/tuned/.

Second round · two nodes · same day

Second round: a real network link, and five loose ends

The network numbers above send from a pod to its own node, which is a copy in memory at about 6,500 MB/s. No network card is that fast. A second node of the same type was added so the same pods could send across the real link. One TCP stream between these two machines is limited by EC2 to 5 Gbit/s (592 MB/s here); four streams together reach 1,480 MB/s, the machine's peak.

Runtime, MB/sTo its own nodeTo the other node, 1 streamTo the other node, 4 streams
SendReceiveSendReceiveSendReceive
The node itself, no container6,6626,7735925921,4801,480
runc6,5296,4875705701,4261,426
gVisor, as shipped1,3201,214569450647691
gVisor with pod overhead2,2032,3605685701,1791,382
Kata QEMU, as shipped7052,019268308601597
Kata QEMU, tuned1,7586,2485705701,4201,425
Kata Firecracker5531,875393441697917
Kata Dragonball2791,273196440543865
Kata Cloud Hypervisor153440160296185361
  • Across the real link, tuned Kata QEMU and runc are the same: both sit at the limit of the link with one stream and with four. The 3.2× sending gap in the Network section is a gap against a memory copy.
  • gVisor with pod overhead also reaches the limit with one stream, and is within 17% of it with four.
  • Still below the link: Kata as shipped, Firecracker, Dragonball, and above all Cloud Hypervisor at 160 MB/s sending.
  • Why Cloud Hypervisor is slow, the likely cause (observed, not yet tested): its virtual network card has checksum and segmentation offload turned off on both sides, so the guest sends packet by packet through one thread. Kata QEMU has both on. Kata 4.3.1 has no setting to turn them on, so a version with them on was never measured.
gVisor, pod to its own nodeSendReceiveSmall messages
MB/sslower than runcMB/sslower than runcMB/sslower than runc
runc6,2961×6,4411×78.11×
gVisor, as shipped1,2265.1×1,1155.8×7.8410.0×
gVisor, receive offload flag only1,2325.1×1,1335.7×7.889.9×
gVisor, two network channels only1,2145.2×1,1655.5×7.4410×
gVisor with pod overhead2,0753.0×2,3372.76×16.44.8×
gVisor in KVM mode with pod overhead2,6012.42×2,4512.63×23.93.3×
  • gVisor small messages. Its network flags change nothing. What helps is CPU allowance and the KVM mode: 7.84 MB/s as shipped, 23.9 with both, against runc's 78.1. The cost is in catching each kernel call, not in gVisor's network code. A third flag, checksum offload on send, left the pod with no network at all.
  • Kata shared folder without a thread pool (the setting its own authors default to): unpacking node_modules is 20% faster and listing files 33% faster, which still leaves unpacking 46× slower than runc (57× as shipped). The answer stays block devices.
  • Firecracker 1.18 in place of 1.17: no change. Sending 554 to 568 MB/s, saved writes 2,403 to 2,384 per second.
  • Is runc held back by its kernel-call filter? Only a little. With the filter off the cheapest call is 19% faster and the rest barely move. Firecracker's guest still opens files 2.6× faster than runc, so those "faster than runc" cells are the guest kernel doing less work, not the filter.
  • Did not start: gVisor with the container image as a read-only EROFS disk. The setting also reaches the pod's pause container, which then fails to load. Two attempts, no numbers.

Two nested m8id.xlarge in one subnet · 1 warm-up + 4 measured rounds (3 for gVisor as shipped and Cloud Hypervisor in the one-stream pass) · pods 1 CPU / 2 GiB, pod packet size 1500 · raw rows: bench/results/tuned/raw/round2-*

Measured, no gain

What didn't help

  • Kata shared-folder settings: more server threads, cache=always, DAX. About 5%.
  • Transparent huge pages set to always on the node.
  • Kata guest flags for cheaper wake-ups between vCPUs, and longer halt polling on the node (200 µs to 1 ms).
  • Jumbo packets (MTU 9001) for Kata QEMU, Firecracker and gVisor.
  • Firecracker's asynchronous disk engine: slower on both storage pools.
  • gVisor's exclusive-mount and directory-cache flags, and turning off its fast path (2.4–4× slower).
  • Second round: gVisor's network flags, Firecracker 1.18 in place of 1.17, and the Kata shared folder without a thread pool (13–33% on file storms, far from enough).
  • Did not work: Kata QEMU with huge pages (the VM timed out), Kata QEMU with macvtap networking (no route to the node), Firecracker with PCI devices under Kata (the guest agent never answered).

Read with care

Caveats

  • One nested Intel node, one day. Two or three measured rounds per cell; the headline rows were repeated with 8.
  • The node is nested, so every trip out of a Kata VM costs more than on bare metal. The wake-up and network gaps should be smaller there; this was not re-measured.
  • The one-vCPU fix holds for 1-CPU pods. With two vCPUs a wake-up across vCPUs costs about 20 µs again.
  • Pod overhead is not free: the node reserves that CPU and memory for each pod, so fewer pods fit.
  • Block volumes are private to one pod. A volume shared between pods, or one that must show the node's files, still needs the shared folder.
  • The node's storage pool lives on instance storage, which is erased when the node stops.
  • AWS Nitro sandboxes were not part of this run.