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

Rate-limit reading proc files #912

Merged
merged 17 commits into from
Feb 9, 2016
Merged

Rate-limit reading proc files #912

merged 17 commits into from
Feb 9, 2016

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Feb 4, 2016

Second attempt at #814 after seeing #812 (comment)
Improves #812

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch 2 times, most recently from 488f6c6 to 45ab210 Compare February 4, 2016 12:49
@2opremio 2opremio mentioned this pull request Feb 4, 2016
@2opremio 2opremio force-pushed the 812-rate-limit-proc branch 2 times, most recently from c7a60b6 to 1e79273 Compare February 8, 2016 12:27
@2opremio 2opremio changed the title [WIP] Rate-limit reading proc files Rate-limit reading proc files Feb 8, 2016
@2opremio
Copy link
Contributor Author

2opremio commented Feb 8, 2016

@peterbourgon Can you PTAL? I will rebase before merging.

if !br.running {
return fmt.Errorf("background reader already not running")
}
br.pleaseStop = true

This comment was marked as abuse.

This comment was marked as abuse.

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from 78c8fde to 93d75c1 Compare February 8, 2016 12:57
defer br.mtx.Unlock()

reader := bytes.NewReader(br.readyBuf.Bytes())
buf.ReadFrom(reader)

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@peterbourgon
Copy link
Contributor

I still think @paulbellamy should take a look for overall cohesion, but I like this approach.

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from 93d75c1 to 016d9d4 Compare February 8, 2016 13:17
br.mtx.Lock()
defer br.mtx.Unlock()
if !br.running {
return fmt.Errorf("background reader already not running")

This comment was marked as abuse.

This comment was marked as abuse.

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from 016d9d4 to 3dd2d45 Compare February 8, 2016 13:43
@2opremio
Copy link
Contributor Author

2opremio commented Feb 8, 2016

Rebased to get client test fixes.


// Adjust rate limit to more-accurately meet the target walk time in next iteration
scaledRateLimitPeriod := targetWalkTimeF / walkTimeF * float64(rateLimitPeriod)
rateLimitPeriod = time.Duration(math.Min(scaledRateLimitPeriod, maxRateLimitPeriodF))

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@paulbellamy
Copy link
Contributor

Overall, it's a substantial improvement. I wonder if it could be improved with contexts?

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from 5939ac3 to df4f72b Compare February 8, 2016 18:12
@2opremio
Copy link
Contributor Author

2opremio commented Feb 8, 2016

@peterbourgon @paulbellamy please take a thorough look, I am still a bit of a newbie with Golang channels.

dirName := strconv.Itoa(p.PID)
fdBase := filepath.Join(procRoot, dirName, "fd")

if fdBlockCount > w.fdBlockSize {
// we surpassed the filedescriptor rate limit
// TODO: worth selecting on w.stopc?

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from df4f72b to 53bc710 Compare February 8, 2016 19:29
@2opremio 2opremio force-pushed the 812-rate-limit-proc branch from 98423d3 to 0545d9a Compare February 8, 2016 21:04
begin time.Time // when we started the last performWalk
tickc = time.After(time.Millisecond) // fire immediately
walkc chan map[uint64]*Proc // initially nil, i.e. off
walkBuf = bytes.NewBuffer(make([]byte, 0, 5000))

This comment was marked as abuse.

// when to start next walk
restInterval = targetWalkTime - took

return

This comment was marked as abuse.

@peterbourgon
Copy link
Contributor

We could do another iteration over the loop body and clean it up a good bit, but I won't frustrate you any more :) LGTM after those changes.

@2opremio
Copy link
Contributor Author

2opremio commented Feb 9, 2016

@peterbourgon Please go ahead and comment. I would like to avoid refactoring other parts of the code not directly related to this change though.

2opremio pushed a commit that referenced this pull request Feb 9, 2016
@2opremio 2opremio merged commit 26ccb49 into master Feb 9, 2016
@2opremio 2opremio deleted the 812-rate-limit-proc branch February 9, 2016 11:20
@2opremio
Copy link
Contributor Author

2opremio commented Feb 9, 2016

I should had rebased, oh well.

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.

3 participants