mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #256] [MERGED] feat(snapshot): compress layers at publish time when uploading to OSS/ACR #297
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#297
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/256
Author: @huajq
Created: 9/7/2026
Status: ✅ Merged
Merged: 9/8/2026
Merged by: @yingdi-shan
Base:
main← Head:feat/snapshot-publish-compression📝 Commits (1)
d03b5a6feat(snapshot): compress layers at publish time when uploading to OSS/ACR📊 Changes
25 files changed (+1316 additions, -482 deletions)
View changed files
📝
config/default.toml(+14 -24)📝
crates/e2e-tests/tests/snapshot_oss_e2e_test.rs(+243 -15)📝
docs/src/configuration/reference.md(+22 -16)📝
docs/src/internals/p2p-design.md(+2 -0)📝
src/cfg.rs(+19 -25)📝
src/image/local_layer.rs(+4 -2)📝
src/sandbox/firecracker/overlaybd_snapshot.rs(+8 -124)📝
src/sandbox/firecracker/sandbox.rs(+4 -28)📝
src/sandbox/mod.rs(+1 -1)📝
src/sandbox/ublk/overlaybd.rs(+26 -41)📝
src/snapshot/image_export/service.rs(+2 -0)📝
src/snapshot/manager.rs(+25 -2)📝
src/snapshot/p2p.rs(+106 -12)📝
src/snapshot/repository/backends/common/acr/client.rs(+1 -1)📝
src/snapshot/repository/backends/common/acr/publisher.rs(+316 -25)📝
src/snapshot/repository/backends/common/mod.rs(+1 -0)➕
src/snapshot/repository/backends/common/recontainerize.rs(+379 -0)📝
src/snapshot/repository/backends/mod.rs(+1 -0)📝
src/snapshot/repository/backends/oss/mod.rs(+22 -2)📝
src/snapshot/repository/backends/oss/repository.rs(+97 -33)...and 5 more files
📄 Description
What
Redesign snapshot layer compression: local layers always stay raw, and compression happens once when layers are uploaded to OSS/ACR. A single new switch,
[snapshot.publish_compression](enabled/algorithm(lz4|zstd) /workers, on by default), replaces the legacy capture-time knobs —[memory_snapshot].compression_*and[template_build]are removed from the configuration schema.Why
Benchmarks show capture-time compression is a local pessimization: the guest working set is unchanged by compression (~62 MiB in the test setup), and while layer files are page-cache-warm the saved bytes never materialize — yet decompression CPU is paid on every fault (cold resume: raw 63.8 ms vs lz4 +18% vs zstd +106%; hot path identical at ~15 ms). The bytes compression actually saves only matter on the network path: OSS/ACR upload and cross-node resume.
Related issue
Closes # (no tracking issue; motivation is the measurement analysis above)
Scope and non-goals
Repositorytrait changes; POSIX backend unchanged (local stays raw); zero read-path changes (ZFile is already transparent via switch-file magic detection); full P2P alignment for compressed digests (left as a TODO).Design and behavior changes
close_sealunchanged).prepare_layer_upload(common/recontainerize.rs) probesis_zfile, recontainerizes raw local layers withcompact_layersinto a temporary ZFile, then hashes and uploads the compressed bytes.ManagedLayer.digest/size, OSS object keys, and ACR blob annotations all reference the actually-uploaded bytes. Remote lowers are re-referenced untouched; already-ZFile inputs are passed through (idempotent).delete_prefix); no partial uploads; temp files are cleaned up by guard.uuid = None, so P2P uuid-keyed acceleration does not apply to them (the daemon virtual-size probe falls back to a fullImageFileopen, one-time).Compatibility and operations
[snapshot.publish_compression]section (enabled by default,lz4) — OSS/ACR uploads start compressing on upgrade; setenabled = falseto keep raw uploads. Legacy keys removed from the schema; unknown TOML keys are ignored by the config parser, so stale configs keep starting.Validation
make fmt(cargo fmt --all -- --check)make clippy(cargo clippy -p agentenv -p agentenv-e2e-tests --all-targets -- -D warnings)make test-unit(cargo test -p agentenv --lib: 817/818; the single failure is a pre-existing flakyapi::proxytest that passes in isolation, unrelated)fc::memory_snapshot_format_matches_config_and_resumes,fc::backend_pause_state_round_trips_through_encoded_artifacts)reference.md,default.toml,p2p-design.md)Commands and results:
Performance comparison (real OSS, release build; template-build scenario, memory layer 87.8 → 31.9 MiB, 2.75×):
Evidence for removing capture-time compression: cold resume raw 63.8 ms vs lz4 75.1 ms (+18%) vs zstd 131.4 ms (+106%); hot path identical at ~15 ms; guest working set (~62 MiB) is codec-independent.
Skipped checks and reasons:
make -C services test(services/untouched); no generated-code changes.Risks and reviewer notes
recontainerize.rsand the minio e2e. Please focus review oncommon/recontainerize.rs(new), the three upload branches inoss/repository.rs, andacr/publisher.rs::upload_local_delta.p2p.rsabout propagating compressed paths to restore acceleration).uuid = None: P2P uuid-keyed acceleration is unavailable for them (pre-existing graceful degradation, not a regression).Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.