mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #178] [MERGED] feat(observability): add overlaybd/ext4 usage gauges on restack snapshot #231
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#231
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/178
Author: @huajq
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @yingdi-shan
Base:
main← Head:feat/overlaybd-usage-metrics📝 Commits (1)
70fae06feat(observability): add overlaybd/ext4 usage gauges on restack snapshot📊 Changes
12 files changed (+325 additions, -24 deletions)
View changed files
📝
src/sandbox/firecracker/overlaybd_snapshot.rs(+5 -1)📝
src/sandbox/firecracker/sandbox.rs(+1 -0)📝
src/sandbox/ublk/device.rs(+38 -6)➕
storage/overlaybd/src/ext4_stat.rs(+121 -0)📝
storage/overlaybd/src/image/image_file.rs(+60 -1)📝
storage/overlaybd/src/lib.rs(+1 -0)📝
storage/overlaybd/src/lsmt/file/types.rs(+1 -1)📝
storage/ublk-daemon/src/client.rs(+13 -4)📝
storage/ublk-daemon/src/lib.rs(+3 -1)📝
storage/ublk-daemon/src/protocol.rs(+63 -4)📝
storage/ublk-daemon/src/server.rs(+10 -1)📝
storage/ublk-daemon/tests/ublk_daemon_test.rs(+9 -5)📄 Description
What
Report per-device usage statistics on the restack-snapshot RPC and export them as Prometheus gauges, so overlaybd layer bloat and TRIM headroom become observable without any guest cooperation:
agentenv_overlaybd_data_bytes{dev_id, kind, stat="valid"}— unique bytes mapped by the device's merged index (≈ what a compact/snapshot of this device would carry).agentenv_ext4_used_bytes{dev_id, kind}— guest ext4 used bytes probed from the block view (=df"Used").agentenv_trim_reclaimable_bytes{dev_id, kind}— the difference, i.e. how much a working discard/TRIM path could reclaim.Why
Block-layer mappings in overlaybd grow monotonically because deletions never reach the backend (Firecracker's virtio-block does not advertise discard). Before investing in discard support we need to quantify the potential savings per sandbox, and afterwards verify them. Today there is no node-local way to see either "how much of a layer is actually referenced" or "how much the guest filesystem actually uses". Sampling piggybacks on the existing restack RPC (once per snapshot per device), so there is no new hot-path work and no polling loop.
Related issue
N/A (no tracking issue; root-caused from production incident analysis)
Scope and non-goals
Included:
ImageFile::data_stat()passthrough (merged-index mapped bytes; cheap in-memory index scan reusing the existing LSMTdata_stat).ext4_statmodule: best-effort used-bytes probe from the ext4 superblock free-block counter (same quantity asdf"Used"; ~130 KB of metadata reads; non-ext4 views yield no sample).RestackSnapshotCreatedresponse carries optionaldata_stat/ext4_used_bytes.kind="rootfs"|"drive"labels threaded from the call sites.Excluded:
Design and behavior changes
dev_idlabels (a few hundred devices per node; cardinality is bounded by the device count).Compatibility and operations
#[serde(default)], so new server ↔ old daemon and old server ↔ new daemon both decode fine (rolling-upgrade safe; covered by a protocol test).Validation
make fmt(cargo fmt --all -- --check)make clippy(cargo clippy -p overlaybd -p uvm-ublk-daemon -p agentenv --all-targets -- -D warnings)make test-unitequivalent: see commands belowCommands and results:
Skipped checks and reasons:
make -C services test: noservices/changes.Risks and reviewer notes
ext4_used_bytesis a heuristic (superblock counters, no journal replay); it is meant for observability, not billing-grade accuracy.kindlabel threading throughrestack_snapshot_overlaybd_devicecall sites (rootfs vs attached drives).Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.