provider: the live-model test weighs the same steps on Windows too
TestLiveModelReadWithoutACopy (v0.1.2449) took LiveListed alone as the
cost of a look before the copy. liveByID also asks whether the list is
the provider's and the id it is listed by, which cost more on Windows,
whose stat allocates more: green on macOS, red on Windows ("a look at
one model took 2552 bytes, the list's read 1232"). The baseline now
takes the same steps, and the bar is half a model: the same steps leave
~0 bytes over, a copy 448 and more (on macOS the bar was 16 bytes from
the old code's 1112).
Run on mote and on the Windows box: the test ok -count=10 on each; with
liveByID back on the copying LiveByID it is red 10 of 10 on each. go
vet darwin and windows of internal/provider ok, gofmt -l clean. The
rest of internal/provider on Windows has 14 reds that are the same at
origin/main f9ca3dd44 (keychain, git links, daemon env, two allocation
tests): TestResolveKeptAcrossRequests is #4633, filed now; the
others are #4115, #2808 and #4446.
This commit is contained in:
@@ -52,11 +52,15 @@ func TestLiveModelReadWithoutACopy(t *testing.T) {
|
||||
runtime.ReadMemStats(&after)
|
||||
return (after.TotalAlloc - before.TotalAlloc) / 200
|
||||
}
|
||||
// the read of the list itself (its path, the file's look) is the
|
||||
// same either way; what is over it is the copy
|
||||
read := bytesPer(func() { catalog.LiveListed("r") })
|
||||
// the steps before the list is read (whether it is the provider's, the
|
||||
// id it is listed by) and the read itself, the file's look, are the
|
||||
// same either way; what is over them is the copy. Each costs more on
|
||||
// Windows, whose stat allocates more.
|
||||
read := bytesPer(func() { _ = p.lists(); _ = p.OwnModelID("m-7"); catalog.LiveListed("r") })
|
||||
looked := bytesPer(func() { p.liveByID("m-7") })
|
||||
if size := uint64(unsafe.Sizeof(catalog.Model{})); looked >= read+size {
|
||||
// the same steps leave nothing over; a copy, a model and more. Half a
|
||||
// model leaves room both ways.
|
||||
if size := uint64(unsafe.Sizeof(catalog.Model{})); looked >= read+size/2 {
|
||||
t.Fatalf("a look at one model took %d bytes, the list's read %d; a model is %d", looked, read, size)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user