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

testing: benchmark timeout when benchtime set too long #49973

Open
lkxiaolou opened this issue Dec 4, 2021 · 9 comments · May be fixed by #50023
Open

testing: benchmark timeout when benchtime set too long #49973

lkxiaolou opened this issue Dec 4, 2021 · 9 comments · May be fixed by #50023
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@lkxiaolou
Copy link

What version of Go are you using (go version)?

go1.15

Does this issue reproduce with the latest release?

yes

What did you do?

When benchmark function execute time is very short, set benchtime=5s / 10s / 20s is ok.

BenchmarkNewObject-2            1000000000               0.279 ns/op

But set benchtime=120s will execute time out.

*** Test killed with quit: ran too long (11m0s).

What did you expect to see?

Do not timeout

What did you see instead?

*** Test killed with quit: ran too long (11m0s).
@lkxiaolou lkxiaolou changed the title affected/package: Benchmark timeout when benchtime set too long Dec 4, 2021
@gopherbot
Copy link

Change https://golang.org/cl/369294 mentions this issue: Fix #49973 benchmark timeout when benchtime set too long

@seankhliao
Copy link
Member

Duplicate of #12446

@seankhliao seankhliao marked this as a duplicate of #12446 Dec 4, 2021
@lkxiaolou
Copy link
Author

Duplicate of #12446

Not the same, see #49974, int64 overflow, may be a bug

@mvdan
Copy link
Member

mvdan commented Dec 6, 2021

I agree that this might not be a duplicate - the code doesn't seem to be safe against overflows.

That said, the fix doesn't seem complete. Not all overflows will result in negative numbers.

@mvdan mvdan reopened this Dec 6, 2021
@seankhliao seankhliao changed the title Benchmark timeout when benchtime set too long testing: benchmark timeout when benchtime set too long Dec 6, 2021
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 6, 2021
@lkxiaolou
Copy link
Author

I agree that this might not be a duplicate - the code doesn't seem to be safe against overflows.

That said, the fix doesn't seem complete. Not all overflows will result in negative numbers.

Sorry, Is there any other cases?

@mvdan
Copy link
Member

mvdan commented Dec 6, 2021

https://go.dev/play/p/MBFpdZOOSgx

That example also has some better overflow detection that you can enable and try for yourself.

Note that there are multiple operations involved in testing/benchmark.go, including multiplications and additions. Proper overflow checking won't be as trivial as in my example.

@mvdan
Copy link
Member

mvdan commented Dec 6, 2021

Also, a fix would need to come with a test :)

@lkxiaolou lkxiaolou linked a pull request Dec 7, 2021 that will close this issue
@lkxiaolou
Copy link
Author

Also, a fix would need to come with a test :)

Done, see new PR #50023

@gopherbot
Copy link

Change https://golang.org/cl/372395 mentions this issue: Fix #49973 benchtime too long leads timeout

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants