/api/providers took ~25ms of CPU a call with the owner's real config (25
providers, plugins signed in), polled by every open window. Its profile
had file system calls at about half, each repeated for every provider
the list shows:
- StampNow stat'ed providers.json, settings.json and the catalog for every
provider (KeptListing); under a request's Hold it is looked at once.
- plugin.ListedAt was asked for every plugin provider's Listed(); once a
request (heldOf "plugin-listed").
- pluginLogins took logins.json's lock, a file opened across magpies,
for every plugin even with nothing to change. It now settles the list
as read first, and takes the lock and settles again from a fresh read
only when something changes.
- clientShape read and parsed client-shapes.json for every relay a list
shows (TestsAs); parsed once until the file changes (filememo), a copy
given out.
- Logins(agent) took the same lock for every provider, twice with its
account models; listed once an agent a request, a copy each, listed
anew after a write (writePrivate's filememo.Forget).
Run (on mote unless named):
- go test ./internal/provider ./internal/gui -timeout 45m: provider ok
(102s) with the new tests; gui red on TestMainWindowCorners (macOS 27,
#3949) and on TestSettingsSaveKeepsWhatItDoesNotSend, red on main since
b09349d17, fixed by #4514's commit before this one.
- At the pushed head (rebased on e84870f17): go test ./internal/provider
ok (100.7s), ./internal/plugin ok (102.7s), TestLoginsListedOnceARequest
-count=5 ok (it now clears the 30s look another test left), gui
TestSettingsSaveKeepsWhatItDoesNotSend and TestCoreScriptBudget ok;
GOOS=linux and windows go vet ./internal/provider ok.
Then rebased onto 3defaf662 (internal/agent dsh.go only); not rerun.
- New tests: TestStampLooksOnceARequest, TestClientShapeParsedOnceUntilWritten,
TestLoginsListedOnceARequest, and TestAccountListsCopyNoLoginsUnchanged
now counts the lock. Broken by hand, each goes red: "51 stamps in one
request looked 51 times, want 1", "30 asks parsed the file 30 times",
"20 plugin lists with nothing to change took the lock 20 times",
"20 lists in one request listed 20 times".
- GOOS=linux and windows go vet ./internal/provider: ok. gofmt clean.
- Real config, on this Mac: a copy of the owner's ~/.config/magpie in an
offline sandbox HOME (proxy :9), 200 GET /api/providers each:
v0.1.2541 5.04s CPU (25.2ms a call, median 22.5ms wall), this change
4.55s (22.8ms, median 20.3ms). The profile's stats under StampNow fell
from 2.17s to 0.34s.
Not run: the full ./... suite; GUI (browser) tests, as nothing the page
gets changed. What is left in the profile: StepFun's sign-in file,
sync.json, plugin icons and agent detection, each read once a request.