Skip to content

runtime: add memprofile attribution support#1905

Draft
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-heapsampling-coverage
Draft

runtime: add memprofile attribution support#1905
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-heapsampling-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary:

  • add a lightweight LLGo runtime memprofile snapshot with synthetic frames for runtime.MemProfile
  • preserve heap attribution frames by disabling inline/tail-call elimination for packages using runtime.MemProfile/MemProfileRate
  • add stable test/go coverage and un-xfail GOROOT heapsampling.go

Tests:

  • go test ./test/go -run TestRuntimeMemProfileAttribution -count=1
  • go test ./test/goroot -run TestGoRootRunCases -count=1 -args -goroot /opt/homebrew/Cellar/go@1.24/1.24.11/libexec -dirs . -case '^heapsampling.go$' -directive-mode runlike
  • go test ./cl ./ssa
  • cd runtime && go test ./internal/lib/runtime ./internal/runtime
  • git diff --cached --check

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

Verification update for commit 622e1e5:\n\n- Root cause: Linux CI could not reliably recover LLGo Go function names from libunwind for memory profile stack attribution; the profile saw frames like n / __libc_start_main, so TestRuntimeMemProfileAttribution could not find main.profiledAlloc.\n- Fix: for packages that use runtime.MemProfile, the compiler now emits lightweight MemProfileEnter/Exit calls and the runtime uses that Go call stack before falling back to libunwind.\n- Local tests:\n - go test ./test/go -run TestRuntimeMemProfileAttribution -count=1 -v\n - go test ./test/go -count=1\n - go test ./ssa -count=1\n - go test ./cl -count=1\n\nPushed only to cpunion/llgo:codex/goroot-heapsampling-coverage. Monitoring the new CI run now.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

CI update for 622e1e5a0e3eeccd097599b6f4a6abb8639740f9:

  • Previously failing test/go memprofile attribution failure is fixed by keeping a lightweight Go call stack for runtime.MemProfile test packages.
  • Local verification passed:
    • go test ./test/go -run TestRuntimeMemProfileAttribution -count=1 -v
    • go test ./test/go -count=1
    • go test ./ssa -count=1
    • go test ./cl -count=1
  • New CI: the three previously failing jobs now pass:
    • test (ubuntu-latest, 19)
    • test (ubuntu-latest, 19, 1.24.2, 2)
    • test (ubuntu-latest, 19, 1.26.0, 2)

At the time of this update, the remaining visible checks are queued macOS jobs; no new failure is showing on the PR.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.66667% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/compile.go 86.53% 4 Missing and 3 partials ⚠️
ssa/memory.go 0.00% 4 Missing ⚠️
ssa/decl.go 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

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