Use condition variable to wake stats collector.#40481
Merged
AkihiroSuda merged 1 commit intomoby:masterfrom Feb 21, 2020
Merged
Use condition variable to wake stats collector.#40481AkihiroSuda merged 1 commit intomoby:masterfrom
AkihiroSuda merged 1 commit intomoby:masterfrom
Conversation
Before the collection goroutine wakes up every 1 second (as configured). This sleep interval is in case there are no stats to collect we don't end up in a tight loop. Instead use a condition variable to signal that a collection is needed. This prevents us from waking the goroutine needlessly when there is no one looking for stats. For now I've kept the sleep just moved it to the end of the loop, which gives some space between collections. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Member
Author
|
Coupled with #40478, you can get a single stat in ~0.02s-0.03s |
tonistiigi
approved these changes
Feb 20, 2020
Member
|
ping @tiborvass @AkihiroSuda PTAL |
Member
Author
|
Issue this is improving is that the kubelet hits the stats endpoint to collect stats and it takes almost 2s per container. This changes it to just over 1s per container. Plus it's just not great to wake the daemon every second for no reason. |
AkihiroSuda
approved these changes
Feb 21, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before the collection goroutine wakes up every 1 second (as configured).
This sleep interval is in case there are no stats to collect we don't
end up in a tight loop.
Instead use a condition variable to signal that a collection is needed.
This prevents us from waking the goroutine needlessly when there is no
one looking for stats.
For now I've kept the sleep just moved it to the end of the loop, which
gives some space between collections.
This significantly speeds up the first stat collection.
Example,
docker stats --no-streamgoes from about 1.8s+- to 1.03s+-