Skip to content

fix(malloc): harden pprof output for Pyroscope malloc profiles - #24197

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/malloc-pyroscope-pr
Apr 27, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:violet/malloc-pyroscope-pr

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Apr 24, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24222

What this PR does / why we need it:

This PR hardens MatrixOne's custom /debug/malloc pprof output for Pyroscope ingestion.

Changes:

  • rename malloc profile sample types to Go heap-style names:
    • alloc_objects
    • alloc_space
    • inuse_objects
    • inuse_space
  • populate pprof metadata in Profiler.Write:
    • PeriodType
    • Period
    • TimeNanos
    • Mapping.HasFunctions
  • explicitly bind every emitted profile.Location to the default profile.Mapping
  • strengthen malloc pprof tests with:
    • profile.Parse(...)
    • p.CheckValid()
    • non-nil Location.Mapping assertions
  • update regression TKE template to include [malloc] config for tp / dn

We previously observed that /debug/malloc was parseable by go tool pprof, and Pyroscope could discover malloc profile types, but agent/backend ingest could still fail with nil pointer dereference. The remaining MatrixOne-side compatibility gap appeared to be Location.Mapping == nil in the emitted profile.

Validation:

  • malloc pprof round-trip/validity test added and strengthened
  • isolated TKE validation using the forked build from this change
  • malloc profile types visible in Pyroscope API
  • CN/DN series queryable
  • stacktrace/flamegraph data queryable
  • previous nil-pointer ingest failure did not reproduce in short-window validation

Longer soak / overhead validation is handled separately in mo-auto-test.

@CLAassistant

CLAassistant commented Apr 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

- Rename sample types to alloc_objects, alloc_space, inuse_objects, inuse_space; default inuse_space
- Set PeriodType, Period, TimeNanos, and Mapping.HasFunctions in Profiler.Write
- Add heap_profiler_pprof_test for profile.Parse round-trip
- Add [malloc] block to mo_checkin_regression_tke.yaml for tp/dn

Made-with: Cursor
@mergify mergify Bot added kind/bug Something isn't working kind/enhancement labels Apr 27, 2026
@mergify

mergify Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-04-27 06:33 UTC · Rule: main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-04-27 07:35 UTC · at 748048952e2713883b29b12eb5a8f5edba2c240b · squash

This pull request spent 1 hour 2 minutes 6 seconds in the queue, including 1 hour 1 minute 38 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage

@mergify
mergify Bot merged commit 2fce858 into matrixorigin:main Apr 27, 2026
34 of 36 checks passed
@mergify mergify Bot removed the queued label Apr 27, 2026
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
…xorigin#24197)

This PR hardens MatrixOne's custom `/debug/malloc` pprof output for Pyroscope ingestion.

Changes:
- rename malloc profile sample types to Go heap-style names:
- `alloc_objects`
- `alloc_space`
- `inuse_objects`
- `inuse_space`
- populate pprof metadata in `Profiler.Write`:
- `PeriodType`
- `Period`
- `TimeNanos`
- `Mapping.HasFunctions`
- explicitly bind every emitted `profile.Location` to the default `profile.Mapping`
- strengthen malloc pprof tests with:
- `profile.Parse(...)`
- `p.CheckValid()`
- non-nil `Location.Mapping` assertions
- update regression TKE template to include `[malloc]` config for `tp` / `dn`

We previously observed that `/debug/malloc` was parseable by `go tool pprof`, and Pyroscope could discover `malloc` profile types, but agent/backend ingest could still fail with `nil pointer dereference`. The remaining MatrixOne-side compatibility gap appeared to be `Location.Mapping == nil` in the emitted profile.

Validation:
- malloc pprof round-trip/validity test added and strengthened
- isolated TKE validation using the forked build from this change
- `malloc` profile types visible in Pyroscope API
- CN/DN series queryable
- stacktrace/flamegraph data queryable
- previous nil-pointer ingest failure did not reproduce in short-window validation

Longer soak / overhead validation is handled separately in `mo-auto-test`.

Approved by: @fengttt, @aptend, @XuPeng-SH
@VioletQwQ-0
VioletQwQ-0 deleted the violet/malloc-pyroscope-pr branch May 20, 2026 09:49

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants