-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Limit parallelism during garbage collection #2427
Conversation
This PR introduces a parallelism limit during garbage collection. This is used to avoid large resource usage spikes if garbage collecting many allocations at once.
client/gc.go
Outdated
func (a *AllocGarbageCollector) Stop() { | ||
close(a.shutdownCh) | ||
close(a.destroyCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe to call concurrently with destroyAllocRunner above? I forget whether or not a race could cause a send on a closed chan on line 130 above.
client/gc.go
Outdated
|
||
select { | ||
case <-a.destroyCh: | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default
case shouldn't be necessary and could make bugs harder to find.
|
||
a.destroyAllocRunner(ar) | ||
return nil | ||
} | ||
|
||
// CollectAll garbage collects all termianated allocations on a node | ||
func (a *AllocGarbageCollector) CollectAll() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[OT] Huh, this method actually never returns an error because all destroying is done async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of my comments are blockers as long as you're confident closing a chan can safely happen concurrently with sending to it in a select.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
This PR introduces a parallelism limit during garbage collection. This
is used to avoid large resource usage spikes if garbage collecting many
allocations at once.