Commit Graph
1 Commits
Author SHA1 Message Date
yetone 7e340036a7 agent: a goose on PATH is told apart from a Go program without parsing its symbol table
Telling Block's goose from pressly's Go migration tool (goProgram) called
buildinfo.ReadFile, which parses a binary's whole symbol and string tables
before it looks for Go's build info. For Block's goose, a 260 MB Rust
program, that was ~210 MB allocated on the first state the window asked
for (the procmem heap profile: 200 MB under debug/buildinfo, gooseIn,
goProgram, in the first 10 minutes of GUI use). It is kept per file
afterwards, but the heap had grown by it and kept the room.

Now the file is read through a 256 KB buffer for Go's build-info magic
("\xff Go buildinf:") first. A file without it is no Go program; one with
it is still asked of buildinfo, so the answer is the same as before.

Measured on the real ~/.local/bin/goose (260 MB, Rust): 214468 KB
allocated and 460 ms before, 256 KB and 244 ms after.

Tested with TestGoProgramReadsNoSymbolTable (a 40 MB Mach-O whose
LC_SYMTAB names 32 MB of strings: 186 MB allocated before, fails; under
4 MB after) and TestHasGoMagicAcrossReads (the magic across a buffer
boundary, zeros, this Go test binary). TestGooseDetectSkipsGoGoose (a
real Go goose is skipped, a script goose detected) passes. gofmt -l
clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
pass. The full suite is run before the push of this batch.
2026-10-21 04:16:24 +08:00