Slide 1

Slide 1 text

rbperf: Understanding Ruby with BPF Javier Honduvilla Coto October 28th-29th, 2020

Slide 2

Slide 2 text

Why BPF?

Slide 3

Slide 3 text

Why BPF? - Flexibility

Slide 4

Slide 4 text

Why BPF? - Flexibility - Low overhead

Slide 5

Slide 5 text

Why BPF? - Flexibility - Low overhead - Continuous profiling

Slide 6

Slide 6 text

Why BPF? - Flexibility - Low overhead - Continuous profiling - No modifications of the tracee

Slide 7

Slide 7 text

rbperf

Slide 8

Slide 8 text

rbperf - Profile Ruby programs

Slide 9

Slide 9 text

rbperf - Profile Ruby programs - Trace complex Ruby programs execution

Slide 10

Slide 10 text

rbperf – on-CPU profiling - $ rbperf record --pid=124 cpu - $ rbperf report [...]

Slide 11

Slide 11 text

rbperf – Rails on-CPU profile

Slide 12

Slide 12 text

rbperf – tracing write(2) calls - $ rbperf record \ --pid=124 event \ --tracepoint=syscalls:sys_enter_write - $ rbperf report [...]

Slide 13

Slide 13 text

Architecture 2. Event (timer, syscall, etc) BPF code (bpf/rbperf.c) Read frame Driver (rbperf.py) 1. Adds info (pid to profile, thread address) 3. Receives stacktrace 4. Serialisation and persistence BPF tail-calls Bounded loop

Slide 14

Slide 14 text

Challenges - Implementing the stack walking for a dynamic language

Slide 15

Slide 15 text

Challenges - Implementing the stack walking for a dynamic language - Supporting multiple Ruby versions

Slide 16

Slide 16 text

Challenges - Implementing the stack walking for a dynamic language - Supporting multiple Ruby versions - Correctness testing

Slide 17

Slide 17 text

Challenges - Implementing the stack walking for a dynamic language - Supporting multiple Ruby versions - Correctness testing - BPF safety features

Slide 18

Slide 18 text

Future plans - Integrate in Facebook’s profiling infra - Rewrite OSS driver program - Make the OSS version awesome - Better documentation (including how to measure overhead) - Add more output formats - Open source GDB / drgn helper - Other tools? - Containers support? - Support request-oriented workloads?

Slide 19

Slide 19 text

Thanks! :) https://github.com/facebookexperimental/rbperf [email protected] @javierhonduco