Repository navigation
Rewind VM 0.19.0 lets a run mount store layers: images of store paths that builds with most of a closure in common, such as NixOS tests, pack once and share. A build with more than one core can now run a container or a sandbox that mounts its own proc and sysfs, and a uid-range build can open /dev/net/tun. A keyframe holds the same MSRs whatever the host's Linux, which removes the cause of #19, where every restore failed on an Intel host with a Linux before 6.13. Layers, the TUN device and the CPU count come from KiaraGrouwstra in #26, #24 and #18.
Before you upgrade
- The guest's kernel and init changed, so the same inputs make a run with another id.
- A run recorded on an Intel host holds the host's IA32_PERF_CAPABILITIES in its keyframes, which a Linux before 6.13 refuses to restore. Record it again with 0.19.0.
- A
v3run recorded under a Linux before 6.13 holds the host's IA32_ARCH_CAPABILITIES. Its replay with 0.19.0 reports that MSR as a difference, and it does not restore under Linux 6.13 or later. Record it again.
Store layers
rewind layer OUT [PATH...] [--paths-from FILE]packs store paths into a layer, an erofs image packed as a run's own image is. It needs no home, so it runs inside a Nix build.rewind nix --layer IMAGEandrewind check --layer IMAGEmount layers below the run's own image, which then holds only the paths that no layer holds. Give the option once for each layer; the first is the uppermost.rewindLib.storeLayer name rootPathspacks the closure ofrootPaths, andinRewindandonRewindtakelayers.rewind buildreads them fromrewindLayers, so a derivation without layers keeps its hash. A build that runs python3 with a layer of the python3 closure packed 38 store paths where it packed 61.- A run's id includes the hash of each layer,
rewind exportpacks the layers with the image, andrewind shownames them in the run's command.
Builds with more than one core
- The guest kernel prints the
--corescount in/proc/cpuinfoand in the sysfs online, possible, present and enabled lists (#18). init used to mount files over them, and Linux then refused a new proc or sysfs to any user namespace: a uid-range build with more than one core failed, and so did rootless podman, bubblewrap orunshare --mount-procinside any build. --coresgives a count and not a topology. The guest kernel is uniprocessor, so sysfs has onlycpu0.
Networking in a build
- init gives
/dev/net/tunthe mode 0666, as udev does, so a uid-range build can open it (#24). The NixOS test driver links each VLAN to its switch through a TAP device, and the nixpkgstoxvpntest failed without one. - The guest kernel has dummy links, which the nixpkgs
vnstattest makes. Both tests pass ininRewind.
Keyframes across hosts
- The monitor sets IA32_PERF_CAPABILITIES to 0 on every vCPU. On an Intel host with a Linux before 6.13, every command that restores a keyframe, such as
where,catandgdb, failed with "KVM took 85 of 98 MSRs" (#19). The cause comes from KVM's source; the fix has not run on an Intel host. - Under
v3, whose CPUID hides IA32_ARCH_CAPABILITIES, the monitor sets that MSR to 0 too, so a run recorded under Linux 6.12 restores under 7.3 and the reverse. - An MSR that one KVM reads as 0 and another does not list, such as the CET MSRs from Linux 6.18 on, is no longer a difference at replay. One run recorded under Linux 7.3 and again under 6.12 or 6.6 replays identically on the other.
Rewinds
- A rewind zeroes a page that was zero at the machine's origin, where it read and kept 4 KiB of zeros for each. A rewind over 20,000 such pages took 41 ms the first time and kept 83 MiB; it now takes 3.7 ms and keeps nothing.
- A rewind reads KVM's dirty log once, and makes its line of parent checkpoints once. A rewind with no page to write back on a 1 GiB guest takes 142 µs where it took 290 µs.
- These come from Ramon Nogueira's fork, semistrict/rewindvm.
Speed
Measured on one machine for every release at https://rewindvm.dev/bench/:
- No workload's time, CPU or memory moved by more than 3 percent against 0.18.0. Store layers change nothing for a run without them, and the faster rewinds serve
rewind blameand gdb running backwards, which no workload of the benchmark does.
Fixes
rewind blamecould name an older write as the last one. A guest that went idle with no timer armed left the monitor's idle flag set, and a rewind to an earlier step stopped there as stalled before the guest ran. A checkpoint now keeps the flag and a rewind puts it back.- A folding row in the Runs panel showed how the run its runs fold under ended, so schedule 8's windows in the mylib family read exited:2 while 47 of its 79 runs passed. The row now says how the folded runs ended: their ending when they share one, or how many failed.
- The tutorials, case studies and examples are recorded again on the new guest. mylib's check now finds schedule 4, decided at step 4,773. The first event that differs is worker 172 reporting job 15 at 4,782 where the passing run's same worker exits, and the crash follows at 4,785. devenv's test still fails under 206 of 257 schedules, the gc-closure case study moves to epoch 1793664000, where schedule 38 fails, and the schema-migration case study follows schedule 130.
Full Changelog: v0.18.0...v0.19.0