-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: cmd/go: add a method to output test that might be worth running in parallel #65770
Comments
That an interesting idea, should For example it wouldn't report tests that modify global state, but would report some test that only modify local objects. |
Static analysis has the advantage of avoiding testing that reports changes to global state, which often should not be parallelized, such as runtime_test.TestChan. The advantage of analyzing after running the test is that it is simple to implement, and the implementation can be to determine whether the time taken exceeds a certain limit after the test is run. Note that |
Each call to T.Parallel is an assertion by the test's maintainer that the test is concurrency-safe with respect to all other tests marked as Parallel. In the absence of the assertion, the test runner must assume that the test is not concurrency-safe, as is often the case. Inviting users to run tests in parallel that have not been designed for concurrency safety seems to me a bit like inviting them to test the top speed of a car whose seatbelts, brakes, and airbags have been removed to reduce weight. Faster but less safe is not the Go way.
I don't think this is practically feasible within the current state of the art of static analysis. |
This proposal is not an invitation for users to run tests that are not designed for concurrency safety in parallel, but to help users find tests that may be worth parallelizing. In packages with a large number of tests, such as runtime, it is not easy to manually analyze go test -v to find tests that might be worth running in parallel because there is too much invalid information such as a test running 0.00s. If the application can identify tests that might be worth running in parallel, the developer can use the energy saved to study whether the tests should be run in parallel, rather than spend the energy searching for valid information in a pile of invalid information. Ideal use case for this proposal:
|
Proposal Details
I am created https://go-review.googlesource.com/c/go/+/564995 and https://go-review.googlesource.com/c/go/+/564576, in this process, discover a way to find test possible worth running in parallel, which can be done automatically with go test .
This method is
go test -v
gets the run time for each of the tests, then excludes tests that have already been run in parallel and tests that have taken a short time, and the rest are tests that might be worth running in parallel.For example:
get from
go test -v runtime
This can determine that TestSmosherTwoNonzero may be worth running in parallel.
However, based on the experience gained in the aforementioned CL, it is more convenient for go test to perform this search.
because there may be many tests, there may be log and skip outputs, and there are clear rules for performing this lookup with
go test
.Specific proposal content
Add a flag, name undetermined, use maybeparallel as placeholder for now,
go test -maybeparallel
only provides this semantics, which reports tests that may be worth running in parallel.One way to achieve this is outputs the name and time of the test that did not run in parallel and took longer than 0.4 seconds.
Worth discussing:
Maybe also should add a flag, set test that is not complete after a certain time,
go test -maybeparallel
only output these test name and test run time.The text was updated successfully, but these errors were encountered: