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

Comments

@lkxiaolou
Copy link

@lkxiaolou lkxiaolou commented Dec 4, 2021

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

@gopherbot gopherbot commented Dec 4, 2021

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

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Dec 4, 2021

Duplicate of #12446

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

@lkxiaolou lkxiaolou commented Dec 6, 2021

Duplicate of #12446

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

@mvdan
Copy link
Member

@mvdan 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
@lkxiaolou
Copy link
Author

@lkxiaolou lkxiaolou 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.

Sorry, Is there any other cases?

@mvdan
Copy link
Member

@mvdan 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 mvdan commented Dec 6, 2021

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

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

@lkxiaolou lkxiaolou commented Dec 7, 2021

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

Done, see new PR #50023

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants