-
Notifications
You must be signed in to change notification settings - Fork 712
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
Conversation
488f6c6
to
45ab210
Compare
c7a60b6
to
1e79273
Compare
@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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
78c8fde
to
93d75c1
Compare
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I still think @paulbellamy should take a look for overall cohesion, but I like this approach. |
93d75c1
to
016d9d4
Compare
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Use a reader in the background, dynamically rate-limited, reading the required files in a loop
016d9d4
to
3dd2d45
Compare
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Overall, it's a substantial improvement. I wonder if it could be improved with contexts? |
5939ac3
to
df4f72b
Compare
@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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
df4f72b
to
53bc710
Compare
98423d3
to
0545d9a
Compare
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.
This comment was marked as abuse.
Sorry, something went wrong.
// when to start next walk | ||
restInterval = targetWalkTime - took | ||
|
||
return |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
We could do another iteration over the |
@peterbourgon Please go ahead and comment. I would like to avoid refactoring other parts of the code not directly related to this change though. |
Rate-limit reading proc files
I should had rebased, oh well. |
Second attempt at #814 after seeing #812 (comment)
Improves #812