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

tidb-server: introduce go.uber.org/automaxprocs #13340

Merged
merged 3 commits into from
Nov 11, 2019

Conversation

tennix
Copy link
Member

@tennix tennix commented Nov 11, 2019

What problem does this PR solve?

This PR closes #13337 to allow auto set GOMAXPROCS to the CPUs tidb-server can use.

What is changed and how it works?

Introducing the package go.uber.org/automaxprocs, this package will read cgroup system to get the CPU the process can use and adjust the GOMAXPROCS to the CPU limit. When users already explicitly set performance.max-procs to non-zero, then the value provided by users will override the default value, so it does not have break change.

Check List

Tests

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

Run tidb-server inside a kubernetes pod which has cpu limit by GODEBUG=schedtrace=1000 ./tidb-server, the reported GOMAXPROCS is exactly the cpu limits set by pod resources.

Code changes

None

Side effects

None

Related changes

  • Need to cherry-pick to the release 2.1 and 3.0
  • Need to update the documentation

Release note

Auto set GOMAXPROCS in Docker container environment.

@codecov
Copy link

codecov bot commented Nov 11, 2019

Codecov Report

Merging #13340 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #13340   +/-   ##
===========================================
  Coverage   80.1608%   80.1608%           
===========================================
  Files           469        469           
  Lines        112626     112626           
===========================================
  Hits          90282      90282           
  Misses        15384      15384           
  Partials       6960       6960

@tennix tennix changed the title auto set GOMAXPROCS according to its environment tidb-server/main.go: auto set GOMAXPROCS according to its environment Nov 11, 2019
@ngaut ngaut requested review from coocood and zz-jason November 11, 2019 08:16
@coocood
Copy link
Member

coocood commented Nov 11, 2019

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason
Copy link
Member

zz-jason commented Nov 11, 2019

@tennix according to Commit Message and Pull Request Style, we should use <subsystem>: <what changed> as the Pull Request title format.

@tennix tennix changed the title tidb-server/main.go: auto set GOMAXPROCS according to its environment tidb-server: introduce go.uber.org/automaxprocs Nov 11, 2019
@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement. labels Nov 11, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 11, 2019

Your auto merge job has been accepted, waiting for 13354, 13209, 13166

@sre-bot
Copy link
Contributor

sre-bot commented Nov 11, 2019

/run-all-tests

@sre-bot sre-bot merged commit 79ff3eb into pingcap:master Nov 11, 2019
@tennix tennix deleted the automaxprocs branch November 11, 2019 11:18
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow auto setting GOMAXPROCS in container environment
4 participants