Entry.Provider was a Provider value, 1,328 of an Entry's 1,760 bytes, copied into every model of every provider each time a catalog, an agent's list or a routing group's entries were built. It is now a *Provider: entriesOf and decide's list give every model of one provider the same one (sharedEntry), and a group's entry points at its first member's. It is read only; every place that hands it on as a value (Resolve, CanFast, ownAgent, modelAllowed, …) dereferences it, so what they get is a copy as before. entryFor keeps its signature for the one model ServedEntryOf builds; offEntries' entries now carry their provider too. Measured on mote with the owner's real accounts (acctp sandbox, page open for 2m32s, w40 = before, w41 = this, alternating): - catalogOf's allocations 106 MB -> 67 MB, providerEntries' 88 -> 78 MB - CPU at the page's settle mark 3.42/3.33 s -> 3.18/3.30 s - live heap unchanged (76.3/76.1 -> 76.7/75.9 MB): the lists are rebuilt, not kept, so the copies were churn for the GC, not held Run: go build and go vet ./... and the tests compiled (go test -run ^$) on mote; the full suite at this tree (d1e823d5f) on mica: 99 packages ok, 0 FAIL (agent 317s, gateway 972s, gui 188s, provider 220s, usage 56s).
33 lines
1.6 KiB
Go
33 lines
1.6 KiB
Go
package provider
|
||
|
||
import "testing"
|
||
|
||
// A magpie's list tells another the provider serving each model
|
||
// (magpie_by): its own provider, the one at the start of a chain of
|
||
// magpies for a Remote magpie's, "routing group" for a group (lcc580 on
|
||
// X). A Remote magpie whose list said none (one from before) is named
|
||
// as ever, upstream names on or off.
|
||
func TestServedByAndUpstreamLabel(t *testing.T) {
|
||
relay := Provider{ID: "relaya", Name: "Relay A"}
|
||
remote := Provider{ID: "office", Name: "Office", Preset: RemoteMagpiePreset, UpstreamProviders: true}
|
||
for _, c := range []struct {
|
||
e Entry
|
||
by, label string
|
||
}{
|
||
{Entry{Name: "DeepSeek Chat", Provider: &relay}, "Relay A", "DeepSeek Chat · Relay A"},
|
||
{Entry{Name: "Fast", Group: "fast", Provider: &relay}, "routing group", "Fast · routing group"},
|
||
{Entry{Name: "DeepSeek Chat · Relay A", Plain: "DeepSeek Chat", By: "Relay A", Provider: &remote}, "Relay A", "DeepSeek Chat · Office › Relay A"},
|
||
{Entry{Name: "Mine", Default: "DeepSeek Chat", By: "Relay A", Provider: &remote}, "Relay A", "Mine · Office › Relay A"},
|
||
{Entry{Name: "DeepSeek Chat · Relay A", Plain: "DeepSeek Chat", Provider: &remote}, "Office", "DeepSeek Chat · Relay A · Office"},
|
||
// upstream names on a provider that isn't a Remote magpie do nothing
|
||
{Entry{Name: "DeepSeek Chat", By: "Relay A", Provider: &Provider{ID: "x", Name: "X", UpstreamProviders: true}}, "X", "DeepSeek Chat · X"},
|
||
} {
|
||
if got := c.e.ServedBy(); got != c.by {
|
||
t.Errorf("%+v: served by %q, want %q", c.e, got, c.by)
|
||
}
|
||
if got := c.e.Label(); got != c.label {
|
||
t.Errorf("%+v: label %q, want %q", c.e, got, c.label)
|
||
}
|
||
}
|
||
}
|