Skip to content

feat: add memory usage benchmark implementation - #7

Merged
cmainas merged 1 commit into
urunc-dev:mainfrom
jim-junior:ft-mem-bench
Aug 14, 2026
Merged

feat: add memory usage benchmark implementation #7
cmainas merged 1 commit into
urunc-dev:mainfrom
jim-junior:ft-mem-bench

Conversation

@jim-junior

Copy link
Copy Markdown
Collaborator

This PR adds Memory benchmarking implementations

It measures the Sandbox footprint and also collects the USS, PSS and RSS memeory sets for the shim process associated with a container. The default image used currently in the experiment.yml is the nginx image.

How it works

The implementation is basically a Go script derived from this sequence of shell command steps.

Cgroups Metrics (Sandbox foot print)

  1. First it pulls the image with nerdctl, then creates and runs the container.
  2. Next it gets the container PID
    PID=$(sudo nerdctl inspect --format '{{.State.Pid}}' $CONTAINER)
  3. Then it locates the cgroup
    CGROUP_REL=$(awk -F: '$1 == "0" {print $3}' /proc/$PID/cgroup)
    CGROUP="/sys/fs/cgroup${CGROUP_REL}"
  4. Then it collects the cgroups metrics
    sudo cat "$CGROUP/memory.current"
    sudo cat "$CGROUP/memory.stat"
    sudo cat "$CGROUP/memory.peak"
  5. Then pparses them and exports them as JSON

Shim process Memory Usage

  1. Gets the container PID (this happens when the image is pullled and container is running)
    CID=$(sudo nerdctl inspect --format '{{.Id}}' $CONTAINER)
  2. Then get the shim PID associated with that container ID:
    SHIM_PID=$(sudo pgrep -af containerd-shim-runc-v2 | awk -v id="$CID" '$0 ~ id {print $1; exit}')
  3. then get the uss, pss, rss
    sudo cat /proc/$SHIM_PID/smaps_rollup
  4. Lastly parses the smaps_rollup file contents into a Go string map, and then collects the USS, PSS AND RSS

@cmainas

cmainas commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Hello @jim-junior ,

the merging of the CPU PR has created some conflicts with this PR.

…tion

Signed-off-by: jim-junior <jimjunior854@gmail.com>

@cmainas cmainas left a comment

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.

Thank you @jim-junior .

@cmainas
cmainas merged commit ecb852a into urunc-dev:main Aug 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants