Skip to content

reporter: split memory traces onto a dedicated ParcaReporter.ReportMemoryTraces path#3192

Draft
gnurizen wants to merge 1 commit into
mainfrom
oomprof-payload-frames
Draft

reporter: split memory traces onto a dedicated ParcaReporter.ReportMemoryTraces path#3192
gnurizen wants to merge 1 commit into
mainfrom
oomprof-payload-frames

Conversation

@gnurizen

Copy link
Copy Markdown
Contributor

What

Splits memory profiles off the otel TraceReporter contract onto a dedicated ParcaReporter.ReportMemoryTraces path.

Previously memory profiles rode on ReportTraceEvent: the oomprof adapter built a fake libpf.Trace per sample, stuffed alloc/free counters onto it via a synthetic memory payload frame (oomprofMemoryFrame = 0xFF), and tagged meta.Origin = TraceOriginMemory. That pushed memory-specific shape into the otel-facing trace interface and took one writer-lock acquisition per sample.

Changes

  • ParcaReporter is now an interface (reporter/iface.go) embedding the otel reporter.Reporter + ExecutableReporter, plus ReportMetrics, ReportMemoryTraces, and Logger. The concrete struct is arrowReporter; New(...) returns the interface.
  • ReportMemoryTraces writes memory rows v2-only, computes labels once per batch, takes the v2 writer lock once, and emits 2–4 rows per sample.
  • oomprof is wired through a new oomprofAdapter (reporter/oomprof_adapter.go) that chunks batches and forwards to ReportMemoryTraces.
  • Deletes the synthetic-payload-frame side channel: oomprofMemoryFrame, the case TraceOriginMemory branches in the v1/v2 builders, and SampleEvents on the concrete reporter.
  • Memory traces now tag meta.Origin as TraceOriginUnknown (the field isn't read on the memory path) rather than TraceOriginMemory.

Notes

  • Builds against the currently-pinned fork; TraceOriginMemory simply goes unused.
  • Pairs with a fork-side change in opentelemetry-ebpf-profiler that removes the now-unused TRACE_MEMORY trace origin. This PR should merge before that fork change is pinned into parca-agent, since main here still references TraceOriginMemory in the old memory path.

…moryTraces path

Memory profiles used to ride on the otel TraceReporter contract: the
oomprof adapter built a fake libpf.Trace per sample, stuffed alloc/free
counters onto it via a synthetic MemoryPayloadFrame, and called
ReportTraceEvent. That worked but pushed memory-specific shape into the
otel-facing trace interface and burned one writer-lock acquisition per
sample.

This commit gives memory traces their own seam:

  * `ParcaReporter` is now an interface (reporter/iface.go) embedding
    the otel `reporter.Reporter` + `ExecutableReporter` and adding
    `ReportMetrics` and the new `ReportMemoryTraces(samples, meta)`.
  * The concrete struct is renamed `arrowReporter`; `New(...)` returns
    the interface.
  * `arrowReporter.ReportMemoryTraces` writes memory rows v2-only,
    computes labels once per batch, takes the v2 writer lock once,
    and emits 2-4 rows (inuse_objects / inuse_space and, when
    enabled, alloc_objects / alloc_space) per sample.
  * The oomprof callback is wired through a new `oomprofAdapter`
    (reporter/oomprof_adapter.go) that implements `oomprof.Reporter`,
    chunks incoming batches into groups of 100, and forwards each
    chunk to `ReportMemoryTraces`.

That lets us delete:

  * `extractMemoryPayload` and its callers in `ReportTraceEvent`
    (the synthetic-payload-frame side channel).
  * The `oomprofMemoryFrame = 0xFF` shim plus its `case` in the
    v1 stacktrace builder and the v2 location builder.
  * The v1 and v2 `case TraceOriginMemory:` branches in
    `reportTraceEvent` / `reportTraceEventV2` (memory no longer
    flows through there).
  * `SampleEvents` on the concrete reporter, now replaced by the
    adapter.

Bonus: the v2 memory path now actually increments `r.memorySamples`
(the previous code only incremented it on the dead v1 branch).

No `main.go` source edits are required — the interface return from
`reporter.New` covers `Start`, `Stop`, `ReportTraceEvent`,
`ReportExecutable`, `ReportMetrics`, and the new
`ReportMemoryTraces`, satisfying every consumer (tracer, metrics,
parcagpu).
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.

1 participant