Repository navigation
driver/memcached: compare the least of several interleaved rounds in the per-operation limit alloc test - #1237
Merged
Merged
Conversation
…TestOperationLimitDoesNotAllocate1218 The test measured the client with the per-operation limit and the one without it one after the other, one AllocsPerRun of 200 runs each, and failed when the first came out above the second. Under -race sync.Pool drops Puts at random, so a round of either side can end an allocation above its true cost (1 round in 35 on 2 CPUs), and with one round per side the Coverage job saw "4.0 allocs/op with the limit, 3.0 without" (10 failed runs of 1000 under -race before). Both clients are built and warmed first and measured in turns over 7 rounds of 100 runs, and the test compares the least of the rounds of each side. The noise only adds allocations, so the least is the cost; a limit that allocates raises every round of its side. The plain budget (TestAllocBudgets) stays the guard. Refs #1235
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
…nate the side measured first The comparison sees a limit that costs a whole allocation or more on every command (AllocsPerRun rounds its average down, so one that allocates on some commands only is invisible, as it was to the single round); the comment says so. The side measured first alternates from round to round. Refs #1235
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1235
TestOperationLimitDoesNotAllocate1218/eventloopfailed on the Coverage job (-race):4.0 allocs/op with the limit, 3.0 without.Reproduced (Linux, golang:1.27.3, 2 CPUs,
go test -race -run TestOperationLimitDoesNotAllocate1218)-count=200: 3 failed subtests in 2 runs (direct, eventloop, netconn).-count=1000: 10 failed runs of 1000 (5 direct, 2 eventloop, 3 netconn of 3000 subtests). The rounds that came out one above their cost went both ways (10 times4.0 with, 3.0 without, 22 times3.0 with, 4.0 without), so the limit costs nothing and the noise issync.Pool's.Change
The two clients are built and warmed first, then measured in turns over 7 rounds of 100 runs, and the test compares the least of the rounds of each side (
onMin > offMinfails). Per-round measure under-race(12 rounds x 89 runs x 3 clients): a round ends at 4 instead of 3 about once in 35 rounds, never at 5, on either side alike. The noise only adds allocations, so the least of the rounds is the cost of a side; with 7 rounds all of one side's rounds would have to be inflated (about 1e-11). The side measured first alternates from round to round. A limit that costs a whole allocation or more on every command raises every round of its side and so its least, and fails the test.AllocsPerRunrounds its average down, so a limit that allocates on only some of the commands (under 1 per command on average) is not seen, in plain mode or under-race; the single round this replaces did not see it reliably either (only by the same pool noise that made it flaky). The strict budgetTestAllocBudgetsis untouched, and no!racetag is added, soci.ymlis unchanged.Mutant
beginOpallocates one object per command when the limit is on (mutSink = new([16]byte)):4.0 allocs/op with the limit, 3.0 withoutin 60 of 60 subtests (20 runs x 3 clients), red under-raceand plain, with the alternating order as well.After
-race -count=500: 0 failures (1500 subtests, all3.0 with, 3.0 without); plain-count=200: 0 (600 subtests). (The first version of this PR:-race -count=10000 failures, against 10 failed runs of 1000 before.)go test -race ./driver/memcachedok;GOOS=windowsandGOOS=darwingo vet ./driver/...ok; golangci-lint 0 issues on./driver/memcached/....Siblings
No other comparison test in #1222 or #1227 counts allocations:
alloc_guard_test.go(#1222) is an absolute budget under!race; the #1227 tests are about socket options.TestRefreshForMovedAllocatesNothingWhenNothingFailed1214in driver/redis asserts an absolute 0 on code that uses no pool.