mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #244] [MERGED] fix(overlaybd): restore premerged index prune offload lost in a rebase #283
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#283
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/244
Author: @YXalix
Created: 9/3/2026
Status: ✅ Merged
Merged: 9/3/2026
Merged by: @yingdi-shan
Base:
main← Head:fix/restore-premerged-prune-offload📝 Commits (1)
a90934dfix(overlaybd): restore premerged index prune offload lost in a rebase📊 Changes
2 files changed (+224 additions, -24 deletions)
View changed files
📝
storage/overlaybd/src/lsmt/file/helper.rs(+164 -24)📝
storage/overlaybd/src/lsmt/file/tests.rs(+60 -0)📄 Description
Problem
uvm-ublk-daemonRSS keeps climbing (observed close to 1 TiB) once the premerged-index cache directory accumulates hundreds of thousands of artifacts, and it stays high long after every sandbox has exited. The directory itself is only ~4 GiB.Root cause: the prune offload from #179 was silently reverted by #123. The auth branch in #123 was authored before #179 merged; when it was rebased onto main before merging, the rebase conflict in
storage/overlaybd/src/lsmt/file/helper.rswas resolved with the branch's stale copy. The revert is visible in #123's own diff ashelper.rs +24/-156andtests.rs -54— an exact mirror of #179 — hidden inside a 24-file auth PR. Currentmaintherefore runs the pre-#179 code.Why the old code leaks memory
The per-key lock only deduplicates writes for the same cache key. Every pause seals a new upper layer (new UUID), so every layer stack gets a new key — hundreds of thousands of artifacts means hundreds of thousands of distinct keys, each spawning its own detached write task with no global bound:
Arc<ReadOnlyIndex>(~24 B/mapping; page-granular memory-snapshot stacks can reach hundreds of MB) and pins it until the task actually finishes.tokio::fs: one blocking-pool round-trip per directory entry. With N tasks and N entries that is O(N²) blocking work, which the 512-thread blocking pool can never drain.max_dir_bytescap (≤1 GiB configured, 4 GiB observed) confirms prune was no longer keeping up.Fix
Restore the #179 implementation on top of current main (conflict-free reverse-apply of the #123 hunks for the two
lsmt/filefiles):spawn_blockinginstead of one async round-trip per entry.max_dir_bytesof new writes, at most one scan per directory at a time; growth charged during a scan chains a follow-up scan.Later changes to the same file from #
3522df8/ #e97064f(sys-module refactor, unaligned-extent rejection) are preserved — the restore only touches the premerged sections.Verification
cargo test -p overlaybd premerged— 8 passed, including the restored prune-accounting tests from #179.cargo fmt -p overlaybd -- --checkandcargo clippy -p overlaybd --all-targetsclean.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.