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

Add a Reserved option #14

Closed
wants to merge 8 commits into from
Closed

Add a Reserved option #14

wants to merge 8 commits into from

Conversation

jcorbin
Copy link
Contributor

@jcorbin jcorbin commented Feb 16, 2018

Okay, after offline discussion with @prashantv and @akshayjshah, here's an addendum to #13:

  • adds a Reserved(q float64) option that can be used to not allocate all of the CPU quota to GOMAXPROCS
  • intentionally left room, per discussion with @akshayjshah, so that we can more easily choose to add an option that takes some sort of a custom strategy func (i.e. maybe a func(func(quota float64, config CPUQuotaConfig) (int, CPUQuotaStatus)) Option)
  • based this branch off master, so we cane choose whether to have (some version) of it and/or Use floor(quota) rather than ceil(quota) #13

Questions I have for reviewers at the outset:

  • would you prefer much of the prep work broken out from the introduction of Reserved?
  • would you rather just externalize some rendition of the internal runtime types and jump to a more generic strategy-func option?

@codecov
Copy link

codecov bot commented Feb 16, 2018

Codecov Report

Merging #14 into master will decrease coverage by 2%.
The diff coverage is 85.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
- Coverage   93.58%   91.57%   -2.01%     
==========================================
  Files           7        7              
  Lines         187      190       +3     
==========================================
- Hits          175      174       -1     
- Misses         10       14       +4     
  Partials        2        2
Impacted Files Coverage Δ
maxprocs/maxprocs.go 91.11% <85.18%> (-8.89%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6fecebd...82b4fde. Read the comment docs.

Copy link

@arkajit arkajit left a comment

Choose a reason for hiding this comment

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

Sounds reasonable to have a separate reservation for resources used outside the go-runtime.

Left a couple small comments about whether we want to respect this reservation fully or whether the boundary between reserved and non-reserved quota is permeable. The answer depends on the previous discussion about whether we want to prevent throttling or under-utilization.

From the system perspective, it seems clear that we'd prefer throttling to under-utilization, but at the moment the throttling penalty is quite large (100ms) which can be severe for latency-critical applications. Ideally we'd allow applications to make this tradeoff themselves.

if cfg.Reserved > 0 {
quota -= cfg.Reserved
}

maxProcs := int(math.Ceil(quota))
Copy link

Choose a reason for hiding this comment

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

Do we want Floor here after all? If we use Ceil, we will not be respecting the full reservation for the Reserved quota. Can Reserved ever be fractional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, we do want floor, this PR was just written orthogonally to #13.

// outside of the Go runtime; e.g. by a cgo extension, or another process
// within the container.
//
// GOMAXPROCS will be set to the remaining (rounded down) quota, clamped to the
Copy link

Choose a reason for hiding this comment

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

Is "rounded down" still the intention? This part of the comment contradicts the use of Ceil in CPUQuotaToGOMAXPROCS (commented there).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is, this doc comment is out of line with the code reality above, good catch.

Copy link
Collaborator

@jasonlai jasonlai left a comment

Choose a reason for hiding this comment

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

Good stuff!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Joshua T Corbin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

None yet

4 participants