After statKind (e3ab7f3bf), os.Stat was still a fifth of what forty /api/drift asks allocated with real accounts: Agent.Detected's look at the agent's file, bundleInfo's and folderSubs' size-and-time stamps for every desktop app, and qoderApp's status files. Each os.Stat makes an os.FileInfo on the heap. They now go through the system call into a Stat_t on the stack: - Detected: statKind (exists, followed through links, as os.Stat). - qoderApp: statFile, a regular file as Mode().IsRegular() says. - bundleInfo, folderSubs: statStamp, mtime and size as ModTime/Size say (Mtimespec on darwin, Mtim on linux; os.Stat elsewhere). Windows and other systems keep os.Stat. Run (at this tree): - mote: go test -count=1 ./internal/agent ok (518s, load high after a reboot); go vet darwin; linux and windows vet clean - wsl-run (Linux): TestStatStamp|TestStatKind|TestQoder ok - win-run (Windows): same set; TestQoderSettingsFromAnIDEPluginIsNotTheCLI red, and red the same on origin/main783cd0f84(#1827: the fixture is an extensionless #!/bin/sh on PATH); the rest ok - TestStatStampAndFileSayWhatStatSays compares with os.Stat for a file, a folder, a link, a gone path and a path under a file; with darwin's statStamp put back on os.Stat by hand it is red (3 allocations for two looks), restored - Real accounts (sandbox HOME copy), 40 /api/drift calls, paired runs: os.Stat 2.0/3.1 MB before, 1.5/0 MB after (left: pencilApp, a glob, provider.stampOf); totals 20.2/19.1 MB before, 18.5/17.5 MB after.
17 lines
372 B
Go
17 lines
372 B
Go
package agent
|
|
|
|
import (
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
// statStamp is p's modification time and size, links followed, as
|
|
// os.Stat's ModTime and Size would say (statstamp_darwin.go).
|
|
func statStamp(p string) (mod time.Time, size int64, ok bool) {
|
|
var st syscall.Stat_t
|
|
if !statInto(p, &st) {
|
|
return time.Time{}, 0, false
|
|
}
|
|
return time.Unix(st.Mtim.Unix()), st.Size, true
|
|
}
|