1ccacad63281094de8a3372d5a507d38f9969e5c
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f03ec97b8f |
proc: a PATH folder that doesn't answer is left out of every look (ifccod7391564 on X)
Started with `open -a`, magpie ran but took over 60s to write
"started", while the same binary run from a shell started in 1s. The
reporter's trace: startUp → agent.RenameLegacy → onMachine →
vscodePortableData → binAt("code-insiders"). Without Insiders,
exec.LookPath walks all of PATH, and a folder on a mount that no longer
answers holds open()/stat() until it does, before applog.Start.
The block isn't binAt's alone: startUp builds every agent through
local() in RenameLegacy and again in moveEfforts (Cursor's and
Antigravity's), each asking for its command through binAt/proc, all
walking the same PATH, and lookStamp stats every PATH folder first. So
the bound is where all of them pass, in proc (reach.go): each PATH
folder is asked (a stat and an open) in a goroutine of its own, all at
once, and one that hasn't answered in 1s is left out of the stamp and of
the look until its probe returns; a probe still out isn't started again,
so later looks skip the folder at once. With such a folder, the command
is looked for in the others, each as a path (exec.LookPath on dir/name).
An answer is trusted for a minute. findMise and FindShell's last resort
used exec.LookPath directly and now go through Look.
Test: TestHungPathFolderIsLeftOut puts a folder whose probe never
returns before the folder with the tool: three looks find the tool, PATH
is never walked whole, the folder is probed once; once it answers, PATH
is walked as before.
Run: go test ./internal/proc ./internal/claudetui on mote ok; go vet for
darwin, linux and windows ok; the proc look tests on the Windows box
(win-run) ok.
Broken by hand: with lookPath not asking hungDirs, the test is red
("PATH was walked 3 times", wsl-run).
Not tried: a real dead network mount on PATH; the test fakes it at the
probe. Direct exec.LookPath calls outside proc (daemon, library, update)
aren't on the startup path and are unchanged.
|
||
|
|
62f612fd44 |
proc: recheck tools installed within a directory clock tick
Adapt JoeyWu-tech f9d7eac9: do not retain lookup answers or directory listings while their timestamps are fresh. Freeze the clock in the same-tick regression so scheduler delays cannot age the fixture. Keep the settled/future directory cache and document the 100ms resolution limit. Validation: the same-tick regression fails with both old layers, only the stamp fixed, and only the listing fixed. Restored proc lookup and four affected agent tests pass five race runs. Batch run, at tree 104d75f0a (the twelve coffemon ports together, on origin/main |
||
|
|
8a4cfe0e4e |
proc: a command that isn't installed is answered from each PATH folder's listing, not a stat per extension, so a Library change after a start no longer looks for ~100 agents' commands one file at a time on Windows (#1624, Hipple)
On every Library create, switch or delete, Targets() asks agent.Detected for about a hundred agents. Each one's command is looked up with exec.LookPath, and on Windows with FindTool's findDirs as well. A command that isn't installed costs a stat of name+each PATHEXT extension in every folder. The answers are cached (looked), but that cache is empty after a start and is dropped whenever any PATH folder's mtime changes. With an antivirus slowing every stat, that is the slow first change Hipple sees. Each folder's listing is now read once (lower-cased names, also each name up to every dot) and read again only when the folder's mtime changes. A command that no folder has a name for is not found without a stat. One a folder may hold, and any folder that can't be read, goes to exec.LookPath and toolIn as before. On Windows the current folder is included unless NoDefaultCurrentDirectoryInExePath is set, as exec.LookPath does. Measured on the Windows test box (47 PATH folders, WSL agents off, library ops through a throwaway test in a sandbox HOME): - the first create after a start went from 486ms to 285ms; the old CPU profile was mostly exec.LookPath/GetFileAttributesEx; - warm ops ~10ms either way. With WSL agents on, the first op costs ~3.0s on both builds, about 2.7s of it in wsl.exe list and probe spawns. This commit doesn't change that. On the box, wsl -l -q, wsl -l --running -q and a docker-desktop probe each take 40-75ms, so a failed-probe retry every 10 min doesn't explain the report there. The 5-8s after 10 min idle wasn't reproduced: ops after 4, 8 and 12 min idle took ~120ms. Run: go test ./internal/proc ./internal/agent ./internal/library (ok); gofmt -l; GOOS=linux and GOOS=windows go vet on the three packages. I broke the fix by hand (look.go/find.go back to exec.LookPath, mayBeIn check off), and TestMissingCommandsReadEachFolderOnce failed: "100 missing commands were looked for on PATH 200 times, want 0". |