Repository navigation
Conversation
TestSchemelessLinear compared wall-clock times, which cannot be made reliable on shared Windows runners (coarse timer, GC pauses, noisy neighbours). Assert linearity on counted work instead: a test-only step hook in the DSN and keyword scans, plus allocation counts and bytes, must each grow under 15x (bytes 25x) for 10x input over 13 adversarial shapes. Allocation checks are skipped under -race, which shadows allocations. The wall-clock check stays as a coarse safety net, best of 5, 40x plus a 5 ms floor, and is skipped on Windows and under -short.
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.
Row id: LINEAR-TEST2
Problem
TestSchemelessLinearstill fails on windows-2022 on main after #980 (run 40445087019), e.g.4000 B took 0s/call, 40000 B took 2.0303ms/call: not linear. A wall-clock ratio cannot be made reliable on shared Windows runners (coarse timer, GC pauses, noisy neighbours).Note: the test lives in
internal/credmask(Schemeless,maskDSNUserinfo), notinternal/config.MaskURLCredentialscalls it. I ran both packages.Change
internal/credmask/schemeless.go: a nil-in-productionstepHookthat receives the bytes read by each scan inmaskDSNUserinfo(forward pass, colon-prefixLastIndexByte) andmaskKeywordValues(per match). No behaviour change.TestSchemelessLinearis now deterministic: for 13 adversarial shapes (@a(,:@a(,a:@,a:b@c(,x=y@a(,password=,password= x, letter runs,::::,@@@@, one colon /:/// quote followed by@a() at 4 KB and 40 KB it requires steps < 15x, allocation count < 15x, allocated bytes < 25x (TotalAlloc deltas, min of 3). Allocation checks are skipped under-race(the race detector shadows allocations); the step check always runs.TestSchemelessLinearWallClockis the coarse safety net: skipped on Windows and-short, best of 5, 40 KB vs 400 KB, ratio < 40 plus a 5 ms floor.Measured growth for 10x input (current code, 4 KB to 40 KB)
a:b@c(, 46 to 55 B/byte for@a() from 256 KB to 4 MB. This is slice doubling and size classes, not super-linearity, hence the 25x bytes bound (a quadratic rebuild is 100x).Mutation proof
Temporarily restored the pre-#979
maskDSNUserinfo(fromc1d7e536^, withsteps(2*len(token))on its rescans):TestSchemelessLinearFAILED on 5 shapes (@a(: 5,326,668 vs 533,266,668 bytes read;x=y@a(,one colon then @a(,scheme then @a(,quote then @a(), and the wall-clock test failed too (@a(40 KB 3.5 ms, 400 KB 239 ms). Reverted; the committed code is the linear one.Commands run
go test -count=20 -run TestSchemelessLinear ./internal/credmask: ok (21.9 s; also runs the wall-clock test)go test -count=1 ./internal/config ./internal/credmask: okgo test -race -count=1 ./internal/credmask: okgo test -count=1 -covermode=atomic ./internal/credmask: okGOOS=windows go vet ./internal/config ./internal/credmask: cleanGOOS=windows go test -c ./internal/credmask: compiles (the Windows test itself runs only in CI)gofmt -l internal: cleanUntouched: cli#958.
TestMaskURLCredentialsLinearininternal/configis also wall-clock but uses a 250 ms floor and was not in the failing log, so it is unchanged.