Skip to content

feat(ateworker-microvm): add --enable-mem-agent flag - #2674

Open
Maria Fernanda Romano Silva (mariafromano-25) wants to merge 1 commit into
agent-substrate:mainfrom
mariafromano-25:zram-oss-pr
Open

Maria Fernanda Romano Silva (mariafromano-25) wants to merge 1 commit into
agent-substrate:mainfrom
mariafromano-25:zram-oss-pr

Conversation

@mariafromano-25

@mariafromano-25 Maria Fernanda Romano Silva (mariafromano-25) commented Oct 14, 2026 •

Copy link
Copy Markdown

Add kata.WithMemAgent() and the --enable-mem-agent flag on ateworker-microvm to enable PSI (psi=1) and configure the in-guest Kata memory agent (MGLRU aging, page-cache/swap eviction, and memory compaction) when --enable-mem-agent is set.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@ajaysundark

Copy link
Copy Markdown
Contributor

/cc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change Maria Fernanda Romano Silva (@mariafromano-25) ! Can you switch this ready for review?

// WithMemAgent enables the in-guest Kata memory agent (MGLRU aging,
// page-cache/zram eviction, and memory compaction).
func WithMemAgent(kernelParams string) string {
return appendKernelParams(kernelParams, "agent.mem_agent_enable=", "agent.mem_agent_enable=true agent.mem_agent_memcg_swap=true agent.mem_agent_memcg_period_secs=60 agent.mem_agent_memcg_eviction_run_aging_count_min=1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have these as tunables instead of hard coding them?


// BaseKernelParams is the guest kernel command line parameters ateom boots with
const BaseKernelParams = "cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1"
const BaseKernelParams = "cgroup_no_v1=all systemd.unified_cgroup_hierarchy=1 psi=1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's good to enable psi by default. We need to check with substrate maintainers if this acceptable or need this behind enable-memagent flag as well

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can start with a smaller more specific change and evaluate it as default down the line; I moved psi=1 out of BaseKernelParams and into WithMemAgent() for now so it only turns on when --enable-mem-agent is on.

Comment thread benchmarking/workloads/deploy.sh Outdated
# since a bigger guest drags more page cache into every memory snapshot. Raise
# it for RAM-consuming suites.
ACTOR_MEMORY="256Mi"
SWEPERF_ACTOR_MEMORY="4Gi"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it maybe a good idea to split the benchmarking code from mem-agent feature.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout, moved those specific changes to https://github.com/agent-substrate/substrate/pull/2768/changes.

// WithMemAgent enables the in-guest Kata memory agent (MGLRU aging,
// page-cache/zram eviction, and memory compaction).
func WithMemAgent(kernelParams string) string {
return appendKernelParams(kernelParams, "agent.mem_agent_enable=", "agent.mem_agent_enable=true agent.mem_agent_memcg_swap=true agent.mem_agent_memcg_period_secs=60 agent.mem_agent_memcg_eviction_run_aging_count_min=1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this PR itself doesn't handle anything specific to zram contrary to what the description says. That said setting memcg_swap=true is safe even in the absence of one as it falls back to file-only cache reclaim

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I updated the PR title to change the mentioning of zram. Those changes are in my zram-feature branch (commit here)

@ajaysundark

Copy link
Copy Markdown
Contributor

area/memory
area/microVM

cc Walter Fender (@cheftako) Benjamin Elder (@BenTheElder)

chBinary = pflag.String("cloud-hypervisor-binary", "cloud-hypervisor", "Path to the cloud-hypervisor binary (used to relaunch on restore).")
guestDebug = pflag.Bool("guest-debug", false, "enable guest debugging (agent debug logs, debug console, and early serial console)")
enableMemAgent = pflag.Bool("enable-mem-agent", false, "enable the in-guest Kata memory agent (MGLRU aging, page-cache/zram eviction, and compaction)")
vmmMemReserve = pflag.Int("vmm-mem-reserve-mib", vmmMemReserveMiB, "Guest RAM (MiB) held back from the pod's memory limit for the cloud-hypervisor VMM + virtiofsd, which run as host processes in the pod cgroup alongside the guest RAM. Prevents the pod OOMing when the VM is sized to the pod's memory limit.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't expose flags like this to users, these flags are all for substrate itself or debug. I don't think we're at a place where we want to make a ton of these tunable YET, because we're still working on the revamped actor lifecycle where the scheduler becomes aware of sandbox config in a new way.

We don't want to break a workload by scheduling to a worker with incompatible settings and we haven't designed exposing arbitrary settings yet for this reason.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this stage we'd rather make reasonable defaults. The other flags are either development only (the debug flag) or things the control plane always plumbs (pod-uid).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha makes sense. So next course of action do you think is merge PR 2768 which allows actor memory override --> run Prow benchmarks on the zram feature branch here --> verify the results and if acceptable--> then merge this one?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're generally not blocking OSS changes on downstream changes and vice versa, can we temporarily point any downstream CI at e.g. your fork where this is just enabled by default without the flag, instead of shipping a change we're not sure we want users to use?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep in mind GA is ~wednesday and we don't want to expose anything we're not intending to support longterm

@mariafromano-25 Maria Fernanda Romano Silva (mariafromano-25) changed the title feat(ateom-microvm): add zram guest assets and --enable-mem-agent sup… feat(ateom-microvm): add --enable-mem-agent flag and sweperf actorMemory support Oct 15, 2026
@mariafromano-25
Maria Fernanda Romano Silva (mariafromano-25) marked this pull request as ready for review October 15, 2026 15:55
Add kata.WithMemAgent() and the --enable-mem-agent flag on ateworker-microvm
to enable PSI (psi=1) and configure the in-guest Kata memory agent
(MGLRU aging, page-cache/swap eviction, and memory compaction) when set.
@mariafromano-25 Maria Fernanda Romano Silva (mariafromano-25) changed the title feat(ateom-microvm): add --enable-mem-agent flag and sweperf actorMemory support feat(ateworker-microvm): add --enable-mem-agent flag Oct 16, 2026
@bowei Bowei Du (bowei) added area/microVM kind/feature An enhancement / feature request or implementation labels Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/microVM kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants