colmugx found magpie hotter with groups, and worse since ~v0.1.1225.
Yayoi_no_yume saw CPU jump to 100% as soon as a request entered a group,
and stay there under concurrency.
Cause: one request to a group asked for the groups' entries
(groupEntries) five or six times: Catalog from Resolve and IsDecider,
and Served from membersImageInput, outputLimit, windowIn and roomy. A
direct provider/model request asked through Resolve too. Nothing held
that work. Each build:
- went through every member of every group, the found auto-<model> ones
included, with a linear pass over the whole catalog per member. It
copied each large Entry it passed (groupEntries, resolveIn);
- since 8f4d091c6 (#2224) ran smallestWindow for every group, not only
one set to ContextSmallest. That was a second full pass per member,
which is the regression after v0.1.1225;
- parsed settings.json again for each group's disabled models
(membersIn -> disabledList -> settings.LoadChecked).
Fix:
- groupEntries is held while a request holds the catalog. heldFrom keys
it to the catalog slice it was built from, so it is rebuilt for a
rebuilt catalog. Catalog and Served hand out a copy.
- Each member's entry is looked up in a map built once per build.
- smallestWindow runs only for ContextSmallest.
- resolveIn walks by index, not by copying each Entry.
- disabledList is held like heldSettings. SetDisabledModels calls
Changed, so a change is seen at once.
Guards (each fails without its fix, broken by hand):
- TestGroupEntriesBuiltOnceWhileHeld: the same build under one Hold.
Also checks that a caller's change to Catalog doesn't reach the next
caller, that another catalog is built from, and that a save is seen.
- TestGroupLooksParseNoSettingsPerGroupWhileHeld: settings parses per
look.
- BenchmarkGroupEntries (provider) and BenchmarkGroupOverhead /
BenchmarkGroupOverheadParallel (gateway). These use fake upstreams:
direct vs groups of 1, 4 and 8 members, one with a failing first
member and one with a resting first member, at 200KB and 2MB, streamed
and not, on a 12x20 and a 30x60 catalog.
Numbers. cpu-ms/op is process CPU per request. The machine was at load
~200-430, so wall times are not comparable.
- Catalog of 30 providers x 60 shared models, 200KB, non-stream,
BenchmarkGroupOverhead, 5x:
| Version | direct p0/m1 | groups (g1 g4 g8u gfail grest) |
|----------------------|--------------|--------------------------------|
| v0.1.1225 (54ba9042d) | 242 | 976 / 1006 / 965 / 966 / 945 |
| HEAD ccb2eea15 | 571 | 1462 / 1745 / 1719 / 1758 / 1715 |
| this commit | 76 | 93 / 116 / 91 / 114 / 106 |
Parallel, HEAD -> this commit: direct 563 -> 73, groups 1355-1625 ->
94-152. The cost of entering a group, over direct: ~+1150 ms at HEAD,
~+15-40 ms now. Memory per group request: 200MB -> 74-79MB. Allocs:
442k -> 128-141k.
- BenchmarkGroupEntries, one build of the 30x60 catalog's groups, CPU:
HEAD 233 ms; HEAD with smallestWindow gated only 151 ms; this commit
20 ms.
- 12x20 catalog, 200KB, HEAD (before): direct 45.5, groups 83-89
cpu-ms/op. v0.1.1225: direct 37, groups 85-97. So with a small catalog
the overhead is old, not new. It grows with providers x models x
groups, which is why colmugx's and Yayoi_no_yume's catalogs feel it.
Run at this head:
- go test ./... -timeout 45m at load ~430: 60 packages ok, including
internal/provider. internal/agent, internal/gateway and
internal/library hit the 45m timeout under that load. These were not
failures. internal/gui failed two tests:
- TestSetAnswersWhileDevinAndProvidersHang ("set slow/slow-1 took
11.9s", over its 10s wall bound) failed in the run and once more
alone (16.25s). It passed on the ccb2eea15 checkout (9.95s) and
2 of 2 with -count=2 at this commit. It is a wall-clock bound under
load, and this commit doesn't touch its path.
- TestMainWindowCorners was killed while measuring and passed rerun.
- go test ./internal/gateway -run
'Group|Member|Rout|Fallback|Rest|Window|Image' -count=1: ok (221s)
- TestGroupLooksParseNoSettingsPerGroupWhileHeld with disabledList not
held: red, "settings.json parsed 50 times in 50 looks"
- gofmt -l internal: clean
- GOOS=linux go vet -tags nogui ./...: clean
- GOOS=windows go vet ./...: clean
oxsean asked for one place to turn a model (claude-fable-5) off for good:
not reached by a direct request, an old session, a routing group member,
a fallback, a sub-agent, count_tokens or a decision model.
What changed:
- settings.DisabledModels: patterns, an exact id or a glob (* any run, /
included; ? one), matched ignoring case against provider/model, the
bare id and its last segment (provider/disabled.go). Empty by default,
so nothing changes for anyone who doesn't set it.
- Lists: buildEntries (entriesOff) leaves a disabled model out of the
catalog, so /v1/models, agents' model files and pickers, Codex's list
and every group go without it; membersIn skips it as a member, Deciders
as a decision model; codexModels drops Codex's own disabled slugs and
codexListTag changes so Codex refetches.
- Requests (gateway/disabled.go): 403 "model <id> is disabled in magpie"
in each API's error shape, at #882's choke points: serve (idOff),
perKeyBarred (no candidate: group next member, provider Fallback),
count_tokens and Gemini :countTokens, serveSystemOne,
serveDecisionGroup and postDecide, draw/video/embeddings, and
codexBackend for Codex's own bare models. A group with a member left
goes on without it; one with none left is refused naming them. A bare
id the catalog no longer has is refused as disabled, not 404. A Codex
sub-agent pick onto a disabled model stays on its lead's model.
- An unreadable settings.json is never "none disabled": the list read
last stays; with none read, every request is refused; nothing is
written over the file.
- CLI: magpie model disable <model|glob>..., enable ..., disabled
(list-disabled).
- GUI: Settings > Models > Disabled models: each pattern with the models
it matches now and Enable; Disable... opens the model picker, which
also takes a typed glob. Says only requests through magpie are covered.
POST /api/settings/disabled-models; POST /api/settings keeps the list.
Strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: Disabled models section.
What was run (worktree at origin/main 091593f7d, private GOCACHE, temp HOME):
- gofmt -l clean; go vet on darwin (touched pkgs), GOOS=linux -tags nogui
./..., GOOS=windows ./... clean; go build ./...
- go test -count=1 ./internal/provider ./internal/gateway ./internal/cli
./internal/gui ./internal/settings: all ok (gui after adding the field to
TestSettingsSaveKeepsWhatItDoesNotSend's fixture, which it asked for).
- node --test internal/gui/tests/disabled-models.test.cjs: 16/16 (chromium
+ webkit, en/zh/ja/de, 1100/420); neighbouring Settings > Models tests
and i18n-keys: 131/131.
- Broken by hand, each turned TestDisabled* red: serve's idOff (404
instead of 403), perKeyBarred's filter (fallback reached spare), the
catalog filter (/v1/models and Codex list), countOff (count_tokens 200),
postDecide's check (decision call went out).
- Not tried with a real vendor account or a real agent.
Ref #1867