Commit Graph
1 Commits
Author SHA1 Message Date
yetone 079da3a785 perf: a state poll lists dsh profiles once, and skips work for Codex's models and gateway base
Each /api/state poll redid work for each agent row. That work is now done
once, or skipped:
- dsh's profile list is held for the request (dshProfilesHeld). dshModern,
  Joined and dshLead each globbed profiles/*/cordis.patch.yml again.
  Writers still call dshProfiles.
- CodexSignInGone reads the record first. With nothing on record for the
  home, the usual case, it no longer parses auth.json and hashes the
  refresh token on each look. A record that can't be read answers as
  before.
- Codex's effort field reads catalog.CodexShared(), which doesn't copy.
  With both lists, they are joined into one presized slice.
- codexViaMagpieFor builds one presized slice instead of two that grow
  and are then joined.
- onAnotherMachine answers a plain loopback base (localhost, 127.0.0.1,
  [::1], digits-only port, no user info) without url.Parse. Anything
  else still goes through url.Parse.

Measured on mote with the real-account sandbox, allocations over 40
/api/state polls, two alternating pairs:
- before (216ac6f85): 34.6 and 36.2 MB
- after: 26.8 and 23.7 MB

Run on mote:
- go vet on agent, provider and catalog.
- go test, all of internal/catalog.
- go test, internal/provider -run "Gone|SignIn|Codex".
- go test, internal/agent -run "OnAnother|Codex|Dsh|DSH|ZCode|Zcode|Loopback".
All ok.

New test: TestOnAnotherMachineQuickLookAgrees compares the quick look with
the url.Parse logic over 21 bases (user info, a port with letters,
uppercase, [::1], %2f) and requires 0 allocations for the gateway base.

Not tried: the full internal/agent suite (about 50 min).
2026-11-10 08:12:56 +08:00