Repository navigation
Add zswap metrics: pool percent and writeback pages - #1383
mariafromano-25 wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mariafromano-25 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/cc @ajaysundark |
4e5a0a9 to
5e91a63
Compare
|
/test all |
5e91a63 to
8466be9
Compare
hakman
left a comment
There was a problem hiding this comment.
Thanks for the PR @mariafromano-25. It mostly looks fine, but needs a few small things fixed before merging.
| mc.collect() | ||
| } | ||
|
|
||
| func TestCalculateZswapPoolPercent(t *testing.T) { |
There was a problem hiding this comment.
This file has no build tag, but these three tests call helpers that only exist in memory_collector_unix.go, so GOOS=windows go vet ./pkg/systemstatsmonitor/ fails with undefined: calculateZswapPoolPercent. CI doesn't catch it because we only test on Linux. Please move them to a memory_collector_unix_test.go with //go:build unix.
| if delta < 0 { | ||
| delta = current | ||
| } |
There was a problem hiding this comment.
readZswapWritebackPages returns 0 on any read or parse failure, and this treats that 0 as a counter reset. The next good read then adds the whole since-boot value again (100 → 0 → 105 exports 205). The same happens if a read falls back from vmstat to a slightly lower debugfs value.
The kernel counter can't go backwards while the node is up, so I'd drop the reset handling and keep the last value:
| if delta < 0 { | |
| delta = current | |
| } | |
| if delta < 0 { | |
| return 0 | |
| } |
The comment above and the last assertion in TestZswapWritebackPagesDelta need updating to match.
| MemoryZswapPoolPercentID MetricID = "memory/zswap_pool_percent" | ||
| MemoryZswapWritebackPagesID MetricID = "memory/zswap_writeback_pages" |
There was a problem hiding this comment.
These two aren't in NPDMetricToSDMetric. With the default empty customMetricPrefix the type formatter returns "", and the GCP exporter sends that as-is, so I'd expect every export from the metric-only service to carry two time series that CreateTimeSeries rejects.
Do guest/memory/zswap/pool_percent and guest/memory/zswap/writeback_pages descriptors exist? If so, please add the mappings and the TestNPDMetricToSDMetric rows. If not, either leave the metrics out of the default config for now, or filter empty-type metrics in the Stackdriver exporter.
| } | ||
| data, err := os.ReadFile(maxPoolPctPath) | ||
| if err != nil { | ||
| return 0 |
There was a problem hiding this comment.
nit: an unreadable max_pool_percent is reported as 0%, which looks the same as an empty pool. Worth a log line at least.
| return 0 | ||
| } | ||
| maxPoolKB := float64(*meminfo.MemTotal) * (maxPoolPct / 100.0) | ||
| if maxPoolKB <= 0 { |
There was a problem hiding this comment.
nit: this can't be true, MemTotal and maxPoolPct are both checked positive above.
Add zswap pool percent and writeback pages metrics to system-stats-monitor
Followup work from: #1337 (already merged)