Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions boot/firmware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package boot_test

import (
"cmp"
"encoding/json"
"fmt"
"net"
Expand Down Expand Up @@ -115,13 +116,13 @@ func (p *probe) start(t *testing.T, variant string, gen bool, incoming, kernel,
args := []string{
"-L", p.firmware,
"-machine", "q35,sata=off,smbus=off",
"-accel", "kvm", "-cpu", orElse("host", cpu),
"-accel", "kvm", "-cpu", cmp.Or(cpu, "host"),
"-m", "2048", "-smp", "2",
"-nodefaults", "-display", "none", "-serial", "stdio", "-monitor", "none",
"-qmp", "unix:" + qmp + ",server=on,wait=off",
"-bios", p.bios[variant],
"-kernel", orElse(p.kernel, kernel),
"-initrd", orElse(p.initrd, initrd),
"-kernel", cmp.Or(kernel, p.kernel),
"-initrd", cmp.Or(initrd, p.initrd),
"-append", "console=ttyS0 quiet loglevel=3 pci=lastbus=0 no_timer_check " +
"tsc=reliable rcupdate.rcu_expedited=1 TERM=dumb rdinit=/init",
}
Expand Down Expand Up @@ -397,12 +398,3 @@ func pct(v []float64, p int) float64 {
x, _ := boot.Percentile(v, float64(p)/100)
return x
}

// orElse is the override or the default, and exists so that a probe varying one argument
// of the machine line does not need a second copy of the whole line.
func orElse(dflt, override string) string {
if override != "" {
return override
}
return dflt
}
2 changes: 1 addition & 1 deletion boot/fwstages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestFirmwareStages(t *testing.T) {
reps := envInt(t, "REPS", 10)
initrd := probeInitrd(t)

flags := strings.Fields(orElse("--cpus 1 --memory 512 --max-cpus 16 --max-memory 8192 --hotplug-disks 1", os.Getenv("FLAGS")))
flags := strings.Fields(cmp.Or(os.Getenv("FLAGS"), "--cpus 1 --memory 512 --max-cpus 16 --max-memory 8192 --hotplug-disks 1"))
flags = append([]string{"--disk", "-", "--initrd", initrd, "--console", "file:/dev/stdout"}, flags...)
cli := filepath.Join(out, "bin", "spin-machine")
type variant struct {
Expand Down
14 changes: 5 additions & 9 deletions boot/initcalls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
package boot_test

import (
"cmp"
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -111,7 +111,7 @@ WantedBy=multi-user.target
checkName = name
}
dump = strings.Replace(dump, "FORMATCHECK ", check+" ", 1)
cvs := slices.Clone(cmdlineVariants)
cvs := []cmdlineVariant{{label: "baseline"}}
if k := kernelB(t); k != "" {
cvs = append(cvs, cmdlineVariant{label: "kernel B", kernel: k})
}
Expand All @@ -128,8 +128,8 @@ WantedBy=multi-user.target
}

base := variant{
cpus: orElse("2", os.Getenv("CPUS")),
memory: orElse("2048", os.Getenv("MEMORY_MIB")),
cpus: cmp.Or(os.Getenv("CPUS"), "2"),
memory: cmp.Or(os.Getenv("MEMORY_MIB"), "2048"),
flags: strings.Fields(os.Getenv("FLAGS")),
files: map[string]string{
"/etc/systemd/system/spin-dmesg.service": dump,
Expand Down Expand Up @@ -282,18 +282,14 @@ func clip(s string) string {
}

// The command lines to compare: the baseline, which the per-initcall table below is taken
// from, and a kernel B or C when one is named.
// from, and a kernel B or C, or a command line B, when one is named.
//
// Smaller TCP and UDP hash tables (thash_entries=2048 uhash_entries=2048), for inet_init's
// 8 ms on a machine that will never hold 32768 connections, moved nothing: 85.8 ms against
// the baseline's 85.7 to "Freeing unused kernel image", inet_init 7.84 against 7.70 (10 and
// 30 boots, 2026-09-30).
type cmdlineVariant struct{ label, extra, kernel string }

var cmdlineVariants = []cmdlineVariant{
{label: "baseline"},
}

// initcallsOfInterest are printed side by side for every variant, because a variant that
// moved the total is only interesting once it is clear which initcall moved.
var initcallsOfInterest = []string{
Expand Down