MMotor OS
Developing

Profiling

Most standard profilers do not work with Motor OS yet, but a Motor OS program can be instrumented with the tracing crate and its trace turned into a flame graph on the host, which is enough to find, for example, the causes of high CPU contention.

Instrument the code

Collect and visualize

profile.svg is the CPU profile flame graph. profile.folded is a text file; you may need to edit it by hand or adjust inferno's options to make the graph readable.

Built-in microbenchmarks

systest carries three measurement tools next to its test suite (on the development image it is /devtools/tests/systest; on the standard image, copy build/bin/release/systest into the VM first). A bare systest runs the suite only; each tool has its own subcommand and prints to stdout.

For your own experiments, stats get (see Logs and diagnostics) reads the same counters: the kernel's include sched.poll_hit, sched.ipi_elided, sys_cpu_waits and sys_cpu_wakes; read them before and after a run and take the difference.

Other benchmarks

Observing a running system

top, ps, pstat, free and uptime show CPU and memory per process; time CMD times a command; ss lists the TCP sockets sys-io knows. stats list, stats providers and stats get <provider>[:<metric>][:<scope>] read any metric from any provider: the kernel is provider 1 and sys-io provider 2, the scope is a PID (0 is the aggregate), so stats get 1::2 is the kernel's view of sys-io (its syscalls, waits, wakes and page maps) and stats get 2 sys-io's own filesystem and network counters. For a hung or slow process, /devtools/bin/mdbg print-stacks PID prints every thread's stack as addresses; addr2line against the unstripped binary under build/obj turns them into symbols (see Logs and diagnostics).