Launching TestFlows Machine: self-service deterministic simulation testing environment Read the post

Running a machine

Creating a run

machine create creates a run from a disk and starts it. The run’s name goes first and is optional. Without one, Machine generates a name.

1
machine create app --disk app --cpus 2 --mem 512

The defaults are 1 CPU and 256 MB of memory. Other options of create:

Option What it does
--no-daemon boot and run to the end by itself, instead of waiting for your commands
--pin-cpu n run on host CPU n, for this start only (the default picks the least-loaded)
--like run start from another run’s options, then apply the ones you give
--label name=value attach a label to the run, as many times as you like
--rng, --rng-seed n an RNG device, on by default, seeded with n; the default seed is 0, and --no-rng leaves the device out
--fs-sync write to the disk as the program writes, instead of later
--mem-hash hash the machine’s memory at every entry, so a replay compares it too (off by default)
--disk-hash hash the machine’s disk at every entry, so a replay compares it too (off by default)
--timer-slack d how late a timer may be in code that takes no exit, 20ms by default; 0 keeps every timer on time
--limit-margin n how many conditional branches short of an exact stop the CPU’s counter interrupts; the default is the host’s
--repeatable record so that recording the run again gives the same entries; the default is the session’s, which machine describe shows, and recording is slower
--vtime-base n the date the machine’s clock starts at, as a Unix timestamp; the default is 2026-03-01, see Machine time
--no-wait return as soon as the request is accepted

Random numbers

A machine has an RNG device, on unless the run was created with --no-rng. The device gives the machine its random bytes from a seed. The default seed is 0, so a program sees the same random numbers every time. --rng-seed chooses another, from 0 to 2^64-1.

1
2
machine create app --disk app --rng-seed 42
machine rng app

machine rng prints the seed, and whether the machine’s kernel reseeds its own generator at once.

To seed the device again, where the run is now:

1
machine rng app seed 7

The run records that seed, so a replay seeds the device at the same point. If the machine’s kernel reads the seed, it reseeds at once. A kernel that does not read the seed picks it up the next time it reseeds. A run created with --no-rng has no device, and the command refuses it.

A branch can draw other random numbers than its parent. machine fork, machine detach and machine go take --rng-seed, and the new run’s device is seeded from it once the run is up:

1
machine fork app --at ^booted --name other --rng-seed 7

At the control prompt the same commands are /rng and /rng seed 7, and a branch takes rng-seed 7.

The seed on machine run --seed is a different one. It draws how long each stretch of execution lasts. Schedules covers it.

From Python, client.create("app", disk="app", rng_seed=42) seeds a new run, run.rng() reads the seed, run.rng.seed(7) seeds the device again, and run.fork(at="^booted", rng_seed=7) makes a branch with its own.

Multiple vCPUs

A machine can have more than one vCPU. Ask for them with --cpus, and the machine’s kernel sees every one and spreads threads across them.

Build a disk from Ubuntu 26.04 whose container runs sleep infinity, so it stays up and waits for your commands. Then create a run with four vCPUs, run it for 15 seconds of machine time so that its container is up, and ask the machine what it has:

1
2
3
4
5
machine disks build --from ubuntu:26.04 ubuntu-26.04 --entrypoint /bin/sleep -- infinity
machine create app4 --disk ubuntu-26.04 --cpus 4
machine run app4 --within 15s
machine exec app4 run --container app -- nproc
machine exec app4 run --container app -- grep -E '^processor|^model name' /proc/cpuinfo
1
2
3
4
5
6
7
8
9
4
processor : 0
model name : TestFlows Machine v1
processor : 1
model name : TestFlows Machine v1
processor : 2
model name : TestFlows Machine v1
processor : 3
model name : TestFlows Machine v1

Nothing about recording changes with more vCPUs. The machine records each of them, along with every interrupt one vCPU sends to another, so a run on four vCPUs replays exactly like a run on one. A race between two threads on different vCPUs plays out the same way every time you replay it.

Each scheduling cycle gives every vCPU a turn. To drive just one of them, use machine run --vcpu N. And to explore how threads on several vCPUs could interleave, see Schedules.

Driving it

A run executes only while you drive it. machine run is the way, and --until says when to stop. (A run created with --no-daemon answers ✗ Machine not in control mode, because the machine isn’t waiting for you.)

1
machine run app --until tasks

A plain machine run can stop before the point you are waiting for. With --until, Machine keeps going until what you asked for is true. If it never gets there, the command exits with status 3.

These are the conditions you can wait for. machine run --until and machine wait --for take the same ones.

Condition True when
running, paused, stopped, halted the machine is in that state
ready the machine accepts commands
tasks Linux is up and its task table can be read, which is before it starts anything in userland
console~REGEX the console output matches the pattern
ttyS1~REGEX the output of another source matches it, here the serial port ttyS1
entry>=N the log has reached entry N
entry=+N N more entries have been recorded
vtime>=T the machine’s clock has reached T, a duration such as 500ms
vtime=+T the machine’s clock has moved T from where it was
/app:exit the program at /app has exited

The last row is one example of a task condition. A condition on a program needs the program focused first, with machine focus app add /app, and the command refuses it otherwise. There are more task conditions under Steering programs.

The two commands read a text condition differently. run --until waits for text printed during the run, so a line already on the console does not end it, and the same --until can stop at the next of several lines alike. wait --for asks whether the text has been printed at all, before the run or during it:

1
2
machine run app --until 'console~app \| ready'    # runs until app next prints ready
machine wait --for 'console~app \| ready' app # true if it printed one already

The pattern is a regular expression, and it is matched against everything the console prints, including the kernel’s boot messages. A bare ready matches the word already in one of those messages, so the run would stop during boot. Each line a service prints starts with the service’s name and |, so app \| ready matches only what app prints.

A source name with a ~ in it is quoted inside the pattern, as in '"/output/keep/app/app.log~"~ERROR'.

--iters limits how many iterations a drive may spend, and the global --timeout limits how long you are willing to wait. The run stops at whichever limit it reaches first.

An iteration has no fixed length. It is one dispatch of a vCPU, and it ends at the vCPU’s next exit: after five instructions or after a million. Because of that, no iteration count can be chosen in advance to match how long a program runs. Stop on a condition, and use --iters or a vtime condition as a limit. Every run ends by saying how far it went:

1
iterations: 2000  run ic: 238893097  vtime: +0.383620410s

vtime is how far the machine’s clock moved. A vtime condition is checked between iterations, so the run stops at the end of the iteration that reaches the time, slightly after it. A run that went too far is not lost: machine rewind and machine go take it back to an earlier point.

A time bound

--within ends a run when the machine’s clock has moved that far:

1
2
machine run app --within 10s                           # run for 10 s of machine time
machine run app --until 'console~done' --within 30s # the first of the two

Alone, it is the same run as --until vtime=+10s. With another --until it is a bound on it: if the clock gets there first, the run ends with exit status 3 and says Machine time ran out. The bound is measured on the machine’s clock, which moves as the programs in the machine work and while the machine is idle. A slow host therefore does not end the run sooner, as the global --timeout, which counts seconds on the host, would.

Now and then the host interrupts an entry while it is being recorded. Machine records that entry again, and you see nothing except a short pause. --retry sets how many more times one entry is tried, 2 by default. If they are all interrupted the run stops with Host interrupted the run at entry N. It is not recorded. and the machine rewind command that puts the run back at the entry before.

Schedules

A program that uses threads can behave differently depending on how they interleave. Machine can draw how long each stretch of execution lasts, so every run explores a different interleaving, and --seed makes those draws repeatable.

1
2
machine focus app add /usr/bin/app
machine run app --until /usr/bin/app:exit --mode step,fast --step 1:200 --seed 1

--mode is how the machine runs: fast, step, step-into, free or fence, or a comma list to draw from. --step and --fast give the length of a stretch in each mode, as a number or a range like 1:200. --strategy sets how the draws are made, random (the default), golden or sweep, and --seed is the seed for the random and golden ones.

A fence stretch ends in the same place every time the same state is recorded, where a fast stretch ends close to its length but not always at the same instruction. That exactness makes a fence stretch somewhat slower than a fast one. Give its length with --fence or --limit. Recording that repeats shows how to make a whole run record the same way every time.

What a task does

Drawing the length of a stretch varies where threads are interrupted. To vary what the machine’s scheduler does with them, draw what the task on the vCPU does at each dispatch:

1
2
3
machine run app --task-sched keep,hold,yield --task-slice 10us:600us --seed 3 --iters 500
machine focus app add /usr/bin/app
machine run app --task-int none,preempt --when /usr/bin/app:on --seed 4 --iters 500

--task-sched draws among keep, hold, yield, drain and drain-all: hold takes the task off the run queue, yield puts it behind its peers, drain undoes the oldest hold or yield, drain-all undoes every one, and keep changes nothing. --task-slice draws how long the task runs before the scheduler decides again, from a span such as 10us:600us, and default puts the kernel’s own back. --task-int draws whether to preempt it. Each takes a comma list to draw from, and --seed makes the draws repeatable.

--when applies the draws only while a predicate holds, such as /usr/bin/app:on for the program running its own code. A predicate on a program needs the program focused first, as the second example does with machine focus, and the run refuses it otherwise. To draw different things at different moments, write a plan, where each clause has its own when.

These draws combine with branches: fork several branches from one checkpoint, give each its own seed, and keep the ones that crash. The explore_seeds.py example in the SDK does exactly that.

To hold an interrupt a drawn time before it is delivered, see Holding interrupts.

A run can also take checkpoints automatically while it is driven. --auto-checkpoints N takes one every N entries, and 0 turns them off.

Cancelling a drive

If a drive or a checkpoint is taking too long, machine cancel app cancels whichever one is in progress. A run stops at once, where the host’s clock put the stop, so a repeatable run no longer repeats from that entry. A replay stops before its next entry.

--soft stops the run at the end of the dispatch in progress instead. That stop is an ordinary entry, so the run stays repeatable. It takes at most the run’s dispatch bound, 1s by default.

1
2
machine cancel app           # stop now
machine cancel app --soft # stop at the end of the dispatch in progress

Ctrl-C on a drive cancels softly, and so does the global --timeout on run and exec run. Ctrl-C prints Stopping at the end of the current dispatch. Press Ctrl-C again to stop now, and a second Ctrl-C stops the run at once. A run still busy 10 seconds after a Ctrl-C or a timeout is stopped at once as well. At the control prompt, /cancel stops the run at once and /cancel soft at the end of its dispatch.

Recording that repeats

A replay always repeats a recording exactly. Recording the same run a second time is different. Two recordings of a run that is not repeatable, from the same disk and the same seeds, start out the same and then differ a little.

When you need the second recording to match the first, the run must be repeatable. Every recording of a repeatable run records the same entries, whether the run has one vCPU or several, and a branch you fork from one of its checkpoints records exactly what its parent recorded after that checkpoint. On the standard-ip and dedicated-ip classes a run is repeatable by default. On other classes, create it with --repeatable. --no-repeatable turns it off, and machine describe shows Repeatable: true for a repeatable run.

1
2
3
4
5
6
machine create app --disk app --repeatable --cpus 2
machine run app --until tasks
machine checkpoint app booted
machine run app --until 'console~done'
machine fork app --at ^booted --name again # records the same entries again
machine fork app --at ^booted --no-repeatable # a branch that records as usual

Repeatable recording is slower. How much slower depends on the program and on the session’s class. On standard-ip, where it is the default, booting Ubuntu 26.04 and running a program with eight threads to its end takes 23.5 seconds to record with --repeatable and 21.6 seconds without it. Booting PostgreSQL 17 on one vCPU takes 24 seconds with it and 22 seconds without it, and loading its test data with pgbench -i takes 2.2 seconds and 1.9 seconds. On standard-ie, where it is off by default, the same boot takes 34 seconds and 32 seconds, and pgbench -i takes 3.0 seconds and 2.8 seconds. Replaying a repeatable run is as fast as replaying any other.

--timer-slack is how late a timer may be while a program runs code that takes no exit. The default is 20ms, and it applies to every fast run. A timer that comes due in code that exits to the machine is delivered at that exit. 0 keeps every timer on time, and recording is slowest that way. The slack takes ns, us, ms or s, as in --timer-slack 1s. A drive can also draw its own slack from a range, for that drive only:

1
machine run app --timer-slack 0:20ms

--limit-margin is how many conditional branches short of an exact stop the CPU’s counter interrupts. The default is the host’s, and machine describe shows that default as host's. A smaller margin records faster, but a margin that is too small misses stops, and a later recording may not repeat. machine replay --limit-margin sets it for that replay.

Four more options decide where a recording stops. Each takes 0 for its default, and machine describe shows them as Instr Margin, Dispatch Bound, Fast Backstop and IRQ Wait:

Option What it does
--instr-margin n how many instructions short of a stop placed by an instruction count the CPU’s counter interrupts; the default is the host’s, 3,630 on Intel and 50,000 on AMD, which describe shows as host's
--dispatch-bound d how much host time a fast dispatch runs before it stops, 1s by default; it takes a duration such as 500ms or 2s
--fast-backstop n how many instructions a fast dispatch runs with no other stop, 100,000,000 by default
--irq-wait n how many conditional branches a dispatch runs while an interrupt waits for the vCPU to take it, 200 by default

A stop placed by --dispatch-bound falls where host time put it, so another recording of the same state does not stop there. A margin the run gives must be smaller than its backstop, and the run is refused otherwise.

1
machine create app --disk app --repeatable --instr-margin 100000 --dispatch-bound 2s

A branch keeps its parent’s --repeatable, --timer-slack, --limit-margin, --instr-margin, --dispatch-bound, --fast-backstop and --irq-wait unless you give it others. machine fork, machine detach and machine go take all seven. machine start keeps what the run was created with.

Where a run stops repeating

Some stops are placed by host time, and no other recording of the same state stops at the same instruction: a stop at the dispatch bound, an immediate machine cancel and a signal the host sends the machine. A repeatable run repeats up to the first such entry. For a repeatable run, machine describe shows that entry as Repeats To, and tip when the whole run repeats:

1
2
Repeatable:             true
Repeats To: entry 804, a host-time stop

machine checkpoints has a REPEATS TO column for a repeatable run: for each of its own checkpoints, the first entry after it where recording again from that checkpoint stops repeating:

1
2
3
NAME  ID     VTIME              DURABLE  REPEATS TO
1 1 0.000013850s no entry 804, a host-time stop
pre 19502 1.380127790s no entry 19580, a host-time stop

A machine cancel --soft and a Ctrl-C end the run at the end of the dispatch in progress, so they keep the run repeatable. See Cancelling a drive.

What you send a run is part of what a recording repeats. Commands given with machine exec, put and get in the same order at the same points give their processes the same ids in every recording. An id such as 40787p1 is the entry the run was at when the command was sent, followed by the command’s place among the commands sent at that entry.

Time compression

Time the machine spends idle costs almost no time on the host.

When every vCPU is halted and waiting for a timer, the machine doesn’t sit through the wait. It moves its clock straight to the earliest timer its kernel armed, and the kernel wakes up at exactly the time it asked for, as if it had waited. No instruction runs in between, so there is nothing for the host to do. Time the machine spends working is never skipped.

So a program that sleeps for ten minutes sleeps ten minutes of machine time, and only a few seconds of yours. Try it on a one-vCPU run of the Ubuntu disk from Multiple vCPUs:

1
2
3
machine create app --disk ubuntu-26.04
machine run app --within 15s
time machine exec app run --container app -- sh -c 'date; sleep 600; date'
1
2
3
4
Sun Mar  1 00:00:14 UTC 2026
Sun Mar 1 00:10:14 UTC 2026

real 0m3.171s

Ten minutes went by in the machine, and 3.2 seconds went by for you.

Every vCPU idle

Time compression works the same way with several vCPUs. The machine only moves the clock once all of them are idle, so a vCPU that still has work finishes it first. Here is the same sleep on the four-vCPU run:

1
time machine exec app4 run --container app -- sh -c 'date; sleep 600; date'
1
2
3
4
Sun Mar  1 00:00:12 UTC 2026
Sun Mar 1 00:10:12 UTC 2026

real 0m7.829s

On replay

Every move of the clock is recorded in the run’s log, so a replay makes the same moves at the same points and ends up in the same state. Fork a branch from the start of the run and replay it, ten minutes of sleep included:

1
2
3
machine stop app4
machine fork app4 --at ^1 --name check
machine replay app4/check

Then machine diff compares the branch with the original:

1
machine diff app4/check
1
✔ No differences

How much a run compresses depends on how idle the machine really is. A database that keeps running background tasks while your test sleeps uses machine time for them, and that time is never skipped.

Turning time compression off

--no-idle-skip keeps the clock moving at its own rate while every vCPU is idle, instead of jumping to the next timer. Use it to see what a program does while it waits in real time, at the cost of speed:

1
machine run app --no-idle-skip --within 10s

Waiting

machine wait doesn’t drive anything. It watches a run, or several, and returns when a condition holds.

1
2
machine wait --for stopped app
machine wait --for 'console~app \| ready' app
1
✔ Reached stopped: app (whUxfLYSFJMDHzKaiBOvH)  2.1s

It exits with 0 when the condition is true, 2 on an error and 3 on a timeout, so scripts can tell them apart. Remember that it only watches. Waiting for a condition on a run nobody is driving never finishes unless you set --timeout. With --timeout 0 it checks once, and the message tells you why it failed: The machine was waiting for commands.

At the control prompt the two are /run until and /wait for, and /run takes within too:

1
2
/run until 'console~app \| ready' within 30s
/wait for 'console~app \| ready'

/wait for answers at once, because nothing drives the machine while the prompt waits. timeout 5 makes it wait 5 seconds, for a run another terminal drives.

From Python, run.run(until=r"console~app \| ready", within="30s") drives until a condition, and run.wait(for_="stopped", timeout=60) waits for one without driving. Bounding a drive shows both.

Inspecting a run

Command Shows
machine runs your runs, newest first (-w keeps the list live)
machine describe app the full configuration of a run
machine state app its state and where it stands; a run with no machine reads stopped
machine now app the last entry it recorded, and the time on the machine’s clock
machine output app what the machine printed (-f follows, -n -20 shows the last 20 lines, --source reads another source than the console)
machine entries app the entries in its log
machine ops operations on runs and how each ended, newest first: checkpoint, branch, fork, switch, rewind, start, replay, delete and each run --until; one you interrupted with Ctrl-C is still listed
machine debug log app the debug output of a run (machine debug err shows its error and crash log)
machine dump app the machine’s registers, code and other state (--show picks the sections, --entry reads an earlier one); its hash section is what the newest entry recorded
machine hash app the hashes of the machine as it stands, to compare with another stopped at the same point; see Comparing two machines
machine vcpu app where one vCPU stopped, and how its last dispatch ended (--vcpu picks another)
machine irqs app the interrupts the machine owes or holds; see Holding interrupts

machine output also takes --entries, if you only want what a few entries printed.

The run’s log is a list of entries, one for each time the machine stopped, with why it stopped and where. machine entries reads it, and -f follows new entries as the run records them:

1
2
3
machine entries app -n -20      # the last 20 entries
machine entries app -n 100:120 # entries 100 to 120
machine entries app -f

With many runs, machine runs --roots shows one row for each tree, with how many of its runs are running, and --not-synced shows the runs nothing has been published from yet.

Finding a line

Often you want the opposite: you know what the machine printed, and you want the entry that printed it, so you can go there. A line is printed over a range of entries, but a byte is printed by exactly one, and Machine can tell you which.

machine output app search finds a pattern and gives the entry of each match:

1
machine output app search 'Linux version'

Each match is a row with the columns ENTRY, TIME, SOURCE, LINE:COL and TEXT. ENTRY is the entry that printed the first byte of the match, and TIME is that entry’s time, a point such as 1.194000000s+2. TEXT is the whole line, with the match in bold.

A match has to cover at least one character, because the search returns the entry that printed the match’s first byte. A pattern that can match an empty string, such as 6*, is refused, in a search and in a console~REGEX condition or point alike. Write 6+ instead.

The search runs where the console is kept, so a large console is not downloaded. -f keeps going with what the machine prints next, and --max 1 stops at the first match. The entry is a point, so you can go straight to it:

1
machine go app '#1276'

console~REGEX is the same thing written as a point, where the console first printed a match. machine go, machine fork --at and machine rewind all take it:

1
machine go app 'console~Linux version'

console:N is a line by its number, as machine output -n numbers it: the point where the console finished printing line N. Any source takes it, such as ttyS1:20. Lines are numbered from 1, and the point names the same place each time it is read:

1
machine go app console:120

If you would rather search with your own tools, pipe the console to them. grep -b prints the byte offset of a match, and machine output app entry turns an offset into its entry:

1
2
machine output app -n : | grep -bo 'Linux version'    # 438:Linux version
machine output app entry 438 # 1276

On a terminal, every line shows the range of entries that printed it, the source it came from and its number. Into a pipe or a file the lines are printed alone, as the machine printed them. --wide and --plain choose either way:

1
2
machine output app -n -5                      # with their entries
machine output app -n : --plain > boot.log # the text alone

On a terminal, a control character the machine printed shows as text, such as ␛[?25l, and your terminal does not act on it. Colors stay colors. A pipe or a file gets every byte as it was printed.

From Python, run.output.find returns the first match, with the entry that printed it and a place that go takes, and run.output.search yields the matches one at a time:

1
2
3
4
5
hit = run.output.find("Linux version", from_="^booted")
branch = run.go(hit.place)

for match in run.output.search("ERROR", from_="^booted", to="^done"):
print(match.entry_id, match.text)

Sources

The console is not the only place a machine prints. It has four serial ports, ttyS0 to ttyS3, and the console is the first. A program in the machine that writes to /dev/ttyS1 prints on ttyS1, apart from the boot log and from everything else on the console:

1
2
# inside the machine
my-app > /dev/ttyS1 2> /dev/ttyS2

Everything a run prints is kept in one log, in the order it was printed, and each part of it has a source. machine output app sources lists the sources that printed:

1
machine output app sources
1
2
3
4
SOURCE      BYTES      LINES  ENTRIES
ttyS0 10767 198 29:21127
ttyS1 116 10 16916:16949
ttyS2 99 10 16917:16948

--source reads one of them. Without it you get the console, as before:

1
2
3
machine output app --source ttyS1
machine output app search ready --source ttyS1
machine output app entry 0 --source ttyS1

--source all reads every source together, in the order printed, with the source in front of each line:

1
machine output app --source all -n -4
1
2
3
4
ttyS0     starting the app
ttyS1 listening on 8080
ttyS2 warning: no config file
ttyS1 ready

A line belongs to one source. If one source prints while another has a line unfinished, that line ends there, so what you read is always what one source printed, in order.

The name of a source also takes the place of console in a condition and in a point. A run that waits for text on ttyS1 stops at the entry that printed it, and what the other sources print in the meantime does not interrupt it:

1
2
machine run app --until 'ttyS1~ready'
machine go app 'ttyS1~ready'
Source What it is
console the console of the run, which is the default
ttyS0 to ttyS3 the four serial ports; ttyS0 is the console
hvc0 the virtio console
debugcon the firmware’s debug port
a path under /output an output file, or every file under a directory
all every source, in the order printed

Output files

A service on a disk has no serial port to write to, and three ports are not many. Every service is given a directory instead, and each file it writes there is a source of its own. The directory is named by a variable:

1
2
# inside the service
my-app --events "$MACHINE_OUTPUT_DIR/events.jsonl"

The file is stored with the run as it is written, each write with its entry. Its name as a source is its path: /output/keep, the name of the service, and the path the service wrote. A disk built from a binary or from one image has one service, named app, so its files are under /output/keep/app.

1
machine output app sources
1
2
3
SOURCE                            BYTES      LINES  ENTRIES
ttyS0 10767 198 29:21127
/output/keep/app/events.jsonl 2210 31 16916:20410

Everything that takes a source takes the path, and the path of a directory is every file under it:

1
2
3
machine output app --source /output/keep/app/events.jsonl
machine output app search '"setup_complete"' --source /output/keep/app
machine run app --until '/output/keep/app/events.jsonl~setup_complete'

A file does not have to be text. machine output app bytes writes what a source printed exactly as it was written:

1
machine output app bytes --source /output/keep/app/core.bin > core.bin

Dropped output

Dropped output is how Machine does retroactive logging: a program writes detailed logs while it runs, the run stores none of them, and you get the logs of any stretch after the fact by replaying it. Debug logs can be gigabytes, and a run that stores them is slow to copy and to read. A service writes those under a second directory, and what is written there is not stored:

1
2
# inside the service
my-app --debug-log "$MACHINE_DROP_OUTPUT_DIR/debug.log"

The file is a source under /output/drop. It still has its name, and machine output app sources lists it with 0 bytes, so you can see what a run dropped. A run can still wait for a line of it. The wait stops the run at the entry that wrote the line and stores nothing:

1
machine run app --until '/output/drop/app/debug.log~connection refused'

Because a run replays exactly, the file is not lost. Fork a branch that keeps the file and starts from a point before the part you care about:

1
2
machine fork app --from ^before --name look --keep-output /output/drop/app/debug.log
machine output look --source /output/drop/app/debug.log

--from replays the branch from that point to where the run is now, and the branch stores the file on the way. Use --at to stop the branch at an earlier point. machine go takes --from too, and moves the machine onto the branch. machine detach takes it for a new root that holds the file and shares nothing with the run it came from.

--keep-output and --drop-output say what a run stores besides what the two directories say. They are options of create, fork, detach and go, the commands that make a run, and a run keeps them for its whole life. machine describe shows the two directories and the names the run gives.

  • A name is a file or a directory under /output, a port such as ttyS1, or a pattern such as '/output/drop/*/*.log'. A pattern is in the syntax of Python’s glob module: *, ?, [abc], [a-z] and [!abc] stay within one directory name, and ** matches any number of directories, as in '/output/**/*.log'. A name that begins with a dot is matched like any other.
  • When a kept and a dropped name cover the same file, a name spelled out decides over a pattern, and of two names spelled out the longer one decides: --keep-output /output/drop/app --drop-output /output/drop/app/huge.log keeps the directory except that file. Otherwise the file is stored.
  • A branch has its parent’s two lists. An option on the fork replaces the list of its own kind and leaves the other as it was. The name none, given alone, is an empty list: --keep-output none keeps nothing beyond what the directories say.

What is stored never changes what the machine executes, so a branch that keeps more still reproduces the recording.

Sending input

A program that reads what a person types can be given that input from outside the machine. machine send writes input to a device of the run:

1
2
3
4
5
machine send app ls                      # type ls and Enter on the console
machine send app ls --device ttyS1 # the same on another serial port
machine send -n app y # no Enter after it
machine send -n -e app '\x03' # Ctrl-C
machine send app - < script.sh # a file, exactly as it is

It works like echo: the text is sent as written and a newline follows, which is Enter. -n leaves the newline out, and -e reads escapes such as \t and \x03.

send does not run the machine. It queues the input and returns, and the device takes it the next time the run executes:

1
2
machine send app 'echo hello'
machine run app --until 'console~hello'

The run records the input where it arrived, so a replay reproduces it without being sent anything. To try other input, fork a branch and send to the branch.

At the control prompt the same command is /send. The options come first and the text is the rest of the line, as you typed it, quotes included:

1
2
3
4
/send ls -la
/send --device ttyS1 echo hello
/send echo "a;b"
/send -n -e \x03

The prompt reads quotes as a shell does. A ; separates commands, except inside quotes, so /send echo "a;b" sends echo "a;b". A quote that is not closed refuses the whole line, so write /send "don't". Put the text in quotes to keep spaces at its ends, as in /send " y ", and put -- before a text that begins with a dash.

Device Is
console the run’s console, which is the default
ttyS0 to ttyS3 the serial ports
hvc0 the virtio console, on a run created with --console virtio
keyboard the PS/2 keyboard

A serial port and the virtio console take bytes. The keyboard takes text and types it on a US keyboard, a key pressed and released for each character, with Shift or Ctrl held where the character needs one. Use it for a program that reads the screen’s terminal and not a serial line.

Commands in the machine

machine exec executes a command in the machine, beside the programs already running there:

1
2
3
machine exec app run -- ls -la /             # execute it and print its output
machine exec app run -- sh -c 'ls | wc -l' # a shell line, on a disk with sh
machine exec app start -- /app/load --rows 9 # send it and return its id

run runs the machine until the command exits, prints what it printed, and exits with its status. A command gets 30 minutes of machine time to end, and --within gives it another: machine exec app run --within 10s -- make check. start sends the command and returns an id. The process starts the next time the run executes, so follow it with machine run.

A command is a program and its arguments, written after --. No shell reads it. Use -c to give a line to the shell of the disk instead, with its pipes and redirections: machine exec app run -c 'ls / | wc -l'.

Processes

Each command is a process. The run records every line the process prints and how it ends, each at its entry, so a replay reproduces them and a branch has the processes of its parent.

machine exec app with no verb lists every command executed in the run, with the entries it started and ended at:

1
2
3
ID       PID  STATE     ENTRIES      COMMAND
23035p1 138 exited 0 23084:23090 ls
23090p1 139 exited 0 23220:23226 sh -c echo foo > /tmp/foo.txt

A process’s id is the entry it was sent at and its number. proc shows one process:

1
2
3
4
5
machine exec app proc 23090p1          # pid, state, exit status
machine exec app proc 23090p1 events # every line and state change, by entry
machine exec app proc 23090p1 stdout # its standard output
machine exec app proc 23090p1 stderr # its standard error
machine exec app proc 23090p1 exits # how it ended, and at which entry

An event’s entry is a point. machine go app '#23224' forks a branch at the entry that printed a line.

The output of a process is a source like any other, under /output/exec/<id>. machine output reads it, and machine run app --until '/output/exec/23090p1/stdout~done' stops the run at a line the process prints. In the machine, its standard output and standard error are the files /.machine/output/exec/23090p1/stdout and /.machine/output/exec/23090p1/stderr, and its events are in /.machine/output/exec/23090p1/status.

Inside a container

Use --container to run a command in a container of your Compose project. It takes the container’s id, its name or the name of its service:

1
2
3
4
machine exec app run --container db -- psql -c 'select 1'
machine exec app run --container db -c 'ls / | wc -l' # the container's shell
machine exec app run --container db --user root -- id # as another user
machine exec app start --container app -- ./worker

--net runs a program of the machine on a container’s network instead: the program comes from the machine’s disk, so it needs nothing in the container’s image, and it sees the container’s interfaces and addresses. This example from Network faults captures the packets of db with the machine’s tcpdump:

1
machine exec app start --net db -- tcpdump --immediate-mode -U -i eth0 -w /.machine/output/keep/db.pcap

machine containers lists the containers with the columns SERVICE, CONTAINER, ID, STATE, IMAGE, ADDRESS, LINK and LIMITS. ADDRESS is the container’s address on each of its networks. LINK is the machine’s interface at the other end of the container’s link, which a capture names in Network faults. LIMITS shows the limits set with Container faults. The service, the container name and the id are what --container takes:

1
machine containers app

Each service’s output, every line it prints across every start of its container, is a source of its own. The console shows all of them together, each line after its service’s name:

1
machine output app --source /output/keep/db/console

The command has the container’s environment and working directory. --user picks the user it runs as, by name or as uid:gid; without it the command runs as the container’s own user. A service that runs several containers is refused, and the message names them, so you pick one. machine put and machine get take the same --container.

A command without --container runs in the machine, beside Docker, and can call Docker itself. The project is named compose:

1
2
3
4
machine exec app run -- docker ps --format '{{.Names}}'                 # the containers
machine exec app run -- docker compose -p compose exec -T db hostname # by service
machine exec app run -- docker exec compose-db-1 hostname # by container
machine exec app run -- docker compose -p compose exec -T db sh -c 'ls / | wc -l'

docker compose exec needs -T, since the command has no terminal. A shell line after the service is run by the image’s own shell, with the image’s tools.

/exec at the control prompt

At the control prompt the command is /exec, with the same verbs and flags. It needs no --: the arguments are the words after the verb, and a line for the shell is the rest of the line after -c, its quotes kept for the shell.

1
2
3
4
5
6
7
/exec run ls -la /
/exec run -c ls / | wc -l
/exec run -c 'X=1;echo $X'
/exec run --container db -- psql -c 'select 1'
/exec start -c gdb -p 36 < /dev/gdb_pipe
/exec proc 23090p1 stdout
/exec

A ; separates commands at the prompt, except inside quotes, so a line with one is written in quotes, as in a terminal. A pair of quotes around the whole -c line is taken off. A $ line, below, needs none of this.

The machine’s shell: $

$ puts you in the machine’s shell. Type a line after it as you would in a terminal. The prompt runs the machine until the line finishes and prints what it wrote. A line that exits other than 0 says so after its output.

Nothing in the line is the prompt’s. Everything after the $ goes to the shell as you typed it, so pipes, redirections, ;, &&, variables and quotes all work without escaping:

1
2
3
4
5
6
7
$ uname -a
$ ls -la /srv
$ ps aux | grep worker
$ cd /srv; make test
$ X=1; echo $X
$ grep -c ERROR /var/log/app.log || echo none
$ echo 'retries=5' >> /etc/app.conf

A $ line is /exec run -c with that line, so the run records it like any other command. /exec lists it, a checkpoint keeps what it changed, and a fork or a replay repeats it. Look around between two steps of a run, change a file, and rewind to a checkpoint to try something else.

A container’s shell: db$

Put a container before the $ to run the line in that container’s shell. Name the container by its Compose service or by its container name, as --container takes it. Put a user and @ before the container to run the line as that user, by name or by uid. Without a user the line runs as the container’s own user.

1
2
3
4
5
6
7
db$ psql -c 'select 1'                          # in the db service
compose-db-1$ hostname # by container name
root@db$ id # as root
70@db$ ls -l /var/lib/postgresql/data # as uid 70
app$ ps aux | grep clickhouse # pipes are the shell's
app$ cd /var/log/clickhouse-server; tail -5 clickhouse-server.log
clickhouse@app$ clickhouse-client -q 'SELECT version()'

db$ LINE is /exec run --container db -c with that line, and root@db$ LINE adds --user root. Everything after the $ goes to the container’s shell as you typed it, and the run records it as it records a $ line.

Commands over several lines

A line goes on in the next one while a quote is open, after a trailing backslash, and through a here-document, as in a shell. The prompt shows > for each line after the first, and runs the whole command once it is complete. A pasted query of several lines is one command:

1
2
3
4
5
6
7
8
9
clickhouse@app$ clickhouse-client -q '
> SELECT name, value
> FROM system.build_options
> LIMIT 3'
$ cat <<EOF > /etc/app.conf
> retries=5
> EOF
$ tar czf /tmp/logs.tgz \
> /var/log/app

The lines of a command are edited together: Backspace at the start of a line goes on into the line above, and the arrows move between the lines. Ctrl+C drops the command.

Input for a program you started

A program that reads commands from its standard input, such as a debugger, is driven through a named pipe. Make the pipe, keep it open, start the program with its input on the pipe, and send to the pipe:

1
2
3
4
5
6
7
machine exec app run   -c 'mkfifo /dev/gdb_pipe'
machine exec app start -c 'sleep 1000000 > /dev/gdb_pipe' # keeps the pipe open
machine exec app start -c 'gdb -p 36 < /dev/gdb_pipe'
machine send app 'b main' --device /dev/gdb_pipe
machine send app c --device /dev/gdb_pipe
machine run app --until vtime=+3s
machine exec app proc 40787p1 stdout # what gdb printed

A --device that begins with / is the path of a file in the machine, and machine send puts the bytes at its end. A process in the machine writes them, and send prints its id: machine exec app proc with that id says whether they were written. One send to a path carries at most 2,042 bytes minus the length of the path, and a little less when the process id is long. A larger send is refused, and the message gives the most bytes that fit.

machine send writes the machine’s own files. For a program in a container, make the pipe in the container and write it from there:

1
2
3
4
5
machine exec app run   --container db -- mkfifo /tmp/p
machine exec app start --container db -c 'sleep infinity > /tmp/p'
machine exec app start --container db -c 'gdb -p $(pidof postgres) < /tmp/p'
machine exec app start --container db -c 'echo c > /tmp/p'
machine run app --until '/output/exec/<id>/stdout~Continuing' --within 10s

<id> is the id exec start printed for GDB.

GDB inside the machine walks through a whole session this way, on ClickHouse.

machine exec sends its requests on the serial port ttyS3, so a program in the machine that reads ttyS3 takes those requests away from machine exec.

From Python, run.exec(["cat", "/etc/hostname"]) runs a program and returns a Process with exit_code, stdout and stderr. A string is a shell line, container="db" and user="root" pick where it runs, and wait=False returns at once with the process’s id:

1
2
proc = run.exec("ls /data", container="app")
print(proc.exit_code, proc.stdout)

Copying files

machine put copies a file of your machine into the running machine, or into one of its containers:

1
2
3
4
5
machine put app ./app.conf /etc/app.conf                    # into the machine
machine put app ./tool.sh /usr/local/bin/tool --mode 755 # with a mode
machine put app ./seed.sql /srv/seed.sql --container compose-db-1
machine put app ./d.bin /data/d.bin --owner 1000:1000 # with an owner
machine put app - /tmp/in < data.bin # standard input
  • put copies a file of any size.
  • The directories on the way to the path are made, and a file already there is replaced.
  • The file has its name only once all of it is written, so a program never reads part of it.
  • The machine runs while the file goes in, and the other programs in it run too.
  • The bytes are a recorded input, so a replay puts the same file and a branch has it.
  • The file is on the disk when put returns. A checkpoint taken after it has the file, and machine fs reads it there.

--container takes a container’s id or name, as machine containers app lists them, or the name of its Compose service: --container db is the container of the service db. A service that runs several containers is refused, and the message names them, so you pick one. The container must be running. A path is resolved inside the container, as a program there would resolve it.

machine send --device <path> is for a line into a pipe, up to 2,042 bytes minus the length of the path. put is for a file.

machine get copies a file the other way, from the machine or from a container to your machine:

1
2
3
machine get app /var/log/app.log ./app.log
machine get app /srv/dump.sql ./dump.sql --container compose-db-1
machine get app /etc/hostname - # standard output

get reads the file as it is now, with what programs wrote and the disk does not have yet. machine fs reads the disk at a checkpoint instead. The machine runs while the file comes out, so a file a program is writing can change on the way.

At the control prompt the commands are /put and /get, with the same operands and options: /put ./app.conf /etc/app.conf.

put into a machine whose disk an older client built still works, but far more slowly. Rebuild the disk to get the speed.

From Python, run.put("./app.conf", "/etc/app.conf") puts a file in, and source can be bytes. run.get("/var/log/app.log", "./app.log") gets one out, and without a destination the Got it returns carries the bytes in data. Both take container=.

Core dumps

machine core tells a process to generate a core dump and copies it to your computer, where a debugger reads it with the program:

1
2
3
machine core app 412 ./app.core                    # pid 412 of the machine
machine core app 7 ./db.core --container db # pid 7 of a container
gdb ./app ./app.core
  • Taking a core ends the process: it dies of a signal, ABRT unless you name another with --signal.
  • To keep your run as it is, fork first and take the core on the branch.
  • With --container, the pid is the one the process has inside the container, as machine exec app run --container db -- ps shows it.
  • A process that handles the signal dumps no core. Name another, such as --signal SEGV.
  • The first process of a container dumps no core. Run your program under an init, init: true in the Compose file, so it is not the first.

From Python, run.core(412, "./app.core") gets the core of process 412, and container="db" names the process by its pid in that container.

Profiling

machine profile shows where a run spent its time, by function and by call stack:

1
2
3
machine profile app                            # a second of everything
machine profile app --for 5s --container db # one container
machine profile app --pid 412 # one process

Here is one second of memstress, one of the example programs, which maps, touches and unmaps memory from four threads:

1
2
3
4
5
6
7
8
463 samples at 250 a second
SELF TOTAL FUNCTION
34.1% 34.1% kernel_[k]
34.1% 34.1% sys_munmap_[k]
19.2% 94.4% worker
5.4% 5.4% sys_madvise_[k]
5.2% 5.2% sys_mmap_[k]
1.1% 1.1% sys_clone3_[k]

SELF is the share of samples a function was running in, and TOTAL the share it was on the stack of. So worker itself ran in 19% of the samples and was on the stack of 94% of them: the rest of its time went to the calls under it.

A name that ends in _[k] is time in the kernel. sys_munmap_[k] is the munmap system call. kernel_[k] is kernel time that is no system call, here the page faults of touching fresh memory.

  • --flame draws a flame graph in the terminal.

  • --folded prints every stack with its count, one per line. That text is what flame graph tools read, so you can save it and draw it with the tool you like, or hand it to an agent:

    1
    2
    3
    4
    5
    memstress;clone3;start_thread;worker;kernel_[k] 56
    memstress;clone3;start_thread;worker;munmap;sys_munmap_[k] 32
    memstress;clone3;start_thread;worker 31
    memstress;clone3;start_thread;worker;mmap64;sys_mmap_[k] 12
    memstress;clone3;start_thread;worker;madvise;sys_madvise_[k] 10
  • -o json gives the same stacks as data.

The samples are taken from outside the machine, at every timer interrupt of each CPU. Nothing is installed in your image and nothing runs in the machine for it, so a run is the same with a profile and without. Your programs do not need frame pointers: a stack is walked by the unwind information every program carries for exceptions.

A recorded stretch

Because a run is recorded, you can profile a stretch of it after the fact, even if no profiler was on at the time:

1
2
machine profile app --from ^request --to ^reply
machine profile app --from 12s --to 14s --flame

The stretch is replayed on a branch, which is deleted afterwards. Your run is not touched, and it does not need to be running. Profile the same stretch twice and you get the same samples.

Where names come from

  • Names come from the program files on the machine’s disk as it is when the stretch ends. You do not need a checkpoint, and a profile does not take one.
  • A file a program in the machine has written but not synced to disk yet shows as [file]. Run sync in the machine first.
  • A stripped program with no unwind information, such as Alpine’s busybox, is one frame named after its file.
  • Time in the kernel is one frame. The functions of the kernel itself are not shown.
  • --in-guest samples with a small process inside the machine instead. Use it when you need the kernel’s own functions by name. It is part of the run, and it cannot profile a recorded stretch.
  • Samples are taken 250 times a second on each CPU.
  • C++ names are printed as the program has them. Pipe --folded through c++filt to read them.

From Python, run.profile("5s", container="db") returns a Profile with samples, functions, stacks and the folded text, and run.profile(from_="^slow", to="^done") profiles a stretch already recorded.

Interactive mode

When you are working on one run for a while, you can open a prompt for it, so you no longer type machine and the run’s name before every command.

1
machine control app

You issue commands to the run as slash commands, like /checkpoint, /branches or /rewind. Most of the commands on this page have one, written the same way without the run’s name. Commands that run the machine, take checkpoints or make and switch branches take their options as plain words, so --at ^booted becomes at ^booted. Commands that execute something in the machine or read its state, such as /exec, /send, /profile or /regs, take the same flags as on the command line: /exec run --container app nproc. Type /help to see them all, and /q or Ctrl+D to leave.

/h and a command shows that command with examples, such as /h exec. A word in capitals in the help is a type: /h RANGE says how to write a range, and /h POINT a point.

Above the prompt, a line shows where the run is: its time, its entry, the vCPU, the RIP, what the entry is, such as IO_OUT, and its state hash. When you come back to an entry, the same hash means the machine is in the same state.

1
⌖ vtime=4.648247180s  entry=32103  vcpu=0  rip=0xffffffff8104880d  IO_OUT  hash=0x91c170d2d6da8e05

The prompt is the easiest way to try something and come back. The session below starts from a new run made from the ubuntu-26.04 disk, the one built in Multiple vCPUs from Ubuntu 26.04 with a container that waits for your commands. Disks has more on building one.

1
2
machine disks build --from ubuntu:26.04 ubuntu-26.04 --entrypoint /bin/sleep -- infinity
machine create app --disk ubuntu-26.04
1
✔ Started app (whyvcWEKxc7c5b2UwO7r6)
1
machine control app

At the prompt, the session below boots the machine until Docker starts its container, keeps that point as a checkpoint, and removes a file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/f until console~Started within 60s
iterations: 24957 run ic: 1525715866 vtime: +3.730915228s checkpoints: 1

VCPU EXIT ID RUN IC RCB TOTAL IC REGS HASH RIP RCX ITER
0 IO 27777 1905719 148 1525715866 0x26180340852cf271 0xffffffff8104880d 1 4

/checkpoint name booted
✔ Created checkpoint booted at entry 27777
Make it durable /sync

/exec run cat /etc/hostname
docker-test

/exec run rm /etc/hostname

/exec run cat /etc/hostname
cat: can't open '/etc/hostname': No such file or directory
✗ Exited 1.

/f runs the machine until Started appears on the console, or for 60 seconds of the machine’s own time at most. Here it takes 3.7 seconds of the machine’s time, and the table shows where each vCPU stopped. To see the machine as it was before the file was removed, fork a branch at booted and switch onto it:

1
2
3
4
5
6
7
8
/go to ^booted
✔ Branched app/27777 (whyvg0aXMSf6g7H2pU5wa) at entry 27777 and switched onto it.

/exec run cat /etc/hostname
docker-test

/switch app
✔ Switched to app (whyvcWEKxc7c5b2UwO7r6)

The branch is named after the entry it was forked at, and the file is there again, while app keeps its own history without it. /switch app moves the machine back. The prompt also remembers the branches you have visited: /go back returns to where the last switch started, /go up and /go down walk the visits in order, and /history lists them. /mark good gives the branch you are on a name, and /switch %good returns to it.

A branch made at the prompt takes the same options as one made with machine fork, written as words. This one records a branch that repeats, with a smaller timer slack than the default, as Recording that repeats describes:

1
2
3
/fork at ^booted name exact repeatable timer-slack 5ms
✔ Forked app/exact (whyvhjPaLbY3hsz3KyytQ)
From checkpoint 27777 of app, nothing replayed

/fork starts the branch beside the one you are on and leaves you where you are. /switch app/exact moves onto it, and /describe:app/exact shows Repeatable: true and Timer Slack: 5ms.

-c runs a single slash command and exits, as in machine control app -c '/state', and machine control log app lists the commands that changed the run.

Keys

The prompt edits a line the way your shell does.

Key Does
Tab completes a command, and after /h a command or a type
Up, Down walk the commands typed at this prompt, the last 500; they are not saved when it closes
Ctrl+C cancels the run, checkpoint or hash in progress, and keeps the prompt; a run stops at the end of its dispatch, and a second Ctrl+C stops it at once; with nothing in progress, Ctrl+C leaves the prompt
Ctrl+D, /q leaves the prompt; the run carries on as it was
; runs the next command after this one, and stops at the first that fails: /s;/d
;+ runs the next command whatever this one did: /replay;+/diff

Quotes work as in a shell, so a ; inside quotes is part of the word: /send "a;b" types a;b. A line with a quote left open continues on the next one, at a > prompt.

Running at the prompt

/run drives the machine as machine run does, and every option of machine run is a word: --until is until, --within is within, --irq-delay is irq-delay. Two shorter forms pick the mode: /f runs fast and /s steps. A suffix picks the vCPU and the number of dispatches: =N drives vCPU N alone, and @N runs N dispatches.

1
2
3
4
5
/f until 'console~app \| ready' within 30s
/s@20
/f=1@10
/run@50 mode fast,step seed 3
/run@200 task-sched keep,hold,yield task-slice 10us:600us seed 7

The first runs fast until ready appears on the console, or for 30 seconds of the machine’s time. /s@20 steps 20 dispatches, and /f=1@10 runs vCPU 1 fast for 10 dispatches. The last two draw something per dispatch from a seed: the mode, then what the focused tasks do and how long each runs, as Schedules describes. /h run lists every word.

Reading another run

A command that reads a run takes :RUN to read another one without switching to it: /describe:app/exact, /checkpoints:app/try-1, /entries:app -20, /lineage:parent. The prompt stays on the branch you are on.

Words that differ from the command line

Most slash commands are machine commands with the run’s name left out and the options of commands that act written as words. These differ:

At the prompt On the command line
/go to ^42 machine go app ^42
/go up, /go down, /go back, /history none: the prompt’s own record of the branches you visited
/delete try-1 recursive force machine delete app/try-1 -r -f; the prompt refuses the branch you are on
/mark good, /mark -good, /marks machine marks add, remove, list
/vcpu=1 machine vcpu app --vcpu 1
/d regs machine dump app --show regs
/checkpoint booted machine checkpoint app booted; /checkpoint name booted also works
/auto-checkpoints 10000 machine run app --auto-checkpoints 10000, at the prompt a setting that stays
/now machine now app

create, start, stop, pause, resume, kill, runs, sessions and disks have no slash command. Use them from the command line beside the prompt.

Scripts and history

-c sends one line and exits, so a script can use the prompt’s syntax. A line can chain commands:

1
2
3
4
machine control app -c '/checkpoint name before'
machine control app -c '/f until console~done within 60s;/d regs'
machine control log app
machine control log app --wide

machine control log lists every command that changed the run, from the prompt or the command line, with the entry where it was issued. Commands that only read are not listed. --wide adds columns.

Stopping and starting

1
2
3
4
5
6
machine pause app
machine resume app
machine stop app
machine start app
machine kill app
machine delete app

pause freezes a running machine and resume lets it carry on. stop shuts a run down and keeps everything it recorded. kill asks the machine to stop and save as stop does, and ends it if it does not stop. In a session, stop and kill both wait until what the run recorded is saved to your storage, and show how far the save has got.

start brings a run back at the end of its log. stop, and a kill that the machine obeys, save a checkpoint at the tip first. A machine that ended before it could save, because kill had to end it or its process died, left recorded entries past its last checkpoint. start replays those entries from that checkpoint to the tip and tells you how many it replayed. Add --no-recover to make it refuse instead.

start can also take a run back to an earlier point. --at replays from an earlier checkpoint, and --read-only opens a checkpoint without running it at all.

1
2
3
machine start app --at ^booted              # replay from booted to the end of the log
machine start app --read-only --at ^booted # the machine at booted, to read
machine start app --no-recover # refuse rather than replay the tail

A run recorded by another version of Machine does not start. Its recording replays only on the version that made it, so start refuses it with it was recorded by another version, followed by the version of its run log and the version the session reads.

--at brings the run up at the checkpoint and replays every entry after it, so the run ends at its tip as it would have without the option, and you see that the recording still replays. A read-only run accepts commands that read, such as machine dump, machine hash and machine output, and refuses run and anything that would record. Stop it, and start it again without --read-only to go on.

A run remembers the options you created it with: --no-daemon, --single-step, --limit and --backstop-limit. Every start and fork repeats them, so you type them once. start takes the same flags to change them for that start only, so machine start app --daemon gives you a machine to drive on a run created with --no-daemon. fork and detach take them too, and the new run keeps what you gave. --pin-cpu is the exception: no run remembers a CPU, so each start and fork picks the least-loaded one unless you name it.

What a run records is fixed when you create it: --side-dump, --side-trace, --mem-hash, --disk-hash and --repeatable. start keeps these settings, and only a new branch can change them: fork, detach and go take each of them, and --no-mem-hash, --no-disk-hash or --no-repeatable to turn one off, and a branch given none records what its parent records. Replay says what the two hashes add.

delete only removes stopped runs, unless you add --stop. It also refuses to remove a run that has branches, unless you add --recursive. And since machine delete --all removes every run, it asks you first.

delete waits until the run is gone, which takes a while for a run with many checkpoints. Add --no-wait and it returns as soon as the delete is accepted, after stopping the machine if you asked it to. --no-wait works only when you delete a single run, so a delete with both --recursive and --no-wait is refused. The delete carries on either way, and machine ops shows how it went.

A delete that was interrupted, by a lost connection or a stopped service, finishes when you run the same delete again. --cleanup -a finishes every interrupted delete at once, and --dry-run lists them first:

1
2
machine delete --cleanup -a --dry-run
machine delete --cleanup -a

To continue a run in a different session, publish it first from the session that has it.

1
machine sync app

To have a run or a disk waiting in a session before you need it, preload it. Going the other way, machine offload lists the copies in this session that can be dropped to free space, and -a drops every one that isn’t in use. The durable copy stays, and starting the run brings it back.

1
2
3
machine preload run app
machine preload disk app
machine offload

machine cleanup removes stale runs and other leftovers, and --force also kills machines that have been orphaned.

ClickHouse is a registered trademark of ClickHouse, Inc. See clickhouse.com.