Skip to content
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

Added summary for entries' size #780

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cache/disk/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type SizedLRU struct {
gaugeCacheLogicalBytes prometheus.Gauge
counterEvictedBytes prometheus.Counter
counterOverwrittenBytes prometheus.Counter
summaryCacheItemBytes prometheus.Summary
}

type entry struct {
Expand Down Expand Up @@ -83,6 +84,16 @@ func NewSizedLRU(maxSize int64, onEvict EvictCallback, initialCapacity int) Size
Name: "bazel_remote_disk_cache_overwritten_bytes_total",
Help: "The total number of bytes removed from disk backend, due to put of already existing key",
}),
summaryCacheItemBytes: prometheus.NewSummary(prometheus.SummaryOpts{
Name: "bazel_remote_disk_cache_entry_bytes",
Help: "Size of cache entries",
Objectives: map[float64]float64{
0.5: 0.05,
0.9: 0.01,
0.99: 0.001,
1: 0,
},
}),
}
}

Expand All @@ -91,6 +102,7 @@ func (c *SizedLRU) RegisterMetrics() {
prometheus.MustRegister(c.gaugeCacheLogicalBytes)
prometheus.MustRegister(c.counterEvictedBytes)
prometheus.MustRegister(c.counterOverwrittenBytes)
prometheus.MustRegister(c.summaryCacheItemBytes)
}

// Add adds a (key, value) to the cache, evicting items as necessary.
Expand Down Expand Up @@ -149,6 +161,7 @@ func (c *SizedLRU) Add(key Key, value lruItem) (ok bool) {

c.gaugeCacheSizeBytes.Set(float64(c.currentSize))
c.gaugeCacheLogicalBytes.Set(float64(c.uncompressedSize))
c.summaryCacheItemBytes.Observe(float64(sizeDelta))

return true
}
Expand Down
Loading