Skip to content

Conversation

@whyevenquestion1t
Copy link

Hey guys, love the stuff you're cooking here. Always wanted to learn eBPF so thanks for documenting all your issues here

This PR aims to tackle these two issues:

  1. feat(profiler): Define 32-byte profile event structure
  2. feat(profiler): Implement BPF ring buffer for profiler

When reading through the requirements of the second issue, I realized that you want to have a ring buffer per-CPU. Ring Buffers are designed to be shared across all CPUs. What would be the reason to have isolated ring buffers per CPU?

According to eBPF docs, if you were to proceed with implementing per-CPU ring buffers, you would lose major benefits that a single centralized Ring Buffer brings to the table. They are:

  1. Memory footprint - BPF ringbuf memory usage scales better with increased amount of CPUs, because going from 16 to 32 CPUs doesn’t necessarily require twice as big a buffer to accommodate more load.

  2. Event ordering - having a per-CPU ring buffer inherently introduces a problem of having to sync related events that are scattered across ring buffers/CPUs, making the application that needs to read those events more complex. (for example: fork(), exec(), and exit() can happen in a very rapid succession on different CPUs for short-lived processes due to the kernel scheduler migrating them from one CPU to another)

Let me know if i'm wrong here and feel free to correct! I would love to try and tackle the second issue, but before i do that, i'd like to get some clarity on whether you want to go per-CPU or single buffer. Thank you!

Reference:
https://nakryiko.com/posts/bpf-ringbuf/
https://www.kernel.org/doc/html/latest/bpf/ringbuf.html

@whyevenquestion1t
Copy link
Author

oops, didn't realize that there's already a PR for this: #182

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