mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #132] [CLOSED] feat: add opt-in dirty-page tracking for memory snapshots #200
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#200
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/132
Author: @Hygge-Gezelligheid
Created: 8/6/2026
Status: ❌ Closed
Base:
main← Head:codex/issue-119-dirty-page-tracking📝 Commits (1)
d165adafeat: add opt-in dirty-page tracking📊 Changes
8 files changed (+196 additions, -9 deletions)
View changed files
📝
config/default.toml(+6 -0)📝
config/oss_default.toml(+6 -0)📝
docs/src/configuration/reference.md(+1 -0)📝
docs/src/deployment/pvm.md(+2 -0)📝
src/cfg.rs(+78 -3)📝
src/sandbox/firecracker/config.rs(+16 -0)📝
src/sandbox/firecracker/instance.rs(+69 -0)📝
src/sandbox/firecracker/sandbox.rs(+18 -6)📄 Description
What
Add an opt-in
memory_snapshot.track_dirty_pagesconfiguration that enables Firecracker dirty-page tracking for direct memory snapshot capture.FirecrackerCommonConfigso the capture behavior follows the sandbox that was launched with it.direct_overlaybd=truewhen dirty-page tracking is enabled.Why
The current mincore-based capture path selects resident pages, including pages that were only read. For workloads with a large read-only resident set, this can copy substantially more memory than the guest actually modified.
Firecracker dirty-page tracking selects pages written after tracking begins. This provides the opt-in behavior requested by #119 while preserving the current behavior by default. The dirty bitmap is cumulative across captures, so a later snapshot can restore pages written both before and after an earlier capture.
Related issue
Closes #119
Related to #120, but this PR does not implement per-snapshot dirty epochs.
Scope and non-goals
Included:
memory_snapshot.track_dirty_pagesboolean, defaulting tofalse.AGENTENV_MEMORY_SNAPSHOT_TRACK_DIRTY_PAGESenvironment-variable support.Non-goals / intentionally excluded:
mem.bincapture path.Design and behavior changes
MemorySnapshotConfig::track_dirty_pagesis mapped intoFirecrackerCommonConfigand persisted with the sandbox. Fresh VM setup and snapshot restore both forward the persisted value to their corresponding Firecracker requests.The direct capture decision uses either the current global
direct_overlaybdsetting or the persisted dirty-tracking setting. This prevents a sandbox launched with dirty tracking from falling back to the legacy capture path after a server restart or configuration change.Configuration validation fails early for unsupported combinations:
track_dirty_pages=truewithdirect_overlaybd=falseis rejected because the legacy path cannot provide the required cumulative dirty-page behavior.track_dirty_pages=truein PVM mode is rejected with an explicit untested-combination error.Existing configurations continue to use mincore behavior because the new setting defaults to
false.Compatibility and operations
false, so existing deployments retain current behavior. Enabling it requires KVM anddirect_overlaybd=true.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
Focused Firecracker socket tests assert that dirty tracking is enabled in both the fresh
/machine-configrequest and the restore/snapshot/loadrequest.A 512 MiB anonymous guest-memory probe verified:
Selected-byte comparison (selection/correctness diagnostic, not an end-to-end speedup claim):
The read-only probe selected 97.8% fewer bytes with dirty tracking. In full-page-write ABBA runs, both modes selected about 619 MB, as expected. Sequential snapshot medians were 515.236 ms (mincore) and 517.641 ms (dirty), which did not show a clear regression. Random-write results were underpowered after excluding runs with swap I/O, so this PR does not claim a general performance improvement.
Skipped checks and reasons:
make test-unit: not run; the focusedagentenvlibrary suite above was run instead.make -C services test: noservices/changes.Risks and reviewer notes
mem.binpath is intentionally rejected when dirty tracking is enabled.src/cfg.rs, persisted setting and Firecracker request propagation insrc/sandbox/firecracker/{config,instance}.rs, and capture-path selection insrc/sandbox/firecracker/sandbox.rs.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.