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/pd-ut: accelerate build by compile-without-link #8069

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

HuSharp
Copy link
Member

@HuSharp HuSharp commented Apr 16, 2024

What problem does this PR solve?

Issue Number: Ref #7969

What is changed and how does it work?

Behind the scene, it's a technique called 'staged build'.

If we build all the test binaries parallelly, the go compiler will detect that much of the pacakge cache are not available, so it would build package cache several times. For example, building pkg/server/api and pkg/server/apiv2 parallelly, they all depends on a lot of other small packages, since those packages do not exist at the time. The package is built repeatedly because of the parallel.

If we build all the packages first to make the cache available, and then built the test binaries, we can avoid repeated package building. This make the whole process a little bit faster.

And rely on this article, we can build without link. https://blog.howardjohn.info/posts/go-build-times/#linking-vs-compiling

run below command

function run-with-cores() {
  cores="$1"
  shift
  docker run --rm -v $PWD:$PWD -w $PWD \
    --cpus="$cores" -e GOMAXPROCS="$cores" \
    -e 'GOFLAGS=-buildvcs=false' \
    -v `go env GOMODCACHE`:/go/pkg/mod \
    -it --init golang:1.21 bash -c "$*"
}

run-with-cores 2 '
make pd-ut
go clean -modcache 
time ./bin/pd-ut build
'

before vs after

real		7m51.159s
user		9m8.612s
sys 		1m18.024s
---
real		5m51.492s
user		9m29.775s
sys 		1m18.955s

Check List

Tests

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

Release note

None.

Signed-off-by: husharp <[email protected]>
Copy link
Contributor

ti-chi-bot bot commented Apr 16, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • nolouch

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 bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 16, 2024
@HuSharp HuSharp mentioned this pull request Apr 16, 2024
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Merging #8069 (f3c5fab) into master (41ff34b) will decrease coverage by 0.06%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

❗ Current head f3c5fab differs from pull request most recent head d4b06d2. Consider uploading reports for the commit d4b06d2 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8069      +/-   ##
==========================================
- Coverage   77.33%   77.27%   -0.06%     
==========================================
  Files         469      469              
  Lines       61097    61097              
==========================================
- Hits        47247    47213      -34     
- Misses      10289    10316      +27     
- Partials     3561     3568       +7     
Flag Coverage Δ
unittests 77.27% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 16, 2024
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 16, 2024
@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 16, 2024

@nolouch: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and 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.

If you have any questions about the PR merge process, please refer to pr process.

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.

Copy link
Contributor

ti-chi-bot bot commented Apr 16, 2024

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

Commit hash: 09120fb

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 16, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 16, 2024

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

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 bot merged commit 22543a9 into tikv:master Apr 16, 2024
22 checks passed
@HuSharp HuSharp changed the title tools/pd-ut: accelarate build by compile-without-link tools/pd-ut: accelerate build by compile-without-link Apr 19, 2024
@HuSharp HuSharp deleted the support_ut_build_cache branch April 19, 2024 02:15
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/M Denotes a PR that changes 30-99 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.

3 participants