Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/language: TestBestMatchAlloc failures with "got 1.000000; want 0" #45809

Closed
bcmills opened this issue Apr 27, 2021 · 1 comment
Closed
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Apr 27, 2021

2021-04-11T12:01:40-c2d28a6/linux-ppc64-buildlet
2021-04-11T12:01:40-c2d28a6/linux-ppc64le-buildlet
2021-04-11T12:01:40-c2d28a6/linux-s390x-ibm
2020-11-18T01:06:06-4482a91/linux-ppc64-buildlet

The test calls testing.AllocsPerRun with a count of 1:
https://github.com/golang/text/blob/e328d63cff14134669501e0e154e4f141c784322/language/match_test.go#L245-L247

That pattern is basically guaranteed to be flaky: AllocsPerRun sets runtime.GOMAXPROCS to 1, but it doesn't have any way to prevent the runtime from descheduling a goroutine and performing an allocation somewhere in the background, and it isn't at all obvious that the test has enough control over its environment to guarantee that no other goroutine that might allocate can be scheduled at that point.

The test should be changed to use a number of runs large enough to average away the occasional noisy allocation.

@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Apr 27, 2021
@bcmills bcmills added this to the Backlog milestone Apr 27, 2021
dpaks added a commit to dpaks/text that referenced this issue May 22, 2021
The test calls testing.AllocsPerRun with a count of 1.
AllocsPerRun sets runtime.GOMAXPROCS to 1, but it doesn't prevent the runtime from descheduling a goroutine
and performing an allocation somewhere in the background.
This commit changes the test to use a number of runs large enough to average away the occasional noisy allocation.

Fixes golang/go#45809
@gopherbot
Copy link

Change https://golang.org/cl/321737 mentions this issue: language: use multiple runs in TestBestMatchAlloc

@golang golang locked and limited conversation to collaborators May 24, 2022
xhit pushed a commit to xhit/text that referenced this issue Oct 10, 2022
AllocsPerRun sets runtime.GOMAXPROCS to 1, but it doesn't prevent the runtime from descheduling a goroutine
and performing an allocation somewhere in the background.
This commit changes the test to use a number of runs large enough to average away the occasional noisy allocation.

Fixes golang/go#45809

Change-Id: Ibf904016d0c067740469c8e861079611440222a1
GitHub-Last-Rev: 1606b69
GitHub-Pull-Request: golang#23
Reviewed-on: https://go-review.googlesource.com/c/text/+/321737
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants