Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

threads: restrict number of golang threads if not set #115

Merged
merged 1 commit into from
Nov 2, 2018

Conversation

grahamwhaley
Copy link
Contributor

If the max number of golang threads (GOMAXPROCS) is not set in
the environment, then set it ourselves to a small set, but
only if the host has more cpus than that max.
This avoids us taking the default (the number of host cores)
on large-core systems, which can end up with us having a lot of
idle threads generated, consuming host PID space, and thus
artificially restricting how many containers we can run
in parallel.

Fixes: #114

Signed-off-by: Graham Whaley graham.whaley@intel.com

@grahamwhaley
Copy link
Contributor Author

For both this and its equiv over in the proxy, I ran the metrics density and footprint tests to check if there was visible (hopefully positive) impact.
On the 88 core machine there was a mild (~2%) drop in KSM density and boot speed. That is probably near the 'noise' threshold of the tests, but at least it is in the right direction.

main.go Outdated
// code in shim.go
const maxthreads = 6
if runtime.NumCPU() > maxthreads {
runtime.GOMAXPROCS(6)
Copy link
Contributor

Choose a reason for hiding this comment

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

runtime.GOMAXPROCS(maxthreads) maybe? :)

Same comment as for kata-containers/proxy#118 - might be worth moving the const to the top for better visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s/6/maxthreads/ indeed (oops ;-)).
The const - yeah, was not sure if better at the top or here.
I may also move the code to the actual main(), to fix the complexity CI niggle. It's not really clear to me why we have realMain() ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

That function is used by this and other components to allow them to recover from panics and log the details.

If the max number of golang threads (GOMAXPROCS) is not set in
the environment, then set it ourselves to a small set.
This avoids us taking the default (the number of host cores)
on large-core systems, which can end up with us having a lot of
idle threads generated, consuming host PID space, and thus
artificially restricting how many containers we can run
in parallel.

Fixes: kata-containers#114

Signed-off-by: Graham Whaley <graham.whaley@intel.com>
@jodh-intel
Copy link
Contributor

jodh-intel commented Oct 18, 2018

lgtm

Approved with PullApprove

@jodh-intel
Copy link
Contributor

lgtm

@jodh-intel
Copy link
Contributor

Keep up github! :) Let's make it a hat-trick...

lgtm!

@devimc
Copy link

devimc commented Oct 18, 2018

lgtm

@codecov
Copy link

codecov bot commented Oct 18, 2018

Codecov Report

Merging #115 into master will decrease coverage by 0.9%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   51.25%   50.35%   -0.91%     
==========================================
  Files           7        7              
  Lines         279      284       +5     
==========================================
  Hits          143      143              
- Misses        124      129       +5     
  Partials       12       12

Copy link
Member

@amshinde amshinde left a comment

Choose a reason for hiding this comment

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

lgtm!

@jodh-intel
Copy link
Contributor

Hmm, all the metrics tests failed with the message "Failed to load JSON"... ?

@grahamwhaley
Copy link
Contributor Author

Hmm, oh. I'll go look. I made a change yesterday, but don't think that would have created that error....

@grahamwhaley
Copy link
Contributor Author

/test

@grahamwhaley
Copy link
Contributor Author

initrd CI failed with what looked like a timeout, so I've nudged a rebuild.
Metrics I know is a bit up/down right now, so pls ignore that. And I think the -0.91% codecov drop is probably unavoidable (if you look at the small code changes).

@grahamwhaley
Copy link
Contributor Author

Slow week for PR reviews this week ... nudge nudge nudge....

@sboeuf
Copy link

sboeuf commented Nov 2, 2018

metrics is broken right now, let's merge this anyway.

@sboeuf sboeuf merged commit 7816c4e into kata-containers:master Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants