Two package-level values were built on every launch, `magpie statusline` on each Claude Code message included, for paths it never takes: - codexcat's bundled: json.Unmarshal of the 231 KB codex_instructions.json into a map (~0.48 MB). Now sync.OnceValue, read the first time a model's instructions are looked up. - agent's wslProbeScript: the WSL probe's shell script, grown with `s +=` over every WSL agent, so each step copied the whole string (~0.5 MB), on macOS and Linux too. Now sync.OnceValue, built the first time a distro is probed. Callers and tests call it. Measured on mote, sandbox HOME, t44 (v0.1.3519) against t45 (this): - GODEBUG=inittrace=1 sum: 3.94 MB -> 2.98 MB - `magpie statusline`, 3 runs: instructions retired ~156M -> ~137M Run: go vet ./internal/agent ./internal/codexcat (darwin, GOOS=linux, GOOS=windows) ok; go test ./internal/codexcat ok, ./internal/agent ok (290s); root go vet ./... after rebase below.
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A WSL omp's version is asked in the distro by its probe, so its models
|
|
// offer max from 16.4.0 as the omp on this machine's do (whqtian on
|
|
// Discord: a WSL omp still had max made xhigh, its version not known).
|
|
// One on Windows' drives isn't asked, and one that says no version is
|
|
// taken for an older omp as before.
|
|
func TestWSLOmpVersionProbed(t *testing.T) {
|
|
if !strings.Contains(wslProbeScript(), `echo "ver:omp $(PATH="${p%/*}:$PATH" timeout 10 "$p" --version`) || !strings.Contains(wslProbeScript(), `/mnt/*) ;;`) {
|
|
t.Fatalf("the probe doesn't ask omp its version: %s", wslProbeScript())
|
|
}
|
|
if strings.Contains(wslProbeScript(), `"ver:codex`) {
|
|
t.Error("the probe asks a kind that doesn't need it")
|
|
}
|
|
d := parseProbe("U", "home:/home/me\nbin:omp /home/me/.bun/bin/omp\nver:omp omp/16.5.1\n")
|
|
if d == nil || d.Versions["omp"] != "16.5.1" {
|
|
t.Fatalf("version not read: %+v", d)
|
|
}
|
|
if v := d.place("omp@wsl:U").version; v != "16.5.1" || !ompTakesMax(v) {
|
|
t.Errorf("omp@wsl:U's place has version %q", v)
|
|
}
|
|
if v := d.place("pi@wsl:U").version; v != "" {
|
|
t.Errorf("pi got omp's version %q", v)
|
|
}
|
|
if d := parseProbe("U", "home:/home/me\nver:omp sh: omp: not found\n"); d == nil || d.Versions["omp"] != "" || ompTakesMax(d.place("omp@wsl:U").version) {
|
|
t.Errorf("no version said, yet %+v", d)
|
|
}
|
|
}
|