Skip to content

feat: log cgroup v2 memory usage alongside token count#210

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/update-memory-cgroup-path
Draft

feat: log cgroup v2 memory usage alongside token count#210
Copilot wants to merge 2 commits intomainfrom
copilot/update-memory-cgroup-path

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

When running in containerised environments (GitHub Actions, Docker, Kubernetes), /sys/fs/cgroup/memory.current reports the process's actual memory consumption. The tool already logs estimated token counts to stderr; this extends that observability to include memory bytes.

Changes

  • pkg/codingcontext/memoryusage — new package with:
    • ReadCurrent() — reads bytes from the cgroup v2 default path
    • ReadCurrentFromPath(path) — path-injectable variant for testability
  • context.go — logs "Current memory usage" after the token count log; silently no-ops when the file is absent (non-Linux, no cgroup v2, bare metal)
time=... level=INFO msg="Total estimated tokens" tokens=4821
time=... level=INFO msg="Current memory usage" bytes=138412032

On systems without the file the second line simply doesn't appear — no error, no behaviour change.

Copilot AI changed the title [WIP] Update cgroup path for memory metrics feat: log cgroup v2 memory usage alongside token count Mar 30, 2026
Copilot AI requested a review from alexec March 30, 2026 20:40
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