-
Notifications
You must be signed in to change notification settings - Fork 905
feat: add filecache prometheus metrics #18089
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
Conversation
ev, err := entry.value.Load() | ||
if err == nil { | ||
c.currentCacheSize.Add(-1 * float64(ev.size)) | ||
} |
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.
This feels really unfortunate, but it is all cached so it's not an expensive call.
coderd/files/cache.go
Outdated
} | ||
|
||
content := bytes.NewBuffer(file.Data) | ||
return archivefs.FromTarReader(content), nil | ||
return archivefs.FromTarReader(content), int64(content.Len()), nil |
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.
hmm. I really dislike trusting honest reporting of size here. is there not some way we could inspect the size of this entire object from inside the cache at runtime? there might not be but it'd be super slick
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.
I don't think there is without doing some recursive Stat()
call on all the files in the filesystem.
Right here is the cheapest place to do it. If we ever add a compression layer, then this won't be 100% accurate, but at present it does indicate the total number of bytes held in memory by the cache entry.
Dynamic parameters has an in memory file cache. This adds prometheus metrics to monitor said cache.
Closes coder/internal#554