gateway: searcherModel's allocations are held to its own 4-model count, not a fixed 50 (#5123)
TestAutoVisionDoesNotBuildListsAgain checked AutoVision against its own count with 4 models, but searcherModel against a fixed 50. What a call allocates differs by OS: 130 on Windows (#5123), 51 on Linux at origin/main, run alone too, so the test was red on both while the lists were kept as meant. Both halves now measure 4 and 400 models and fail when 400 costs more than 50 above 4, which is what the test is named for. Run: - broken by hand (keptSmallCands builds the list each call): red on WSL, AutoVision 496 -> 934 and searcherModel 135 -> 573. - restored: -run 'TestAutoVision|TestSearcher' -count=5 ok on WSL (382/382, 51/51); -count=3 ok on the Windows box (658/658, 130/130). - go vet ./internal/gateway (Windows), gofmt -l: clean.
This commit is contained in:
@@ -51,26 +51,32 @@ func manyEyes(t *testing.T, n int, all bool) {
|
||||
// its allowance: 5.3 GB of a day's 36 GB of allocations. Asked again with
|
||||
// nothing changed, it costs the same whatever the lists' length.
|
||||
func TestAutoVisionDoesNotBuildListsAgain(t *testing.T) {
|
||||
allocs := func(n int) float64 {
|
||||
// what each costs asked again, with n models; measured against the
|
||||
// same call with 4, as a fixed count differs by OS and load (#5123:
|
||||
// searcherModel made 129 on Windows, 51 in a full Linux run)
|
||||
allocs := func(n int) (vision, searcher float64) {
|
||||
manyEyes(t, n, false)
|
||||
if got := AutoVision(); got != "eyes/google/gemini-3-flash" {
|
||||
t.Fatalf("AutoVision = %q of %d", got, n)
|
||||
}
|
||||
return testing.AllocsPerRun(20, func() { AutoVision() })
|
||||
vision = testing.AllocsPerRun(20, func() { AutoVision() })
|
||||
// and the searcher's pick, built the same way
|
||||
p, err := provider.Find("eyes")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
searcherModel(*p)
|
||||
searcher = testing.AllocsPerRun(20, func() { searcherModel(*p) })
|
||||
return vision, searcher
|
||||
}
|
||||
few, many := allocs(4), allocs(400)
|
||||
t.Logf("allocations an AutoVision: %.0f with 4 models, %.0f with 400", few, many)
|
||||
few, fewS := allocs(4)
|
||||
many, manyS := allocs(400)
|
||||
t.Logf("allocations an AutoVision: %.0f with 4 models, %.0f with 400; searcherModel %.0f and %.0f", few, many, fewS, manyS)
|
||||
if many > few+50 {
|
||||
t.Fatalf("AutoVision made %.0f allocations with 400 models, %.0f with 4: the lists are built again", many, few)
|
||||
}
|
||||
// and the searcher's pick, built the same way
|
||||
p, err := provider.Find("eyes")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
searcherModel(*p)
|
||||
if a := testing.AllocsPerRun(20, func() { searcherModel(*p) }); a > 50 {
|
||||
t.Fatalf("searcherModel made %.0f allocations with 400 models", a)
|
||||
if manyS > fewS+50 {
|
||||
t.Fatalf("searcherModel made %.0f allocations with 400 models, %.0f with 4: the lists are built again", manyS, fewS)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user