usage: CodexModelEffort's allocation bar is a packed row a call, not a visit (#2278)
TestCodexModelEffortLetsUnrelatedCallsGo held a build of
CodexModelEffort to a visit of the log and a half. Since dc6f6d902 a
visit decodes into a lent buffer, and allocated 74 KB or 289 KB as the
pool kept that buffer through the test's GC or not, so the bar moved
under a build of ~430 KB and the test was red now and then (1 of 2 runs
on mote at the change below, "a build allocated 430336 bytes, a visit
73848").
The bar is now what #2776 was about: a build over 3000 unrelated calls
allocates less than one packed row (216 B) for each of them, 648 KB.
Builds measured 215 to 430 KB.
Run at this head, on mote:
- go test ./internal/usage -run TestCodexModelEffortLetsUnrelatedCallsGo
-count=30: ok.
- go test ./internal/usage -timeout 45m: ok (23.2s).
Not tried: reverting #2776's fix to see the bar go red.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/yetone/magpie/internal/sessions"
|
||||
)
|
||||
@@ -88,11 +89,15 @@ func TestCodexModelEffortLetsUnrelatedCallsGo(t *testing.T) {
|
||||
if got := CodexModelEffort(All); len(got["main-a"]) != 1 {
|
||||
t.Fatalf("main-a's consumption: %+v", got)
|
||||
}
|
||||
visit := measure(func() { Visit(time.Time{}, func(Record) {}) })
|
||||
// a packed row a call: the bar was a visit of the log, but a visit
|
||||
// decodes into a lent buffer now (#2278), and took 74 KB or 289 KB as
|
||||
// a pool kept it or not
|
||||
rows := uint64(calls+1) * uint64(unsafe.Sizeof(packedRow{}))
|
||||
build := measure(func() { CodexModelEffort(All) })
|
||||
t.Logf("a build allocated %d bytes, a visit %d", build, visit)
|
||||
// the visit itself, the thread's own rows and the sets of its ids
|
||||
if build > visit+visit/2+256<<10 {
|
||||
t.Fatalf("a build over %d unrelated calls allocated %d bytes, a visit of the log %d", calls, build, visit)
|
||||
t.Logf("a build allocated %d bytes, the log's rows are %d", build, rows)
|
||||
// the thread's own rows and the sets of its ids, less than a packed
|
||||
// row for each unrelated call
|
||||
if build > rows {
|
||||
t.Fatalf("a build over %d unrelated calls allocated %d bytes, a packed row each is %d", calls, build, rows)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user