mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #281] Document DAMON reclaim trade-offs with memory density, and runtime #77
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#77
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?
Originally created by @yingdi-shan on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/281
Problem statement
AgentENV can reclaim file-backed pages aggressively with DAMON, but the settings affect both memory density and task runtime. Users need to know which workloads benefit, how much memory is saved, and when reclaim causes page refaults or write throttling.
Profiles being compared
Previous AgentENV profile:
Tuned profile:
The tuned profile considers pages cold after 100 ms, checks watermarks every second, and spends at most 20 ms reclaiming in each 500 ms quota period. DAMON parameter units and watermark behavior are defined by the kernel DAMON reclaim documentation.
Physical memory range used by DAMON
The range tuning used
damon_reclaim.monitor_region_startanddamon_reclaim.monitor_region_end, in guest physical-address bytes. The previous profile left both inputs at0(automatic selection). Linux 6.1 then selects the largest individualSystem RAMresource, which can leave other RAM ranges outside DAMON's coverage. See the kernel parameter documentation.monitor_region_start= minimum start address of allSystem RAMentries.monitor_region_end= maximum end address of allSystem RAMentries plus one, because/proc/iomemprints inclusive ends.The saved 4 GiB tuning runs recorded:
monitor_region_start1048576(1 MiB)4096(4 KiB)monitor_region_end3221225471(3 GiB − 1 byte)5368709120(5 GiB)For that guest layout, the explicit settings were:
The 4 GiB guest had RAM below 3 GiB and another 1 GiB at physical addresses 4–5 GiB, separated by the 3–4 GiB address hole. Automatic selection missed the upper 1 GiB; expanding the span made it eligible for DAMON monitoring/reclaim. Increasing quota or lowering
min_agealone cannot reclaim pages outside the monitored range. This fixes coverage; the measurements do not isolate the memory savings from this change alone.Workloads and measurement
Each workload is the checked-in solution command for a Terminal-Bench 2.1 task. The commands run in a fresh Linux guest with the task's input files and dependencies:
train-fasttextpath-tracingraman-fittinglargest-eigenvalcount-dataset-tokensbuild-cython-extdna-insertwrite-compressorregex-logopenssl-selfsigned-certRuntime is wall-clock time for the task command. Occupied memory is the time-weighted
MemTotal - MemFree; page cache is reported separately asCached. Every task was run once with each profile under the same guest size and task image.Results
train-fasttextpath-tracingraman-fittinglargest-eigenvalcount-dataset-tokensbuild-cython-extdna-insertwrite-compressorregex-logopenssl-selfsigned-certTuned reclaim reduced occupied memory and cache for the longer workloads. Runtime changes ranged from a 4.7% improvement to a 6.9% increase across the six longer tasks. Short tasks complete before reclaim can make a meaningful difference; their measurements are included for completeness but are dominated by startup and sampling resolution.
Dirty-page flushing interaction
A separate high-density experiment also used:
These values reduced average
Dirtymemory during Parquet processing from about 77 MiB to about 5 MiB. They also reduced post-task cache, but dirty thresholds are global VM controls. In file-copy and archive stress tests, combining aggressive reclaim with these thresholds reduced cache while increasing runtime by roughly 2.1–2.5×.Dirty-page flushing should therefore remain a separate opt-in profile until write-heavy workloads have been measured.
C6 and page-fault latency follow-up
The table above was run with host CPU C6 disabled for the duration of the measurements.
To isolate the source of the runtime gap, we warmed the host and OverlayBD cache, dropped only the guest page cache, and touched 1,536 individual 4 KiB pages from a NumPy shared library. Every cold access was a genuine major fault; no physical host-disk read was required.
A kernel trace measured roughly 10 us in the host file-cache read itself and about 115 us in the OverlayBD I/O worker operation. Most of the remaining latency came from waking and rescheduling Firecracker, ublk, and io_uring workers while CPUs entered the deep C6 idle state. This is why a host-cache hit can still approach 1 ms, while disabling C6 brings it close to the 100 us range.