Repository navigation
Only persist the state when a last-used timestamp changes meaningfully - #428
Merged
Merged
Conversation
Docuum rewrote its state file for every event, which accounted for most of its remaining CPU usage under healthcheck load once image IDs were cached (#426). Last-used timestamps are now left alone until they're at least a minute old, and the state is only persisted when something changed. This bounds writes to roughly one per image per minute, at the cost of timestamps being up to a minute stale, which doesn't matter for LRU eviction in practice. A timestamp in the future (e.g., due to the clock moving backward) is always replaced so it can't get stuck.
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.
Following #427, Docuum still rewrote its state file for every event. Under healthcheck load, that save accounted for about 87% of Docuum's remaining CPU usage.
This PR leaves an image's last-used timestamp alone until it's at least a minute old (
LAST_USED_GRANULARITY), and only persists the state when something actually changed.touch_imagenow returns aTouch(New,Updated, orUnchanged) instead of a boolean: new images still trigger a vacuum, and unchanged ones skip the save. This bounds writes to roughly one per image per minute. Timestamps can be up to a minute stale, which doesn't matter in practice for LRU eviction, and images in use by containers (which is all that healthchecks touch) can't be deleted anyway. A timestamp in the future (e.g., due to the clock moving backward) is always replaced so it can't get stuck.It also bumps the version to 0.27.3.
Benchmark: 10 containers with a 1s healthcheck (~29 container events/s) and 223 images in the state, measuring Docuum's CPU time (including child processes) over 60 seconds minus startup:
That's about the same as a build of #427 with the per-event save removed entirely (0.006 cores).
Status: Ready
Fixes: #426