Detection asks isDir, isFile and Taken of about a thousand paths on each
of the window's 15s /api/drift asks. os.Stat made an os.FileInfo on the
heap for each, a fifth of what forty asks allocated with real accounts.
statKind calls syscall.Stat into a Stat_t on the stack (retrying EINTR,
following links as os.Stat does); only the path made a C string is
left. Windows keeps os.Stat (statkind_other.go).
Run:
- TestStatKindAnswersWithoutAFileInfo: folder, file, gone, a path under
a file, "" and a link to a folder answer as os.Stat did; two looks
take 2 allocations. Broken by hand (statKind through os.Stat): red, 4.
- go test ./internal/agent on mote; go vet ./internal/agent for darwin,
windows and linux.
- Real accounts (sandbox HOME on mote, 40 /api/drift asks), paired:
os.Stat's allocations 4.6 and 4.1 MB before (t24), 1.0 and 1.5 MB
after (t25); totals 25.0 and 22.6 MB before, 18.4 and 22.0 MB after.