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

tools/bin/ut: accelerate building test binary #31882

Merged
merged 16 commits into from
Jan 25, 2022

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Jan 21, 2022

What problem does this PR solve?

Issue Number: close #31880
A subtask for #30822

Problem Summary:

Build the test binary one by one is painfully slow.

Before change:

6m39.360986586s

After change:

1m56.399393108s

What is changed and how it works?

go test --exec=xprog, the Go compile toolchain would call your xprog program passing the test binary path as the argument...

So you can do this trick, write you own xprog, and move the test binary to some place else, save it for later use.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Now you can use go test --exec=xprog to build all test binaries at once.

genius@genius-System-Product-Name:~/project/src/github.com/pingcap/tidb$ pwd
/home/genius/project/src/github.com/pingcap/tidb


genius@genius-System-Product-Name:~/project/src/github.com/pingcap/tidb$ make tools/bin/xprog
cd tools/check; \
GO111MODULE=on go build -o ../bin/xprog xprog.go

genius@genius-System-Product-Name:~/project/src/github.com/pingcap/tidb$ go test --exec=/home/genius/project/src/github.com/pingcap/tidb/tools/bin/xprog ./...
ok      github.com/pingcap/tidb/bindinfo        0.062s
ok      github.com/pingcap/tidb/br/cmd/br       0.048s
ok      github.com/pingcap/tidb/br/cmd/tidb-lightning   0.027s
ok      github.com/pingcap/tidb/br/cmd/tidb-lightning-ctl       0.007s
ok      github.com/pingcap/tidb/br/pkg/backup   0.010s
ok      github.com/pingcap/tidb/br/pkg/checksum 0.003s
ok      github.com/pingcap/tidb/br/pkg/conn     0.020s
?       github.com/pingcap/tidb/br/pkg/errors   [no test files]
?       github.com/pingcap/tidb/br/pkg/glue     [no test files]
?       github.com/pingcap/tidb/br/pkg/gluetidb [no test files]
ok      github.com/pingcap/tidb/br/pkg/gluetikv 0.028s
?       github.com/pingcap/tidb/br/pkg/httputil [no test files]
ok      github.com/pingcap/tidb/br/pkg/kv       0.017s
ok      github.com/pingcap/tidb/br/pkg/lightning        0.028s
ok      github.com/pingcap/tidb/br/pkg/lightning/backend        0.060s
ok      github.com/pingcap/tidb/br/pkg/lightning/backend/importer       0.020s
ok      github.com/pingcap/tidb/br/pkg/lightning/backend/kv     0.064s
ok      github.com/pingcap/tidb/br/pkg/lightning/backend/local  0.014s
?       github.com/pingcap/tidb/br/pkg/lightning/backend/noop   [no test files]
ok      github.com/pingcap/tidb/br/pkg/lightning/backend/tidb   0.049s
ok      github.com/pingcap/tidb/br/pkg/lightning/checkpoints    0.067s
?       github.com/pingcap/tidb/br/pkg/lightning/checkpoints/checkpointspb      [no test files]
ok      github.com/pingcap/tidb/br/pkg/lightning/common 0.021s
ok      github.com/pingcap/tidb/br/pkg/lightning/config 0.002s
ok      github.com/pingcap/tidb/br/pkg/lightning/errormanager   0.017s
?       github.com/pingcap/tidb/br/pkg/lightning/glue   [no test files]
ok      github.com/pingcap/tidb/br/pkg/lightning/log    0.002s
?       github.com/pingcap/tidb/br/pkg/lightning/manual [no test files]
ok      github.com/pingcap/tidb/br/pkg/lightning/metric 0.013s
ok      github.com/pingcap/tidb/br/pkg/lightning/mydump 0.034s
ok      github.com/pingcap/tidb/br/pkg/lightning/restore        0.015s
ok      github.com/pingcap/tidb/br/pkg/lightning/tikv   0.009s
ok      github.com/pingcap/tidb/br/pkg/lightning/verification   0.030s
?       github.com/pingcap/tidb/br/pkg/lightning/web    [no test files]
ok      github.com/pingcap/tidb/br/pkg/lightning/worker 0.017s
...

genius@genius-System-Product-Name:~/project/src/github.com/pingcap/tidb$ find . -name '*.test.bin'
./tablecodec/rowindexcodec/rowindexcodec.test.bin
./tablecodec/tablecodec.test.bin
./config/config.test.bin
./meta/autoid/autoid.test.bin
./meta/meta.test.bin
./metrics/metrics.test.bin
./privilege/privileges/privileges.test.bin
./executor/executor.test.bin
./executor/seqtest/seqtest.test.bin
./executor/aggfuncs/aggfuncs.test.bin
./executor/oomtest/oomtest.test.bin
./owner/owner.test.bin
./kv/kv.test.bin
./br/pkg/task/task.test.bin
./br/pkg/checksum/checksum.test.bin
./br/pkg/version/build/build.test.bin
./br/pkg/version/version.test.bin
./br/pkg/mock/mock.test.bin
./br/pkg/gluetikv/gluetikv.test.bin
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 21, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • hawkingrei
  • tangenta

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 21, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 21, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jan 24, 2022

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 24, 2022
@tangenta
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: eb15c5b

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 24, 2022
@hawkingrei
Copy link
Member

/run-check_dev_2

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

1 similar comment
@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

@hawkingrei
Copy link
Member

/run-mysql-test

@tiancaiamao
Copy link
Contributor Author

/run-check_dev_2

@tiancaiamao
Copy link
Contributor Author

/run-unit-test

1 similar comment
@hawkingrei
Copy link
Member

/run-unit-test

@ti-chi-bot
Copy link
Member

@tiancaiamao: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 373f041 into pingcap:master Jan 25, 2022
@tiancaiamao tiancaiamao deleted the go-build-test branch January 25, 2022 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make ut build the test binary too slow
5 participants