Skip to content

Support memory profiling #916

@luweglarz

Description

@luweglarz

Hello,

I am opening this issue because I thought it would be great to have memory profiling integrated to the opentelemetry-ebpf-profiler, and this is something I would like to tackle if it is decided that it is possible to do so.

Here is the strategy I imagine:

  1. eBPF program on Uprobe Entry (malloc/calloc/realloc...): Captures the size parameter
  2. eBPF program on Uretprobe Exit: Captures the returned memory address -> send alloc event
  3. eBPF program on Uprobe on Free: Captures the address being freed -> send free event
  4. User space needs to keep track of stack_traces holding > 0 memory alloc (not sure about how to make this part efficient)

For that I imagine that we could reuse the current eBPF architecture but with a TRACE_MEMORY origin, that would also send the memory alloc/free metadata and user space would do the correlation with trace_events and potential memory_events map.
Or creating a dedicated eBPF architecture for collecting stack_traces and memory metadata to be sent to user space when a memory alloc/free is triggered.

This is a naive intuition so far that would only capture virtual memory, but I think this is a beginning. so let me know what do you think !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions