Skip to content

Commit

Permalink
Merge pull request #1002 from timstclair/loaddecay
Browse files Browse the repository at this point in the history
Fix usage of housekeeping_interval flag
  • Loading branch information
jimmidyson committed Dec 4, 2015
2 parents 3b10b41 + 3321687 commit 1d6e0ec
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions manager/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ var HousekeepingInterval = flag.Duration("housekeeping_interval", 1*time.Second,

var cgroupPathRegExp = regexp.MustCompile(`.*devices.*:(.*?)[,;$].*`)

// Decay value used for load average smoothing. Interval length of 10 seconds is used.
var loadDecay = math.Exp(float64(-1 * (*HousekeepingInterval).Seconds() / 10))

type containerInfo struct {
info.ContainerReference
Subcontainers []info.ContainerReference
Expand All @@ -68,6 +65,9 @@ type containerData struct {
lastUpdatedTime time.Time
lastErrorTime time.Time

// Decay value used for load average smoothing. Interval length of 10 seconds is used.
loadDecay float64

// Whether to log the usage of this container when it is updated.
logUsage bool

Expand Down Expand Up @@ -317,6 +317,8 @@ func newContainerData(containerName string, memoryCache *memory.InMemoryCache, h
}
cont.info.ContainerReference = ref

cont.loadDecay = math.Exp(float64(-cont.housekeepingInterval.Seconds() / 10))

err = cont.updateSpec()
if err != nil {
return nil, err
Expand Down Expand Up @@ -464,7 +466,7 @@ func (c *containerData) updateLoad(newLoad uint64) {
if c.loadAvg < 0 {
c.loadAvg = float64(newLoad) // initialize to the first seen sample for faster stabilization.
} else {
c.loadAvg = c.loadAvg*loadDecay + float64(newLoad)*(1.0-loadDecay)
c.loadAvg = c.loadAvg*c.loadDecay + float64(newLoad)*(1.0-c.loadDecay)
}
}

Expand Down

0 comments on commit 1d6e0ec

Please sign in to comment.